This topic is for the [Write an Integration Test] exercise in the [Testing Fundamentals] trail. Post any questions, corrections, or pointers you have to share with other Upcase subscribers.
[Write an Integration Test]: https://exercises.upcase.com/exercises/testing-fundamentals-write-an-integration-test
[Testing Fundamentals]: Introduction to Ruby Tests | Learn RSpec | Testing Fundamentals
Why do the routes to people#new
and people#show
result in person
? Why not people
?
# config/routes.rb
resources :people, only: [:new, :create, :show]
$ rake routes
Prefix Verb URI Pattern Controller#Action
people POST /people(.:format) people#create
new_person GET /people/new(.:format) people#new
person GET /people/:id(.:format) people#show
Rails automatically converts between singular and plural forms of words for you. You can see the logic documented in the Rails ActiveSupport Guide section on inflections. The logic with the routes is that the resources dealing with the collection will use the plural form, “people”, whereas the new and show actions (as well as edit and destroy) deal with a singular “person” resource.
Hope that helps!
Thanks! I should read more Rails Guides
If you are having trouble on OSX running ‘bin/setup’ because nokogiri has a failure related to missing library libiconv, try running
gem install nokogiri – --use-system-libraries
then rerun bin/setup
Details here ruby - Why does installing Nokogiri on Mac OS fail with libiconv is missing? - Stack Overflow
See the solution by Micah Winkelspecht