2016-03-07 19:52:19 -05:00
|
|
|
# frozen_string_literal: true
|
2016-10-04 14:10:29 -04:00
|
|
|
Capybara::SpecHelper.spec "#execute_script", requires: [:js] do
|
2012-07-21 16:44:10 -04:00
|
|
|
it "should execute the given script and return nothing" do
|
|
|
|
@session.visit('/with_js')
|
2016-06-12 19:28:47 -04:00
|
|
|
expect(@session.execute_script("document.getElementById('change').textContent = 'Funky Doodle'")).to be_nil
|
2016-10-04 14:10:29 -04:00
|
|
|
expect(@session).to have_css('#change', text: 'Funky Doodle')
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|
2016-06-12 19:28:47 -04:00
|
|
|
|
|
|
|
it "should be able to call functions defined in the page" do
|
|
|
|
@session.visit('/with_js')
|
|
|
|
expect{ @session.execute_script("$('#change').text('Funky Doodle')") }.not_to raise_error
|
|
|
|
end
|
2012-07-21 16:44:10 -04:00
|
|
|
end
|