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 User Authentication with Rails Adding User Support to Our Application Fixing Our Tests

Nelly Nelly
Nelly Nelly
7,134 Points

destroy_spec.rb still failing

Sorry me again... There must be something tiny somewhere that I can't find.... my repo is here: https://github.com/knopfler81/odot/tree/user_auth

edit_spec.rb create_spec.rbindex_spec.rbare working good....

but destroy_spec.rb is driving me crazy... What the hell is wrong ?

 rspec spec/features/todo_lists/destroy_spec.rb

Deleting todo lists
  is successful when clicking the destroy link (FAILED - 1)

Failures:

  1) Deleting todo lists is successful when clicking the destroy link
     Failure/Error: expect(TodoList.count).to eq(0)

       expected: 0
            got: 1

       (compared using ==)
     # ./spec/features/todo_lists/destroy_spec.rb:20:in `block (2 levels) in <top (required)>'

Finished in 0.83766 seconds (files took 1.53 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/features/todo_lists/destroy_spec.rb:13 # Deleting todo lists is successful when clicking the destroy link

here is the destroy_spec.rb

require 'rails_helper'
require 'rspec/active_model/mocks'
require 'database_cleaner'

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

  before do
    sign_in user, password: "treehouse1"
  end

  it "is successful when clicking the destroy link" do
    visit "/todo_lists"

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

Thanks if you can help ! maybe Steve Hunter again ? :smile:

cheers

ps: I've tried to go further in the lesson, but EVERYTHING fails now....

5 Answers

Hi Nelly,

What's in your todo_lists_controller? There should be a destroy action in there?

Steve.

Nelly Nelly
Nelly Nelly
7,134 Points

there is:

def destroy
    @todo_list.destroy
    respond_to do |format|
      format.html { redirect_to todo_lists_url, notice: 'Todo list was successfully destroyed.' }
      format.json { head :no_content }
    end
  end
Nelly Nelly
Nelly Nelly
7,134 Points

I think I have an older problem, I've noticed that I had failure on my master brach... i though I had fixed that... awww :( so there is something wrong that is pretty old

Whoopsie!

I don't know if I can pull the project - I'll give it a go. I'll 'follow' you on Github too ...

Nelly Nelly
Nelly Nelly
7,134 Points

I will add you on the project :)

I get some pretty spectacular failures!

104 examples, 30 failures and 3 pending.

I think I need to start again, though. I'm not happy that the git branches pulled across properly. I'll have another go later.

error

Nelly Nelly
Nelly Nelly
7,134 Points

That's what I have too :( is it easier if I find you on skype?

Yeah - message me ... I'm big.dog.consultants. Just back from a run - need a shower and some food. Back soon!

Nelly Nelly
Nelly Nelly
7,134 Points

Steve Hunter I've sent you a message thanks :)