Class: RSpec::RubyContentMatchers::HaveCall
- Inherits:
-
Object
- Object
- RSpec::RubyContentMatchers::HaveCall
- Defined in:
- lib/rspec_for_generators/matchers/content/have_call.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(method, args = nil) ⇒ HaveCall
constructor
A new instance of HaveCall.
- #matches?(content) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(method, args = nil) ⇒ HaveCall
Returns a new instance of HaveCall.
12 13 14 15 |
# File 'lib/rspec_for_generators/matchers/content/have_call.rb', line 12 def initialize(method, args = nil) @method = method.to_s @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
10 11 12 |
# File 'lib/rspec_for_generators/matchers/content/have_call.rb', line 10 def args @args end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
10 11 12 |
# File 'lib/rspec_for_generators/matchers/content/have_call.rb', line 10 def content @content end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
10 11 12 |
# File 'lib/rspec_for_generators/matchers/content/have_call.rb', line 10 def method @method end |
Instance Method Details
#failure_message ⇒ Object
22 23 24 25 26 |
# File 'lib/rspec_for_generators/matchers/content/have_call.rb', line 22 def puts "Content: #{content}" if RSpec::Generator.debug? 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
17 18 19 20 |
# File 'lib/rspec_for_generators/matchers/content/have_call.rb', line 17 def matches?(content) @content = content (content =~ /#{method}#{args_expr}/m) != nil end |
#negative_failure_message ⇒ Object
28 29 30 31 32 |
# File 'lib/rspec_for_generators/matchers/content/have_call.rb', line 28 def puts "Content: #{content}" if RSpec::Generator.debug? 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 |