I'm working on a Rails 4 app and i want to write some tests for BrainTree:
using rspec-rails (2.14.0) and capybara (2.1.0) in Rails 4.0.0
The problem is with on the route, in the form for Braintree i pass a :url
<%= form_for :customer, :url => Braintree::TransparentRedirect.url do |f| %>
Now when i run a feature test like this one:
it 'should make new payment info' do
login
visit new_customer_path
page.fill_in 'customer_credit_card_number', :with => '4111111111111111'
page.fill_in 'customer_credit_card_expiration_date', :with => '01/25'
page.fill_in 'customer_credit_card_cvv', :with => '400'
page.click_button 'Save Payment Info'
page.should have_content('Payment Info Confirmation')
page.should have_content('411111******1111')
end
i get a error on the route:
Failure/Error: page.click_button 'Save Payment Info'
ActionController::RoutingError:
No route matches [POST] "/merchants/fvn6vfc5ptyg2xrp/transparent_redirect_requests"
I've also tried this in a controller test (with render_views):
it 'should make new payment info' do
sign_in_as_user
visit new_customer_path
page.fill_in 'customer_credit_card_number', :with => '4111111111111111'
page.fill_in 'customer_credit_card_expiration_date', :with => '01/25'
page.fill_in 'customer_credit_card_cvv', :with => '400'
page.click_button 'Save Payment Info'
save_and_open_page
page.should have_content('Payment Info Confirmation')
page.should have_content('411111******1111')
end
Same error on the route...
In development env in the browser it works fine, i looks like the :url option in my form gets ignored by capybara? I wonder if anybody can help me with this?
I've also found these examples apps for Braintree with Rails: https://github.com/braintree/braintree_ruby_examples/blob/master/rails3_tr_devise/spec/controllers/customer_controller_spec.rb when i run the tests on that project it works.. maybe my problem has to do with the version of Rails and rspec?
many thanks in advance!!