Class: LiveResource::RSpec::DependOn
- Inherits:
-
Object
- Object
- LiveResource::RSpec::DependOn
- Defined in:
- lib/live_resource/rspec/depend_on.rb
Overview
Tests that a LiveResource::Resource has a dependency on the given target, optionally for the given events.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #for_events(*events) ⇒ Object
-
#initialize(target) ⇒ DependOn
constructor
A new instance of DependOn.
- #matches?(live_resource) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(target) ⇒ DependOn
Returns a new instance of DependOn.
5 6 7 |
# File 'lib/live_resource/rspec/depend_on.rb', line 5 def initialize(target) @target = target end |
Instance Method Details
#description ⇒ Object
25 26 27 |
# File 'lib/live_resource/rspec/depend_on.rb', line 25 def description "depend on #{@target.inspect}" end |
#failure_message ⇒ Object
17 18 19 |
# File 'lib/live_resource/rspec/depend_on.rb', line 17 def "expected '#{@live_resource.name}' resource to depend on #{@target.inspect} but it instead depended on #{@actual_targets}" end |
#for_events(*events) ⇒ Object
29 30 31 32 |
# File 'lib/live_resource/rspec/depend_on.rb', line 29 def for_events(*events) @for_events = events self end |
#matches?(live_resource) ⇒ Boolean
9 10 11 12 13 14 15 |
# File 'lib/live_resource/rspec/depend_on.rb', line 9 def matches?(live_resource) @live_resource = live_resource @actual_targets = @live_resource.dependencies.map { |dependency| dependency.target } return @actual_targets.include?(@target) end |
#negative_failure_message ⇒ Object
21 22 23 |
# File 'lib/live_resource/rspec/depend_on.rb', line 21 def "expected '#{@live_resource.name}' resource not to depend on #{@target.inspect} but it instead depended on #{@actual_targets}" end |