Class: RBeautifyMatchers::BeBlockStartLike
- Defined in:
- lib/ruby-beautify/spec/spec_helper.rb
Overview
Adds more descriptive failure messages to the dynamic be_valid matcher
Instance Method Summary collapse
- #description ⇒ Object
- #expected_string ⇒ Object
- #failure_message ⇒ Object
- #got_string ⇒ Object
-
#initialize(block_matcher_name, offset, match, after_match) ⇒ BeBlockStartLike
constructor
:nodoc:.
- #matches?(target_block) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(block_matcher_name, offset, match, after_match) ⇒ BeBlockStartLike
:nodoc:
13 14 15 16 17 18 19 |
# File 'lib/ruby-beautify/spec/spec_helper.rb', line 13 def initialize(block_matcher_name, offset, match, after_match) # triggers the standard Spec::Matchers::Be magic, as if the original Spec::Matchers#method_missing had fired @block_matcher_name = block_matcher_name @offset = offset @match = match @after_match = after_match end |
Instance Method Details
#description ⇒ Object
43 44 45 |
# File 'lib/ruby-beautify/spec/spec_helper.rb', line 43 def description "block start with" end |
#expected_string ⇒ Object
35 36 37 |
# File 'lib/ruby-beautify/spec/spec_helper.rb', line 35 def expected_string "name: #{@block_matcher_name}, offset: #{@offset}, match: '#{@match}', after_match: '#{@after_match}'" end |
#failure_message ⇒ Object
27 28 29 |
# File 'lib/ruby-beautify/spec/spec_helper.rb', line 27 def "expected\n#{expected_string} but got\n#{got_string}" end |
#got_string ⇒ Object
39 40 41 |
# File 'lib/ruby-beautify/spec/spec_helper.rb', line 39 def got_string "name: #{@target_block.block_matcher.name}, offset: #{@target_block.offset}, match: '#{@target_block.match}', after_match: '#{@target_block.after_match}'" end |
#matches?(target_block) ⇒ Boolean
21 22 23 24 25 |
# File 'lib/ruby-beautify/spec/spec_helper.rb', line 21 def matches?(target_block) @target_block = target_block return !target_block.nil? && (expected_string == got_string) end |
#negative_failure_message ⇒ Object
31 32 33 |
# File 'lib/ruby-beautify/spec/spec_helper.rb', line 31 def "expected to be different from #{expected_string}" end |