Class: Rails::AddOns::Shoulda::Matchers::ImplementIndexActionMatcher
- Inherits:
-
Object
- Object
- Rails::AddOns::Shoulda::Matchers::ImplementIndexActionMatcher
- Includes:
- RSpec::Matchers
- Defined in:
- lib/rails/add_ons/shoulda/matchers/implement_index_action_matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object (also: #negative_failure_message)
- #has_correct_current_path ⇒ Object
- #has_correct_status_code ⇒ Object
-
#initialize(spec) ⇒ ImplementIndexActionMatcher
constructor
A new instance of ImplementIndexActionMatcher.
- #matches?(base_path) ⇒ Boolean
Constructor Details
#initialize(spec) ⇒ ImplementIndexActionMatcher
Returns a new instance of ImplementIndexActionMatcher.
20 21 22 |
# File 'lib/rails/add_ons/shoulda/matchers/implement_index_action_matcher.rb', line 20 def initialize(spec) @spec = spec end |
Instance Method Details
#description ⇒ Object
58 59 60 |
# File 'lib/rails/add_ons/shoulda/matchers/implement_index_action_matcher.rb', line 58 def description "expose index action on #{@base_path}" end |
#failure_message ⇒ Object
48 49 50 |
# File 'lib/rails/add_ons/shoulda/matchers/implement_index_action_matcher.rb', line 48 def "Should expose index action on #{@base_path}. Error: #{@error}" end |
#failure_message_when_negated ⇒ Object Also known as: negative_failure_message
52 53 54 |
# File 'lib/rails/add_ons/shoulda/matchers/implement_index_action_matcher.rb', line 52 def "Should not expose index action on #{@base_path}. Error: #{@error}" end |
#has_correct_current_path ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/rails/add_ons/shoulda/matchers/implement_index_action_matcher.rb', line 39 def has_correct_current_path if @spec.current_path == @base_path true else @error = "Wrong current path [#{@spec.current_path}] instead of [#{@base_path}]" false end end |
#has_correct_status_code ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/rails/add_ons/shoulda/matchers/implement_index_action_matcher.rb', line 30 def has_correct_status_code if @spec.status_code == 200 true else @error = "Wrong status code [#{@spec.status_code}] instead of [200]" false end end |
#matches?(base_path) ⇒ Boolean
24 25 26 27 28 |
# File 'lib/rails/add_ons/shoulda/matchers/implement_index_action_matcher.rb', line 24 def matches?(base_path) @base_path = base_path @spec.visit(@base_path) has_correct_status_code && has_correct_current_path end |