This is a companion discussion topic for the original entry at https://thoughtbot.com/upcase/videos/marking-todos-incomplete
Hi, so in the Todo unit test, in the repeated line:
expect(todo).not_to be_completed
What exactly does the ābe_completedā derive from? Seems a little cryptic.
RSpec provides dynamic predicate matchers. Itās roughly equivalent to writing:
expect(todo.completed?).to eq(false)
Itās definitely one of the more confusing aspects of RSpec.
@joshuaclayton Iām a little bit uncomfortable with using POST and DELETE to mark todos as completed and incompleted respectively mainly because the POST verb was not meant to be idempotent and it ends up being, in this approach. On the other way, I like how all controllers has just one responsability, even the completion controller. Is this one of that cases where we are consciously breaking a rule in favor of a better overall solution?
I am getting:
User marks todo incomplete successfully
Failure/Error: click_on āMark completeā
Capybara::Ambiguous:
Ambiguous match, found 2 elements matching link or button āMark completeā
Database_cleaner appears to not be running properly between feature tests, and I am getting two LIās due to user_completes_todo then the later user_marks_todo_incomplete
I confirmed this is the case, by removing the user_completes_todo_spec and the user_creates_todo_spec which runs before the user_marks_todo_incomplete, in that case the spec does not find multiple todo LIās.
I am on rails 4.2 and also using postgres.
Changing my support/database_cleaner.rb file to this fixed the issue:
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do |example|
DatabaseCleaner.strategy = example.metadata[:js] ? :truncation : :transaction
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end
Thanks! Was running into the same bump today.
Thanks for the solution! I was facing the same issue.
Thank you⦠I had the same issue and your code solved it!