I'm using RSpec/Capybara for Rails app testing and I need to check that one element in the view appears once and only once.
For example, in the following code, i need to make sure that task.title
will appear only once in the page. As shown, I can check if it exists or not, but I could not find how to check that it appears only once.
task = FactoryGirl.create(:task)
login_as(task.user, :scope => :user)
visit tasks_index_url
expect(page).to have_content task.title