Update notes for the book Testing Rails:
After defining the LinksController class, the book mentions:
Failure/Error: visit root_path
NoMethodError:
undefined method `action' for LinksController:Class
While Rails 7.0 returns:
Failure/Error: visit root_path
NoMethodError:
undefined method `action_encoding_template' for LinksController:Class
After adding ApplicationController
and creating the index
action, the new output is:
Failure/Error: visit root_path
ActionController::MissingExactTemplate:
LinksController#index is missing a template for request formats: text/html
FactoryBot examples use the old syntax, without braces. For example:
# spec/factories.rb
FactoryGirl.define do
factory :link do
title "Testing Rails"
url "http://testingrailsbook.com"
end
end
# In your test
link = create(:link)
# Or override the title
link = create(:link, title: "TDD isn't Dead!")
Should be:
# spec/factories.rb
FactoryBot.define do
factory :link do
title { "Testing Rails" }
url { "http://testingrailsbook.com" }
end
end
# In your test
link = FactoryBot.create(:link)
# Or override the title
link = FactoryBot.create(:link, title: "TDD isn't Dead!")
Commented out line now reads:
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }
Commit https://github.com/thoughtbot/testing-rails/commit/10eb83b613bbaf46db7737acdd71ead7052f569a skipped - Not needed, it is already set by default.
Commit https://github.com/thoughtbot/testing-rails/commit/384a7cc1b99aa5f0e737d3432e58b7e52ca0f522 skipped - it's different in newer Rails versions.