Module: Shoulda::ActionView::Macros
- Included in:
- Test::Unit::TestCase
- Defined in:
- lib/shoulda/action_view/macros.rb
Overview
Macro test helpers for your view
By using the macro helpers you can quickly and easily create concise and easy to read test suites.
This code segment:
context "on GET to :new" do
setup do
get :new
end
:title => /index/
should "do something else really cool" do
assert_select '#really_cool'
end
end
Would produce 3 tests for the show
action
Instance Method Summary collapse
-
#should_render_a_form ⇒ Object
Macro that creates a test asserting that the rendered view contains a <form> element.
-
#should_render_page_with_metadata(options) ⇒ Object
Deprecated.
Instance Method Details
#should_render_a_form ⇒ Object
Macro that creates a test asserting that the rendered view contains a <form> element.
Deprecated.
27 28 29 30 31 32 |
# File 'lib/shoulda/action_view/macros.rb', line 27 def should_render_a_form warn "[DEPRECATION] should_render_a_form is deprecated." should "display a form" do assert_select "form", true, "The template doesn't contain a <form> element" end end |
#should_render_page_with_metadata(options) ⇒ Object
Deprecated.
Macro that creates a test asserting that the rendered view contains the selected metatags. Values can be string or Regexps. Example:
:description => "Description of this page", :keywords => /post/
You can also use this method to test the rendered views title.
Example:
:title => /index/
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/shoulda/action_view/macros.rb', line 46 def () warn "[DEPRECATION] should_render_page_with_metadata is deprecated." .each do |key, value| should "have metatag #{key}" do if key.to_sym == :title assert_select "title", value else assert_select "meta[name=?][content#{"*" if value.is_a?(Regexp)}=?]", key, value end end end end |