Class: RSpec::RubyContentMatchers::HaveCalls
- Inherits:
-
Object
- Object
- RSpec::RubyContentMatchers::HaveCalls
- Defined in:
- lib/rspec_for_generators/matchers/content/have_calls.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#calls ⇒ Object
readonly
Returns the value of attribute calls.
-
#method ⇒ Object
Returns the value of attribute method.
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(calls) ⇒ HaveCalls
constructor
A new instance of HaveCalls.
- #matches?(content) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(calls) ⇒ HaveCalls
Returns a new instance of HaveCalls.
6 7 8 |
# File 'lib/rspec_for_generators/matchers/content/have_calls.rb', line 6 def initialize(calls) @calls = calls end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
4 5 6 |
# File 'lib/rspec_for_generators/matchers/content/have_calls.rb', line 4 def args @args end |
#calls ⇒ Object (readonly)
Returns the value of attribute calls.
3 4 5 |
# File 'lib/rspec_for_generators/matchers/content/have_calls.rb', line 3 def calls @calls end |
#method ⇒ Object
Returns the value of attribute method.
4 5 6 |
# File 'lib/rspec_for_generators/matchers/content/have_calls.rb', line 4 def method @method end |
Instance Method Details
#failure_message ⇒ Object
19 20 21 22 |
# File 'lib/rspec_for_generators/matchers/content/have_calls.rb', line 19 def 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
10 11 12 13 14 15 16 17 |
# File 'lib/rspec_for_generators/matchers/content/have_calls.rb', line 10 def matches?(content) calls.each_pair do |method, args| @method = method @args = args return false if (content =~ /#{method}\s+#{args_expr}/m) == nil end true end |
#negative_failure_message ⇒ Object
24 25 26 27 |
# File 'lib/rspec_for_generators/matchers/content/have_calls.rb', line 24 def 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 |