Sha256: 97737a1fa6963ed1c575f3780a018ba2fcbeb65d00e5b2af786d9b83593fe9fd

Contents?: true

Size: 1.85 KB

Versions: 38

Compression:

Stored size: 1.85 KB

Contents

module Shoulda # :nodoc:
  module ActionView # :nodoc:
    # = 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
    #
    #     should_render_page_with_metadata :title => /index/
    #
    #     should "do something else really cool" do
    #       assert_select '#really_cool'
    #     end
    #   end
    #
    # Would produce 3 tests for the +show+ action
    module Macros

      # Macro that creates a test asserting that the rendered view contains a <form> element.
      #
      # Deprecated.
      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

      # Deprecated.
      #
      # Macro that creates a test asserting that the rendered view contains the selected metatags.
      # Values can be string or Regexps.
      # Example:
      #
      #   should_render_page_with_metadata :description => "Description of this page", :keywords => /post/
      #
      # You can also use this method to test the rendered views title.
      #
      # Example:
      #   should_render_page_with_metadata :title => /index/
      def should_render_page_with_metadata(options)
        warn "[DEPRECATION] should_render_page_with_metadata is deprecated."
        options.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
    end
  end
end

Version data entries

38 entries across 38 versions & 10 rubygems

Version Path
auser-poolparty-1.3.0 vendor/gems/shoulda/lib/shoulda/action_view/macros.rb
auser-poolparty-1.3.1 vendor/gems/shoulda/lib/shoulda/action_view/macros.rb
auser-poolparty-1.3.10 vendor/gems/shoulda/lib/shoulda/action_view/macros.rb
auser-poolparty-1.3.11 vendor/gems/shoulda/lib/shoulda/action_view/macros.rb
auser-poolparty-1.3.12 vendor/gems/shoulda/lib/shoulda/action_view/macros.rb
auser-poolparty-1.3.13 vendor/gems/shoulda/lib/shoulda/action_view/macros.rb
auser-poolparty-1.3.14 vendor/gems/shoulda/lib/shoulda/action_view/macros.rb
auser-poolparty-1.3.15 vendor/gems/shoulda/lib/shoulda/action_view/macros.rb
auser-poolparty-1.3.16 vendor/gems/shoulda/lib/shoulda/action_view/macros.rb
auser-poolparty-1.3.17 vendor/gems/shoulda/lib/shoulda/action_view/macros.rb
auser-poolparty-1.3.2 vendor/gems/shoulda/lib/shoulda/action_view/macros.rb
auser-poolparty-1.3.3 vendor/gems/shoulda/lib/shoulda/action_view/macros.rb
auser-poolparty-1.3.4 vendor/gems/shoulda/lib/shoulda/action_view/macros.rb
auser-poolparty-1.3.5 vendor/gems/shoulda/lib/shoulda/action_view/macros.rb
auser-poolparty-1.3.6 vendor/gems/shoulda/lib/shoulda/action_view/macros.rb
auser-poolparty-1.3.7 vendor/gems/shoulda/lib/shoulda/action_view/macros.rb
auser-poolparty-1.3.8 vendor/gems/shoulda/lib/shoulda/action_view/macros.rb
fairchild-poolparty-1.3.17 vendor/gems/shoulda/lib/shoulda/action_view/macros.rb
fairchild-poolparty-1.3.5 vendor/gems/shoulda/lib/shoulda/action_view/macros.rb
iGEL-shoulda-2.10.2 lib/shoulda/action_view/macros.rb