Class: Surrogate::RSpec::WithFilter::RSpecMatchAsserter

Inherits:
Object
  • Object
show all
Defined in:
lib/surrogate/rspec/with_filter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(actual_invocation, expected_invocation) ⇒ RSpecMatchAsserter

Returns a new instance of RSpecMatchAsserter.



10
11
12
# File 'lib/surrogate/rspec/with_filter.rb', line 10

def initialize(actual_invocation, expected_invocation)
  self.actual_invocation, self.expected_invocation = actual_invocation, expected_invocation
end

Instance Attribute Details

#actual_invocationObject

Returns the value of attribute actual_invocation.



8
9
10
# File 'lib/surrogate/rspec/with_filter.rb', line 8

def actual_invocation
  @actual_invocation
end

#expected_invocationObject

Returns the value of attribute expected_invocation.



8
9
10
# File 'lib/surrogate/rspec/with_filter.rb', line 8

def expected_invocation
  @expected_invocation
end

Instance Method Details

#approximate_2_11?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/surrogate/rspec/with_filter.rb', line 23

def approximate_2_11?
  Gem::Requirement.create('~> 2.11').satisfied_by? Gem::Version.new(::RSpec::Mocks::Version::STRING)
end

#approximate_3_0_0_rc?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/surrogate/rspec/with_filter.rb', line 27

def approximate_3_0_0_rc?
  Gem::Requirement.create('~> 3.0.0.rc').satisfied_by? Gem::Version.new(::RSpec::Mocks::Version::STRING)
end

#match?Boolean

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/surrogate/rspec/with_filter.rb', line 14

def match?
  rspec_arg_expectation = matcher_class.new *expected_invocation.args
  rspec_arg_expectation.args_match? *actual_invocation.args
end

#matcher_classObject



19
20
21
# File 'lib/surrogate/rspec/with_filter.rb', line 19

def matcher_class
  ::RSpec::Mocks::ArgumentListMatcher
end