Class: Spec::Rails::Matchers::RenderTemplate
- Defined in:
- lib/vendor/plugins/make_resourceful/spec/rspec-rails/render_template.rb,
lib/vendor/plugins/rspec-rails/lib/spec/rails/matchers/render_template.rb
Overview
:nodoc:
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(expected, controller) ⇒ RenderTemplate
constructor
A new instance of RenderTemplate.
- #match_files(actual, expected) ⇒ Object
- #matches?(response_or_controller) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(expected, controller) ⇒ RenderTemplate
Returns a new instance of RenderTemplate.
7 8 9 10 |
# File 'lib/vendor/plugins/make_resourceful/spec/rspec-rails/render_template.rb', line 7 def initialize(expected, controller) @controller = controller @expected = expected end |
Instance Method Details
#description ⇒ Object
33 34 35 |
# File 'lib/vendor/plugins/make_resourceful/spec/rspec-rails/render_template.rb', line 33 def description "render template #{@expected.inspect}" end |
#failure_message ⇒ Object
25 26 27 |
# File 'lib/vendor/plugins/make_resourceful/spec/rspec-rails/render_template.rb', line 25 def "expected #{@expected.inspect}, got #{@actual.inspect}" end |
#failure_message_for_should ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/vendor/plugins/rspec-rails/lib/spec/rails/matchers/render_template.rb', line 50 def if @redirect_url "expected #{@expected.inspect}, got redirected to #{@redirect_url.inspect}" else "expected #{@expected.inspect}, got #{@actual.inspect}" end end |
#failure_message_for_should_not ⇒ Object
58 59 60 |
# File 'lib/vendor/plugins/rspec-rails/lib/spec/rails/matchers/render_template.rb', line 58 def "expected not to render #{@expected.inspect}, but did" end |
#match_files(actual, expected) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/vendor/plugins/rspec-rails/lib/spec/rails/matchers/render_template.rb', line 41 def match_files(actual, expected) actual_parts = actual.split('.') expected_parts = expected.split('.') expected_parts.each_with_index do |expected_part, index| return false unless expected_part == actual_parts[index] end true end |
#matches?(response_or_controller) ⇒ Boolean
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/vendor/plugins/make_resourceful/spec/rspec-rails/render_template.rb', line 12 def matches?(response) if response.respond_to?(:rendered_file) @actual = response.rendered_file else @actual = response.rendered_template.to_s end return false if @actual.blank? given_controller_path, given_file = path_and_file(@actual) expected_controller_path, expected_file = path_and_file(@expected) given_controller_path == expected_controller_path && given_file.match(expected_file) end |
#negative_failure_message ⇒ Object
29 30 31 |
# File 'lib/vendor/plugins/make_resourceful/spec/rspec-rails/render_template.rb', line 29 def "expected not to render #{@expected.inspect}, but did" end |