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


Problem with 'rspec' test using Ruby On Rails.

Hey guys!

So I am currently following along with the Ruby On Rails 'Todo List' app course and I am having a lot of fun with it! Everything has worked pretty well so far and I have managed to get everything installed with no problem.

However, after writing the test to see whether todo lists can be created I have encountered an issue. For some reason instead of just getting one example I get one example and one failure.

Do you guys know why this might be happening?

Below is the code for the test file that I written out!

require 'spec_helper'

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

And below this is the console output which I get when I run the command to start the test!

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.24671 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 18050

Thank you in advance to anyone who manages to help me out with this issue!


Milo Winningham
Milo Winningham
Web Development Techdegree Student 3,317 Points

Can you post any more of the console output? The actual failure message should appear before the warnings and summary that you posted.

I had exactly the same issue, and got no answers. I'll be following this question and bumping it now and again to figure it out.

2 Answers

Try changing your test to the following:

it "redirects to the todo list index page on success" do
    expect(page).to have_content("My todo list")

Hey guys!

I also found this information from just above the error message that I posted before! From what I can gather Rspec has been updated and now it has some syntax differences and etc.

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