Skip to content

Instantly share code, notes, and snippets.

View jwood's full-sized avatar

John Wood jwood

View GitHub Profile
@jwood
jwood / bad_spec.rb
Last active August 29, 2015 14:17
Fix Flakey Feature Tests by Using Capybara's APIs Properly - 1
first("#foo").click
expect(first(".message").value).to eql("Loaded successfully")
@jwood
jwood / use_find.rb
Last active August 29, 2015 14:17
Fix Flakey Feature Tests by Using Capybara's APIs Properly - 2
find("#foo").click
expect(find(".message").value).to eql("Loaded successfully")
@jwood
jwood / use_matchers.rb
Last active August 29, 2015 14:17
Fix Flakey Feature Tests by Using Capybara's APIs Properly - 3
find("#foo").click
expect(find(".message")).to have_text("Loaded successfully")
@jwood
jwood / use_actions.rb
Last active August 29, 2015 14:17
Fix Flakey Feature Tests by Using Capybara's APIs Properly - 4
click_link("#foo")
expect(find(".message")).to have_text("Loaded successfully")
expect(page.find("#some-text-field").value).to eql("Some value")
expect(page).to have_field("#some-text-field", with: "Some value")
expect(page).to !have_css(".some-class")
expect(page).to have_no_css(".some-class")
expect(page).to_not have_css(".some-class")
@jwood
jwood / css_existence.rb
Last active August 29, 2015 14:22
Testing for existence using CSS
expect(page).to have_css("#blah")