← Back to Upcase

Testing Fundamentals - Write an Integration Test

(Upcase ) #1

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]: https://thoughtbot.com/upcase/testing-fundamentals

(Rick Liu) #2

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

(Chris Toomey) #3

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!

(Rick Liu) #4

Thanks! I should read more Rails Guides :smile:

(Tom Freudenheim) #5

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 http://stackoverflow.com/questions/5528839/why-does-installing-nokogiri-on-mac-os-fail-with-libiconv-is-missing/25561761
See the solution by Micah Winkelspecht