Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: thoughtbot/capybara-webkit
...
head fork: jemmyw/capybara-webkit
compare: master
Checking mergeability… Don't worry, you can still create the pull request.
  • 1 commit
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 23 additions and 0 deletions.
  1. +19 −0 spec/driver_spec.rb
  2. +4 −0 src/capybara.js
View
19 spec/driver_spec.rb
@@ -453,7 +453,17 @@
<div id="change">Change me</div>
<div id="mouseup">Push me</div>
<div id="mousedown">Release me</div>
+ <form action="/" method="GET">
+ <select id="change_select" name="change_select">
+ <option value="1" id="option-1" selected="selected">one</option>
+ <option value="2" id="option-2">two</option>
+ </select>
+ </form>
<script type="text/javascript">
+ document.getElementById("change_select").
+ addEventListener("change", function () {
+ this.className = "triggered";
+ });
document.getElementById("change").
addEventListener("change", function () {
this.className = "triggered";
@@ -491,6 +501,15 @@
subject.find("//*[@class='triggered']").should_not be_empty
end
+ it "fires a change on select" do
+ select = subject.find("//select").first
+ select.value.should == "1"
+ option = subject.find("//option[@id='option-2']").first
+ option.select_option
+ select.value.should == "2"
+ subject.find("//select[@class='triggered']").should_not be_empty
+ end
+
it "fires drag events" do
draggable = subject.find("//*[@id='mousedown']").first
container = subject.find("//*[@id='mouseup']").first
View
4 src/capybara.js
@@ -87,11 +87,15 @@ Capybara = {
},
selectOption: function(index) {
+ this.nodes[index].selected = true;
this.nodes[index].setAttribute("selected", "selected");
+ this.trigger(index, "change");
},
unselectOption: function(index) {
+ this.nodes[index].selected = false;
this.nodes[index].removeAttribute("selected");
+ this.trigger(index, "change");
}
};

No commit comments for this range

Something went wrong with that request. Please try again.