Last active
September 15, 2016 08:48
-
-
Save JoeStanton/37f6384e7bc92d24254c to your computer and use it in GitHub Desktop.
React onChange event not firing under Poltergeist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source "https://rubygems.org" | |
gem 'rspec' | |
gem 'capybara' | |
gem 'poltergeist' | |
gem 'selenium-webdriver' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<title>React.js</title> | |
<head> | |
</head> | |
<body> | |
<div id="form"></div> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/es5-shim/4.0.0/es5-shim.js"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/es5-shim/4.0.0/es5-sham.js"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/react/0.11.0/react-with-addons.js"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/react/0.11.0/JSXTransformer.js"></script> | |
<script type="text/jsx"> | |
/** @jsx React.DOM */ | |
var Form = React.createClass({ | |
getInitialState: function() { | |
return {select: false, text: false } | |
}, | |
onChanged: function() { this.setState({select: true}) }, | |
onTextChanged: function() { this.setState({text: true}) }, | |
render: function() { | |
return ( | |
<div> | |
<h1>Form</h1> | |
<select id="select" onChange={this.onChanged}> | |
<option value="">Please Select</option> | |
<option value="A">A</option> | |
</select> | |
{this.state.select ? "Select changed" : ""} | |
<input id="text" onChange={this.onTextChanged}/> | |
{this.state.text ? "Text changed" : ""} | |
</div> | |
); | |
} | |
}); | |
React.renderComponent(new Form(), document.getElementById('form')); | |
</script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Failures: | |
1) App should work | |
Failure/Error: expect(page).to have_content 'Select changed' | |
expected to find text "Select changed" in "Form Text changed" | |
# ./test.rb:17:in `block (2 levels) in <top (required)>' | |
Finished in 6.94 seconds (files took 0.4138 seconds to load) | |
1 example, 1 failure | |
Failed examples: | |
rspec ./test.rb:10 # App should work |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'capybara/rspec' | |
require 'capybara/poltergeist' | |
Capybara.current_driver = :poltergeist # :selenium works fine | |
Capybara.server_port = 3000 | |
Capybara.app_host = 'http://127.0.0.1:3000' | |
Capybara.default_wait_time = 5 | |
describe 'App', type: :feature do | |
it 'should work' do | |
visit '/' | |
fill_in "text", with: "stuff" | |
expect(page).to have_content 'Text changed' | |
select "A", from: "select" | |
expect(page).to have_content 'Select changed' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment