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

Brian Patterson
Brian Patterson
19,588 Points

Getting example and 1 failure

This is what I have written in the create_spec.rb file.

equire 'spec_helper'

describe "Creating todo lists" 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 am doing today."
        click_button "Create Todo list"

        expect(page).to have_content("My todo list")

        end

end

The failure I am getting is: 2 deprecation warnings total

Finished in 0.01959 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 38375

4 Answers

Ferdinand Pretorius
Ferdinand Pretorius
18,705 Points

Hi Brian,

The error message would suggest that the route you are trying to GET ( visit ) is wrong. The error also tells you that this happens on line 5 of your create_spec.rb file located at ./spec/features/todo_lists/create_spec.rb. Looking at the line:

visit "/todo_list"

Everything seems to look okay with the code, which would suggest that maybe in the string there is a spelling error. Low and behold there we have it, it should be:

visit "/todo_lists"

Notice the 's' at the end of "/todo_lists". That is the proper route!

I didn't mean to be patronizing, the idea was to give you some insight on how to read a stack trace and go about solving the errors.

I hope this helps!

Brian Patterson
Brian Patterson
19,588 Points

Great ! Will try this later .

Brian Patterson
Brian Patterson
19,588 Points

Now I am getting this error

1) Creating todo lists redirects to the todo list index page on success
     Failure/Error: expect(page).to have_content("New Todo List")
       expected to find text "New Todo List" in "New todo_list Title Description Back"
     # ./spec/features/todo_lists/create_spec.rb:7: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.3858 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 22973

This course is really frustrating !!!!!!!!!!

Ferdinand Pretorius
Ferdinand Pretorius
18,705 Points

Hi Brian,

You are expecting your page to have the content of "New Todo List"

expect(page).to have_content("New Todo List")

But when you look at the page at /todo_lists , you will notice that the page actually has the content of New Todo list ( notice that the "l" in list is lowercase ).

Therefore, you should:

expect(page).to have_content("New Todo list")

Pay attention to the small details, and try and learn some troubleshooting methods. I don't think this is the best course for absolute beginners, I would recommend you google "rails for zombies".

Rails is a very fun and rewarding framework and I implore you to hang in there.

Good Luck!

You're missed an 'r' off your require spec_helper statement.

It's probably not that though. It's impossible to know what the problem is without seeing the 'stack trace' - that's the bunch of errors it prints out when it fails - it should say somewhere in there what line the problem is and probably some more information that will be useful. Need to see that because there's nothing wrong with the syntax of that test, at least (except for the missing 'r').

Brian Patterson
Brian Patterson
19,588 Points

Will post the whole error message later.

Brian Patterson
Brian Patterson
19,588 Points

Thanks for the reply Ferdinand . I am going to stick with this course and maybe move on to your recommendation. The thing about these courses, correct me if I am wrong, they offer a template of how to do a particular app. How would you be able to add your own interpretation of an app? Maybe this is something I will learn later.

Ferdinand Pretorius
Ferdinand Pretorius
18,705 Points
The short answer here is,
Yes and No.

Yes because:

Rails have a very strict way of writing apps. This is great because, with some rails knowledge you can easily jump into someone else's project and quickly get a feel for what is going on. For the same reason you can easily troubleshoot your apps with the "google the error message" methodology.

No because:

You get to choose the tools you want to use, therefore you still get to put your own "flavour" in your apps. You don't need to write in a test driven environment ( as is the case with this course ), however it is still highly recommended.

So you are right in thinking that they provide you with a template of how to do a particular app, but that doesn't mean that there isn't a different way to do it.

If you want to feel like you are doing something completely different, I would suggest going with Node and Express. This is very hot topics at the moment! Once you get a general understanding of those, you can throw in a bit of Angular in the mix as well, or even React( which we prefer at Edited ).

Just keep experimenting!