class RSpec::UnitExt::Expectation
Public Class Methods
new(example_group, **attributes)
click to toggle source
# File lib/rspec/unit_ext/expectation.rb, line 11 def initialize(example_group, **attributes) @example_group = example_group override_attributes attributes end
Public Instance Methods
run()
click to toggle source
# File lib/rspec/unit_ext/expectation.rb, line 16 def run evaluator = evaluator_proc matcher = matcher_inst failure = failure_proc if matcher.supports_block_expectations? @example_group.expect(&evaluator).to matcher, failure else @example_group.expect(evaluator.call).to matcher, failure end end
Private Instance Methods
evaluator_proc()
click to toggle source
# File lib/rspec/unit_ext/expectation.rb, line 30 def evaluator_proc lambda do @result = if args.is_a? Array base.send method, *args elsif args base.send method, args else base.send method end end end
failure_proc()
click to toggle source
# File lib/rspec/unit_ext/expectation.rb, line 46 def failure_proc base = self.base.inspect lambda do <<-FAILURE Unit Expectation Failed: Call: #{base}.#{method}(#{args}) Expected: #{expect} Got: #{@result} FAILURE end end
matcher_inst()
click to toggle source
# File lib/rspec/unit_ext/expectation.rb, line 42 def matcher_inst @example_group.send matcher, expect end