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 Deleting Todo Lists

John Stoveld
John Stoveld
4,203 Points

Every Capybara test I create seems to keep failing - this has happened since create, edit and now happening in destroy..

So I keep getting this familiar error. I have been following along Jason's videos. To the letter.

(Sorry about the formatting earlier - edited to be easier to read)

Todays Failure

Failures:

  1) Deleting todo lists is successful when cicking destroy link
     Failure/Error: clik_link "Destroy"
     NoMethodError:
       undefined method `clik_link' for #<RSpec::Core::ExampleGroup::Nested_1:0x007faad81f74c8>
     # ./spec/features/todo_lists/destroy_spec.rb:10:in `block (3 levels) in <top (required)>'
     # ./spec/features/todo_lists/destroy_spec.rb:9: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 /Users/JS/.rvm/gems/ruby-2.2.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 /Users/JS/.rvm/gems/ruby-2.2.0/gems/capybara-2.1.0/lib/capybara/rspec.rb:21:in `block (2 levels) in <top (required)>')
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
rspec-rails 3 will no longer automatically infer an example group's spec type
from the file location. You can explicitly opt-in to this feature using this
snippet:

RSpec.configure do |config|
  config.infer_spec_type_from_file_location!
end

If you wish to manually label spec types via metadata you can safely ignore
this warning and continue upgrading to RSpec 3 without addressing it.
--------------------------------------------------------------------------------


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.

3 deprecation warnings total

Finished in 0.05891 seconds
1 example, 1 failure

Failed examples:

rspec ./spec/features/todo_lists/destroy_spec.rb:6 # Deleting todo lists is successful when cicking destroy link

Randomized with seed 43954

JSs-MacBook-Pro:odot JS$ 

So here is my code on the destroy_spec.rb:

require 'spec_helper'

describe "Deleting todo lists" do
  let!(:todo_list) { TodoList.create(title: "Groceries", description: "Grocery list.") }

  it "is successful when cicking destroy link" do 
    visit "/todo_lists"

    within "#todo_list_#{todo_list.id}" do 
        clik_link "Destroy"
    end
    expect(page).to_not have_content(todo_list.title)
    expect(TodoList.count).to eq(0)
  end
end

and here is my index.html.erb

<h1>Listing todo_lists</h1>

<table>
  <thead>
    <tr>
      <th>Title</th>
      <th>Description</th>
      <th></th>
      <th></th>
      <th></th>
    </tr>
  </thead>

  <tbody>
    <% @todo_lists.each do |todo_list| %>
      <tr id="<%= dom_id(todo_list) %>">
        <td><%= todo_list.title %></td>
        <td><%= todo_list.description %></td>
        <td><%= link_to 'Show', todo_list %></td>
        <td><%= link_to 'Edit', edit_todo_list_path(todo_list) %></td>
        <td><%= link_to 'Destroy', todo_list, method: :delete, data: { confirm: 'Are you sure?' } %></td>
      </tr>
    <% end %>
  </tbody>
</table>

<br>

<%= link_to 'New Todo list', new_todo_list_path %>

Can someone tell me what is wrong here that keeps popping up? Nothing more frustrating than being wrong when thinking you have done everything correct.

1 Answer

John Stoveld
John Stoveld
4,203 Points

Alright -

Lesson learned.

When you are frustrated. Go outside. and take a few deep breaths and go back to your code.

I had click misspelled. Which broke my code.

Goes to show. Spelling errors will not help your code.