I'm building tests for a user sign-up page. I'm about to add Recaptcha to the page, and I don't know how to account for it in rspec. Specifically, I want my integration test to verify that a user can fill out the page, click on the button, and will be signed up. But with Recaptcha on the page, how do I get Rspec to simulate entering a valid Recaptcha string?
This works for me:
context 'User login with captcha' do
it 'should login with correct recaptcha' do
LoginController.any_instance.expects(:verify_recaptcha).returns(true)
user = with_user # get your user...
post :login, { :username => user.username, :password => user.password }
session[:user].should eql(user.id)
response.should redirect_to(root_path)
end
end
Recaptcha by default does not verify the captcha in the test environments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With