Class: Warp::ActionMatchers::CreateMatcher
- Inherits:
-
Matcher
show all
- Defined in:
- lib/warp/action_matchers/create_matcher.rb
Constant Summary
collapse
- CREATE_METHOD =
:create
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Matcher
#description_of, #failure_message_for_should, #failure_message_for_should_not, #values_match?
Constructor Details
Returns a new instance of CreateMatcher.
15
16
17
|
# File 'lib/warp/action_matchers/create_matcher.rb', line 15
def initialize(model)
@model = model
end
|
Instance Attribute Details
#model ⇒ Object
Returns the value of attribute model.
13
14
15
|
# File 'lib/warp/action_matchers/create_matcher.rb', line 13
def model
@model
end
|
Instance Method Details
#description ⇒ Object
30
31
32
|
# File 'lib/warp/action_matchers/create_matcher.rb', line 30
def description
"create a #{model_name}"
end
|
#failure_message ⇒ Object
34
35
36
|
# File 'lib/warp/action_matchers/create_matcher.rb', line 34
def failure_message
"expected a #{model_name} to be created"
end
|
#failure_message_when_negated ⇒ Object
38
39
40
|
# File 'lib/warp/action_matchers/create_matcher.rb', line 38
def failure_message_when_negated
"expected no #{model_name} to be created"
end
|
#matches?(actual) ⇒ Boolean
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/warp/action_matchers/create_matcher.rb', line 19
def matches?(actual)
check_callable!(actual)
instrument = Warp::Instrument.for(model, CREATE_METHOD)
instrument.reset
instrument.run { actual.call }
instrument.calls.size > 0
end
|