vendredi 4 décembre 2015

Rails Capybara Feature Tests with assert page.has_content? fails

I am trying to implement some feature test for my rails application using Capybara.

Now I am stucking.

I have an element in my html which looks like this:

<p class="no-stars">
  <strong class="">No stars:</strong>0
</p>

My test looks like this:

  test "should increase the number of stars for a user" do
    Capybara.current_driver = Capybara.javascript_driver
    visit users_path
    click_link('John F. Kennedy')
    assert page.has_content?('No stars: 0'), 'no matching content found!'
    page.find("input[value='+1']").click
    assert page.has_content?('No stars: 1'), 'no matching content found!'
  end

It seems to me that my test fails because it can't find the content 'No stars: 0'.

Does anyone have a solution for that problem?

Aucun commentaire:

Enregistrer un commentaire