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.
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
The helper name.…
# 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
# 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
# File vendor/plugins/rspec_on_rails/lib/spec/rails/example/helper_example_group.rb, line 56 56: def flash 57: @flash 58: end