Currently I have two tests that each individually test for a button_click within a form on the same page with no ids but both have the same text Go. So what is happens is capybara/rspec only tests the first instance of the Go button for both tests. Is there a way to find something based on the parents? I don’t want to have to modify my functional code by adding an id just for the sole purpose of testing. I was thinking of something like test_form > input[type='submit'] but that doesn’t work.
Current code:
let(:submit) {"Go"}
describe "with valid information" do
before do
fill_in "email", with: "stuff@example.com"
fill_in "password", with: "stuff"
end
it "should create a user" do
expect {click_button submit}.to change(User, :count).by(1)
end
end
Current Gems:
rails 3.2.6
rspec-rails 2.10.1
capybara 1.1.2
You can specify within which selector you want your button, see doc