how to tell Rails RSpec that spec is "type helper"

Posted by equivalent8 on Stack Overflow See other posts from Stack Overflow or by equivalent8
Published on 2012-07-05T09:06:52Z Indexed on 2012/07/05 9:15 UTC
Read the original article Hit count: 273

I wrote *simple_form* input extension that is located in app/inputs/something_input.rb

I'm trying to write RSpec for this. When I put this spec inside spec/helpers/application_helper_spec.rb everything was working without single problem.

# spec/helpers/application_helper_spec.rb
require 'spec_helper'
describe ApplicationHelper do
  it do
    helper.simple_form_for @foo,:method=>'get', :url=>helper.users_path do |f|
      f.input :created_at, :as =>:custom_datepicker
    end.should =~ /something/
  end
end

Now I'm trying to move that spec to spec/inputs/something_input_spec.rb so it will be similar name path.

# spec/imputs/something_input_spec.rb
require 'spec_helper'
describe SomethingInput do
  it do
    helper.simple_form_for @foo,:method=>'get', :url=>helper.users_path do |f|
      f.input :created_at, :as =>:custom_datepicker
    end.should =~ /something/
  end
end
#
#ERROR:   undefined local variable or method `helper' for #<RSpec::Core::ExampleGroup

the thing I want to tell RSpec to threat this file as type helper spec, so I will have helper method availible with all the RSpec::Rails::HelperExampleGroup functionality

... how can I do that ??

I was trying to extend/include it with RSpec::Rails::HelperExampleGroup nothing seems to work

© Stack Overflow or respective owner

Related posts about ruby-on-rails-3

Related posts about rspec