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 trialNelly Nelly
7,134 PointsNo error when I run `rake`but still having error when running `rspec spec`
Hello all !
When I run rake
everything is fine ! ( well i don't know why I only have 105 btw instead of 120 on Jason's video)
Finished in 1.94 seconds (files took 1.56 seconds to load)
105 examples, 0 failures
If I run rspec spec
I do have errors....
Failures:
1) Deleting todo items is successful
Failure/Error: expect(TodoItem.count).to eq(0)
expected: 0
got: 1
(compared using ==)
# ./spec/features/todo_items/delete_spec.rb:19:in `block (2 levels) in <top (required)>'
2) 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)>'
3) Completing todo items is successful when marking a single item complete
Failure/Error: expect(todo_item.completed_at).to_not be_nil
expected: not nil
got: nil
# ./spec/features/todo_items/complete_spec.rb:19:in `block (2 levels) in <top (required)>'
Finished in 12.73 seconds (files took 1.68 seconds to load)
105 examples, 3 failures
Failed examples:
rspec ./spec/features/todo_items/delete_spec.rb:13 # Deleting todo items is successful
rspec ./spec/features/todo_lists/destroy_spec.rb:13 # Deleting todo lists is successful when clicking the destroy link
rspec ./spec/features/todo_items/complete_spec.rb:12 # Completing todo items is successful when marking a single item complete
Thank for your help ! here's my updated repo https://github.com/knopfler81/odot/tree/user_auth
Steve Hunter maybe ?
3 Answers
Nelly Nelly
7,134 Pointsfound out ! ( dunno how....) but I was missing the first line in the spec_helper.rb
ENV["RAILS_ENV"] ||= 'test'
Steve Hunter
57,712 PointsHi Nelly,
I've pulled your code and have it running here. I get exactly the same as you - and I have no idea why.
Testing the app directly, and the code does work; the link does delete the todo_item. I'll try to figure out what's going on!
Steve.
Nelly Nelly
7,134 PointsSounds weird :(
btw I will continue the lesson ... hopefully it won't break anything
Steve Hunter
57,712 PointsI think this is because you have two databases - I think there's some confusion in the application itself as to which one to use. Using rake
will invoke the development database.
I wonder if some of the tests are leaving artfacts behind. So, when you're testing for a count to equal zero; maybe there's a list or item already there from other tests? So, testing for a decremented value, rather than a specific zero might work? Make sense?
I'll try to find the test for 'being one less' and give that a go.
Nelly Nelly
7,134 Pointsyes ! OMG I am happy ! Merging NOW :D
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsAha! So I was nearly there with my idea - all GREEN here now.