Anyone know how to get around this? On OSX, trying to get RSpec running with Rails 3.0.7. Full details at: https://gist.github.com/1017044
it \"renders but
I was able to fix this issue in my app by adding require 'rspec/rails'
to my spec_helper file.
If at all you are using 'spec/features', you may need to add the following to your 'spec_helper.rb'
config.include RSpec::Rails::RequestExampleGroup, type: :feature
I had this issue when I added
gem 'rspec'
to my Gemfile in the rails project. It should be
gem 'rspec'
gem 'rspec-rails'
(or just rspec-rails). After
bundle install
re-create the spec directory with
rspec --init
and put your xxx_spec.rb file in the appropriate directory (won't work if it is in the spec directory). Beginners error but maybe this helps somebody ;) Here's the link that helped me:
https://www.relishapp.com/rspec/rspec-rails/docs/gettingstarted
For others looking into this. I was trying to track down a undefined method 'get'
error. My issue was that I had the get
in a describe block
make sure your get
is in an it block
.
If you used rspec
to generate the .rspec
file, you should change the content from:
--require spec_helper
to:
--require rails_helper
An alternative is to specify type: :request
for your spec. For example:
RSpec.describe "Widget management", :type => :request do
it "creates a Widget and redirects to the Widget's page" do
get "/widgets/new"
expect(response).to render_template(:new)
post "/widgets", :widget => {:name => "My Widget"}
expect(response).to redirect_to(assigns(:widget))
follow_redirect!
expect(response).to render_template(:show)
expect(response.body).to include("Widget was successfully created.")
end
end
Example taken from here https://www.relishapp.com/rspec/rspec-rails/docs/request-specs/request-spec.