Sha256: 39cdbbd1f1b037e57ab5d1dab9e1c5e2c603356b80bb2901ef9c47a0274bf00b

Contents?: true

Size: 809 Bytes

Versions: 2

Compression:

Stored size: 809 Bytes

Contents

require 'rspec/expectations'

module Approvals
  module RSpec
    module DSL
      def executable(command, &block)
        Approvals::Executable.new(command, &block)
      end

      def verify(options = {}, &block)
        group = eval "self", block.binding
        namer = ::RSpec.configuration.approvals_namer_class.new(group.example)
        Approvals.verify(block.call, options.merge(:namer => namer))
      rescue ApprovalError => e
        if diff_on_approval_failure?
          ::RSpec::Expectations.fail_with(e.message, e.approved_text, e.received_text)
        else
          raise e
        end
      end

      private

      def diff_on_approval_failure?
        ::RSpec.configuration.diff_on_approval_failure? ||
          example.metadata[:diff_on_approval_failure]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
approvals-0.0.11 lib/approvals/extensions/rspec/dsl.rb
approvals-0.0.10 lib/approvals/extensions/rspec/dsl.rb