Ruby on Rails
Thursday, December 10, 2015
I am using capybara minitest on windows using selenium driver .. webkit driver would require me to install QT so I am avoiding that
I am trying to simulate things like http error on an ajax request. I have this test in my feature as shown below.
I have a library that I include in my real controller, I then monkey patch that in my test to throw a 500 error. This seems to work,
but if I run "rake test:features" the tests all do not run because the monkey patch effects the other tests it seems. I am not sure there is a better approach ?
otherwise my tests have to be run individually somehow
the call: all('.submit-btn').first.click causes the controller submit_req action ..
============================================
require "test_helper"
Capybara.default_max_wait_time = 18
require "main_controller_lib"
# Monkey Patch here:
module MainControllerLib
def submit_req
puts "in submit stub"
render :text => "http error", :status => 500
end
end
feature "Will handle ajax errors" do
scenario "ajax http error on main page", js: true do
visit "/main/index"
all('.submit-btn').first.click
page.must_have_css(".fa-exclamation-circle")
el = page.find('.fa-exclamation-circle')[:tooltip]
assert_equal el, "Error on Submit:http error"
end
end
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3c548676-2075-4401-9bcd-c45a6ac3b4be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment