Class Spec::Rails::Example::HelperExampleGroup
In: vendor/plugins/rspec_on_rails/lib/spec/rails/example/helper_example_group.rb
Parent: FunctionalExampleGroup

Helper Specs live in $RAILS_ROOT/spec/helpers/.

Helper Specs use Spec::Rails::Example::HelperExampleGroup, which allows you to include your Helper directly in the context and write specs directly against its methods.

HelperExampleGroup also includes the standard lot of ActionView::Helpers in case your helpers rely on any of those.

Example

  class ThingHelper
    def number_of_things
      Thing.count
    end
  end

  describe "ThingHelper example_group" do
    include ThingHelper
    it "should tell you the number of things" do
      Thing.should_receive(:count).and_return(37)
      number_of_things.should == 37
    end
  end

Methods

Public Class methods

The helper name.…

[Source]

    # File vendor/plugins/rspec_on_rails/lib/spec/rails/example/helper_example_group.rb, line 31
31:           def helper_name(name=nil)
32:             send :include, "#{name}_helper".camelize.constantize
33:           end

Public Instance methods

[Source]

    # File vendor/plugins/rspec_on_rails/lib/spec/rails/example/helper_example_group.rb, line 60
60:         def eval_erb(text)
61:           ERB.new(text).result(binding)
62:         end

[Source]

    # File vendor/plugins/rspec_on_rails/lib/spec/rails/example/helper_example_group.rb, line 56
56:         def flash
57:           @flash
58:         end

TODO: BT - Helper Examples should proxy method_missing to a Rails View instance. When that is done, remove this method

[Source]

    # File vendor/plugins/rspec_on_rails/lib/spec/rails/example/helper_example_group.rb, line 67
67:         def protect_against_forgery?
68:           false
69:         end

[Validate]