Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Write Our First Tests

steven alston
steven alston
16,292 Points

code fails testing in newer version of ruby

I cannot pass the testing with the newer version of rails. The files are not the same, and I tried to add require "rails_helper" and delete the other require as mentioned previously in another forum post. However, that did not work either. Please Help! The sections commented out would not even test when added, even though I think there were no typos. For some reason, the code is not formatting right in the forum either. I tried using html tags p and code neither worked to format the code.

rails_helper.rb
ENV["RAILS_ENV"] ||= 'test'
require 'spec_helper'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rspec'</code>



create_spec.rb

require 'rails_helper'

describe 'Creating todo list' do 
    it "redirects to the todo list index page on success" do 
        visit "/todo_list"
        click_link "New Todo list"
        expect(page).to have_content("New todo_list")

        #fill_in "Title", with: "My todo list"
        #fill_in "Description", with: "This is what I'm doing today" 
        #click_button "Create Todo list"

        #expect(page)to have_content("My todo list")
    end
end```
cpauciello
cpauciello
26,629 Points

What versions of ruby/rails are you using?

David Moore
David Moore
13,916 Points

For code formatting on the forum, read over the Markdown Cheatsheet. It is linked below the comment/answer boxes. What you want to do is wrap your code with three `s (the key beside the 1 key on most keyboards). You can also add the language for proper highlighting.

Along with your code, it would also be helpful to get the error message provided.

steven alston
steven alston
16,292 Points

David Moore thanks for the info, that corrected the format in this forum. Any advice on getting this to pass? thanks!

steven alston
steven alston
16,292 Points

Here is what I am getting from the terminal when testing:

  1) Creating todo list redirects to the todo list index page on success
     Failure/Error: visit "/todo_list"
     ActionController::RoutingError:
       No route matches [GET] "/todo_list"
     # ./spec/features/todo_lists/create_spec.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.01412 seconds (files took 6.04 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/features/todo_lists/create_spec.rb:4```
steven alston
steven alston
16,292 Points

Ok, so I read error info that the terminal test provided. I was getting a failure because I entered: visit '/todo_lists' The (s) was not needed.

1 Answer

David Moore
David Moore
13,916 Points

Looks like you either have not yet set up the route in config/routes.rb or it is set up incorrectly. If you have any problems with setting up the route, we'll need to see your routes file as well.

Brian Patterson
Brian Patterson
19,588 Points

I am getting the same error.

1) Creating todo lists redirects to the todo list index page on success
     Failure/Error: visit "/todo_list"
     ActionController::RoutingError:
       No route matches [GET] "/todo_list"
     # ./spec/features/todo_lists/create_spec.rb:5:in `block (2 levels) in <top (required)>'

Deprecation Warnings:

--------------------------------------------------------------------------------
RSpec::Core::ExampleGroup#example is deprecated and will be removed
in RSpec 3. There are a few options for what you can use instead:

  - rspec-core's DSL methods (`it`, `before`, `after`, `let`, `subject`, etc)
    now yield the example as a block argument, and that is the recommended
    way to access the current example from those contexts.
  - The current example is now exposed via `RSpec.current_example`,
    which is accessible from any context.
  - If you can't update the code at this call site (e.g. because it is in
    an extension gem), you can use this snippet to continue making this
    method available in RSpec 2.99 and RSpec 3:

      RSpec.configure do |c|
        c.expose_current_running_example_as :example
      end

(Called from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/capybara-2.1.0/lib/capybara/rspec.rb:20:in `block (2 levels) in <top (required)>')
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
RSpec::Core::ExampleGroup#example is deprecated and will be removed
in RSpec 3. There are a few options for what you can use instead:

  - rspec-core's DSL methods (`it`, `before`, `after`, `let`, `subject`, etc)
    now yield the example as a block argument, and that is the recommended
    way to access the current example from those contexts.
  - The current example is now exposed via `RSpec.current_example`,
    which is accessible from any context.
  - If you can't update the code at this call site (e.g. because it is in
    an extension gem), you can use this snippet to continue making this
    method available in RSpec 2.99 and RSpec 3:

      RSpec.configure do |c|
        c.expose_current_running_example_as :example
      end

(Called from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/capybara-2.1.0/lib/capybara/rspec.rb:21:in `block (2 levels) in <top (required)>')
--------------------------------------------------------------------------------


If you need more of the backtrace for any of these deprecations to
identify where to make the necessary changes, you can configure
`config.raise_errors_for_deprecations!`, and it will turn the
deprecation warnings into errors, giving you the full backtrace.

2 deprecation warnings total

Finished in 0.01941 seconds
1 example, 1 failure

Failed examples:

rspec ./spec/features/todo_lists/create_spec.rb:4 # Creating todo lists redirects to the todo list index page on success

Randomized with seed 22593

How do you setup the route file?