Class: Rails::AddOns::Shoulda::Matchers::ImplementShowActionMatcher
- Inherits:
-
Object
- Object
- Rails::AddOns::Shoulda::Matchers::ImplementShowActionMatcher
- Includes:
- RSpec::Matchers
- Defined in:
- lib/rails/add_ons/shoulda/matchers/implement_show_action_matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object (also: #negative_failure_message)
-
#for(resource) ⇒ Object
Resource that will be updated.
- #has_correct_current_path ⇒ Object
- #has_correct_status_code ⇒ Object
- #id ⇒ Object
-
#initialize(spec) ⇒ ImplementShowActionMatcher
constructor
A new instance of ImplementShowActionMatcher.
- #matches?(base_path) ⇒ Boolean
Constructor Details
#initialize(spec) ⇒ ImplementShowActionMatcher
Returns a new instance of ImplementShowActionMatcher.
20 21 22 |
# File 'lib/rails/add_ons/shoulda/matchers/implement_show_action_matcher.rb', line 20 def initialize(spec) @spec = spec end |
Instance Method Details
#description ⇒ Object
71 72 73 |
# File 'lib/rails/add_ons/shoulda/matchers/implement_show_action_matcher.rb', line 71 def description "expose show action on #{@base_path}" end |
#failure_message ⇒ Object
61 62 63 |
# File 'lib/rails/add_ons/shoulda/matchers/implement_show_action_matcher.rb', line 61 def "Should expose show action on #{@base_path}. Error: #{@error}" end |
#failure_message_when_negated ⇒ Object Also known as: negative_failure_message
65 66 67 |
# File 'lib/rails/add_ons/shoulda/matchers/implement_show_action_matcher.rb', line 65 def "Should not expose show action on #{@base_path}. Error: #{@error}" end |
#for(resource) ⇒ Object
Resource that will be updated
25 26 27 28 |
# File 'lib/rails/add_ons/shoulda/matchers/implement_show_action_matcher.rb', line 25 def for(resource) @resource = resource self end |
#has_correct_current_path ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/rails/add_ons/shoulda/matchers/implement_show_action_matcher.rb', line 52 def has_correct_current_path if @spec.current_path == @expected_path true else @error = "Wrong current path [#{@spec.current_path}] instead of [#{@expected_path}]" false end end |
#has_correct_status_code ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/rails/add_ons/shoulda/matchers/implement_show_action_matcher.rb', line 43 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 |
#id ⇒ Object
30 31 32 |
# File 'lib/rails/add_ons/shoulda/matchers/implement_show_action_matcher.rb', line 30 def id @resource.to_param end |
#matches?(base_path) ⇒ Boolean
34 35 36 37 38 39 40 41 |
# File 'lib/rails/add_ons/shoulda/matchers/implement_show_action_matcher.rb', line 34 def matches?(base_path) @base_path = base_path @expected_path = "#{@base_path}/#{id}" @spec.visit(@expected_path) has_correct_status_code && has_correct_current_path end |