What is the best way to test JavaScript views (test to see if a page works JavaScript wise) in Rails?
So lets say I have a page called /users/new
that contains a form that does something. I would like to have it so that I submit the form and the JavaScript testing tool will let me know if that page breaks or not. What is the best way to do this?
I have come across three options for testing:
Konacha (best tool so far for JS BDD) http://www.solitr.com/blog/2012/04/konacha-tutorial-javascript-testing-with-rails/
JasmineRice (Jasmine + Rails + Guard) https://github.com/bradphelan/jasminerice/
Capybara Webkit. https://github.com/thoughtbot/capybara-webkit
The first two are basically there for BDD and isolated testing. The last one is more for what I'm looking for, but I don't want to have a separate testing setup for JavaScript BDD and integration testing.
Does anyone have a better solution?
If you are using RSpec, you can use Capybara in an RSpec integration test:
spec/requests/my_spec.rb:
describe "my test", :js => true do
it "should do something" do
visit '/some/path'
click_on 'Submit'
page.should have_content 'Congratulations!'
end
end
Remember to set Capybara.javascript_driver = :webkit
in spec_helper.rb
.