Class: Operandi::RSpec::Matchers::DefineStepMatcher
- Inherits:
-
Object
- Object
- Operandi::RSpec::Matchers::DefineStepMatcher
- Defined in:
- lib/operandi/rspec/matchers/define_step.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(name) ⇒ DefineStepMatcher
constructor
A new instance of DefineStepMatcher.
- #matches?(service_class) ⇒ Boolean
- #with_always(value = true) ⇒ Object
- #with_if(condition) ⇒ Object
- #with_unless(condition) ⇒ Object
Constructor Details
#initialize(name) ⇒ DefineStepMatcher
Returns a new instance of DefineStepMatcher.
38 39 40 41 42 43 |
# File 'lib/operandi/rspec/matchers/define_step.rb', line 38 def initialize(name) @name = name @expected_always = nil @expected_if = nil @expected_unless = nil end |
Instance Method Details
#description ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/operandi/rspec/matchers/define_step.rb', line 85 def description desc = "define step :#{@name}" desc += " with always: #{@expected_always}" unless @expected_always.nil? desc += " with if: #{@expected_if.inspect}" if @expected_if desc += " with unless: #{@expected_unless.inspect}" if @expected_unless desc end |
#failure_message ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'lib/operandi/rspec/matchers/define_step.rb', line 72 def return "expected #{@actual_class} to define step :#{@name}" unless step_defined? return unless always_matches? return unless if_matches? return unless unless_matches? "" end |
#failure_message_when_negated ⇒ Object
81 82 83 |
# File 'lib/operandi/rspec/matchers/define_step.rb', line 81 def "expected #{@actual_class} not to define step :#{@name}" end |
#matches?(service_class) ⇒ Boolean
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/operandi/rspec/matchers/define_step.rb', line 60 def matches?(service_class) @service_class = service_class @actual_class = service_class.is_a?(Class) ? service_class : service_class.class return false unless step_defined? return false unless always_matches? return false unless if_matches? return false unless unless_matches? true end |
#with_always(value = true) ⇒ Object
45 46 47 48 |
# File 'lib/operandi/rspec/matchers/define_step.rb', line 45 def with_always(value = true) @expected_always = value self end |
#with_if(condition) ⇒ Object
50 51 52 53 |
# File 'lib/operandi/rspec/matchers/define_step.rb', line 50 def with_if(condition) @expected_if = condition self end |
#with_unless(condition) ⇒ Object
55 56 57 58 |
# File 'lib/operandi/rspec/matchers/define_step.rb', line 55 def with_unless(condition) @expected_unless = condition self end |