Skip to Content
Rails 5 Test Prescriptions
book

Rails 5 Test Prescriptions

by Noel Rappin
February 2018
Intermediate to advanced
406 pages
9h 52m
English
Pragmatic Bookshelf
Content preview from Rails 5 Test Prescriptions

Connecting the JavaScript to the Server Code

Were you to run the RSpec tests now that you’ve moved all the logic to JavaScript, you’d find that both tests in spec/system/add_task_spec.rb fail. The first test, which did not run in the JavaScript browser, fails because without JavaScript the tasks don’t display at all. That’s to be expected, and the test can be removed as its logic is now covered elsewhere.

The JavaScript test also fails for a couple of reasons. The simple one is the JavaScript makes a new Ajax call to get the JSON data for the tasks. To make that work, you need to make a small change to the ProjectsController#show method:

 def​ show
  @project = Project.find(params[​:id​]) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Rails 4 Test Prescriptions

Rails 4 Test Prescriptions

Noel Rappin
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz
Agile Web Development with Rails 5.1

Agile Web Development with Rails 5.1

Sam Ruby, David B. Copeland, Dave Thomas

Publisher Resources

ISBN: 9781680505566Errata Page