Class: RSpec::RubyContentMatchers::HaveCalls
- Inherits:
-
RSpec::RubyContentMatcher
- Object
- RSpec::RubyContentMatcher
- RSpec::RubyContentMatchers::HaveCalls
- Defined in:
- lib/generator_spec/matchers/content/have_calls.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#calls ⇒ Object
readonly
Returns the value of attribute calls.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
Attributes inherited from RSpec::RubyContentMatcher
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(calls) ⇒ HaveCalls
constructor
A new instance of HaveCalls.
- #matches?(content) ⇒ Boolean
- #negative_failure_message ⇒ Object
Methods inherited from RSpec::RubyContentMatcher
Constructor Details
#initialize(calls) ⇒ HaveCalls
Returns a new instance of HaveCalls.
5 6 7 |
# File 'lib/generator_spec/matchers/content/have_calls.rb', line 5 def initialize(calls) @calls = calls end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
3 4 5 |
# File 'lib/generator_spec/matchers/content/have_calls.rb', line 3 def args @args end |
#calls ⇒ Object (readonly)
Returns the value of attribute calls.
3 4 5 |
# File 'lib/generator_spec/matchers/content/have_calls.rb', line 3 def calls @calls end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
3 4 5 |
# File 'lib/generator_spec/matchers/content/have_calls.rb', line 3 def method @method end |
Instance Method Details
#failure_message ⇒ Object
19 20 21 22 23 |
# File 'lib/generator_spec/matchers/content/have_calls.rb', line 19 def super return "Expected there to be a call to #{method} with args #{args}, but there wasn't" if args "Expected there to be a call to #{method}, but there wasn't" end |
#matches?(content) ⇒ Boolean
9 10 11 12 13 14 15 16 17 |
# File 'lib/generator_spec/matchers/content/have_calls.rb', line 9 def matches?(content) super calls.each_pair do |method, args| @method = method.to_s @args = args return false if (content =~ /#{method}\s+#{args_expr}/m) == nil end true end |
#negative_failure_message ⇒ Object
25 26 27 28 29 |
# File 'lib/generator_spec/matchers/content/have_calls.rb', line 25 def super return "Did not expect there to be a call to #{method} with args #{args}, but there was" if args "Did not expect there to be a call to #{method}, but there was" end |