class TarkaMatchers::Helpers::Expectation::ExpectCapture
Attributes
actual_matcher[W]
Public Class Methods
capture(actual)
click to toggle source
# File lib/tarka_matchers/helpers/expectation/expect_capture.rb, line 9 def self.capture actual self.redefine actual.call self.replace @actual_matcher end
new(target, block_target)
click to toggle source
# File lib/tarka_matchers/helpers/expectation/expect_capture.rb, line 5 def initialize target, block_target target == :undefined ? @target = block_target.call : @target = target end
Private Class Methods
redefine()
click to toggle source
# File lib/tarka_matchers/helpers/expectation/expect_capture.rb, line 38 def self.redefine @rspec_matchers = ::RSpec::Matchers @real_expect = @rspec_matchers.instance_method :expect self.remove expect_capture = self @rspec_matchers.send(:define_method, :expect){ |target=:undefined, &block_target| expect_capture.new(target, block_target) } end
remove()
click to toggle source
# File lib/tarka_matchers/helpers/expectation/expect_capture.rb, line 34 def self.remove @rspec_matchers.send :remove_method, :expect end
replace()
click to toggle source
# File lib/tarka_matchers/helpers/expectation/expect_capture.rb, line 46 def self.replace self.remove @rspec_matchers.send(:define_method, :expect, @real_expect) end
Public Instance Methods
to(matcher)
click to toggle source
# File lib/tarka_matchers/helpers/expectation/expect_capture.rb, line 20 def to matcher match_populate 'should ', matcher end
to_not(matcher)
click to toggle source
# File lib/tarka_matchers/helpers/expectation/expect_capture.rb, line 24 def to_not matcher match_populate 'should not ', matcher end
Private Instance Methods
match_populate(verb, matcher)
click to toggle source
# File lib/tarka_matchers/helpers/expectation/expect_capture.rb, line 29 def match_populate verb, matcher matcher.send :matches?, @target self.class.actual_matcher = [verb,matcher] end