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 Validating Length

Tomasz Jaśkiewicz
Tomasz Jaśkiewicz
5,399 Points

I get some deprecation warnings during testing. How can I fix that?

I got this warning:

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/tomasz/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-2.1.0/lib/capybara/rspec.rb:20:in `block (2 levels) in <top (required)>')
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

My question is how can I fix that?

My example test looks like that:

    it "displays an error when todo list have no description" do
        expect(TodoList.count).to eq(0)

        visit "/todo_lists"
        click_link "New Todo list"
        expect(page).to have_content("New todo_list")

        fill_in "Title", with: "Grocery list"
        fill_in "Description", with: ""
        click_button "Create Todo list"

        expect(page).to have_content("error")
        expect(TodoList.count).to eq(0)

        visit "/todo_lists"
        expect(page).to_not have_content("Grocery list")
    end

2 Answers

Here's another forum post from 4 months ago that may be useful to you: https://teamtreehouse.com/forum/how-do-i-removed-these-depreciation-warnings

Sorry I don't know more about the issue.

Tomasz Jaśkiewicz
Tomasz Jaśkiewicz
5,399 Points

Thanks, I couldn't find that topic before but the solution works perfectly fine!