Michael Hartl's RoR Tutorial chapter 3 rails generate integration_test does nothing [closed]
-
11-12-2019 - |
Question
I am new to Ruby on Rails and I am following Michael Hartl's Ruby on rails tutorial. I am on chapter 3 at Test Driven Development. When I run the command
rails generate integration_test static_pages
it does nothing. No error and no spec files get created. I have installed rails using railsinstaller.
What to do next?
Solution
I'm not sure why it's not generating files for you. It worked when I tried it.
Only one file gets generated:
require 'test_helper'
class StaticPagesTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end
which goes in test/integration/static_pages_test.rb
OTHER TIPS
It's a simple problem. Put the rspec-rails into the development and test groups of your gemfile:
group :development, :test do
gem 'rspec-rails'
end
Then bundle and you'll be set. When you run rails g integration_test , it'll now generate the test files. The reason is that the rspec-generators are only exposed when the gem is also in the development group (as opposed to just the test group.)
Not sure why you would get no errors. I have to use
bundle exec rails generate integration_test static_pages
for it to work.
I have the same problem (i.e. no error and no spec files get created) and EricM's solution does not work for me. I manually created the following file in spec/requests/static_pages_spec.rb and it seems to have worked (I had to create the requests directory in spec):
require 'spec_helper'
describe "Static pages" do
describe "Home page" do
it "should have the content 'Sample App'" do
visit '/static_pages/home'
page.should have_content('Sample App')
end
end
end
This is the same code that is used in Listing 3.9 of the book: http://ruby.railstutorial.org/chapters/static-pages#sec:TDD