mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
update specs to be more condensed
This commit is contained in:
parent
c6103e75c1
commit
399a8fbfb9
1 changed files with 44 additions and 59 deletions
|
@ -1436,6 +1436,21 @@ describe Capybara::Driver::Webkit do
|
||||||
body
|
body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def charCode_for(character)
|
||||||
|
subject.find("//input")[0].set(character)
|
||||||
|
subject.find("//div[@id='charcode_value']")[0].text
|
||||||
|
end
|
||||||
|
|
||||||
|
def keyCode_for(character)
|
||||||
|
subject.find("//input")[0].set(character)
|
||||||
|
subject.find("//div[@id='keycode_value']")[0].text
|
||||||
|
end
|
||||||
|
|
||||||
|
def which_for(character)
|
||||||
|
subject.find("//input")[0].set(character)
|
||||||
|
subject.find("//div[@id='which_value']")[0].text
|
||||||
|
end
|
||||||
|
|
||||||
context "keypress app" do
|
context "keypress app" do
|
||||||
before(:all) do
|
before(:all) do
|
||||||
@app = lambda do |env|
|
@app = lambda do |env|
|
||||||
|
@ -1445,26 +1460,39 @@ describe Capybara::Driver::Webkit do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the charCode for the keypressed" do
|
it "returns the charCode for the keypressed" do
|
||||||
subject.find("//input")[0].set("a")
|
charCode_for("a").should == "97"
|
||||||
subject.find("//div[@id='charcode_value']")[0].text.should == "97"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the keyCode for the keypressed" do
|
it "returns the keyCode for the keypressed" do
|
||||||
subject.find("//input")[0].set("a")
|
keyCode_for("a").should == "97"
|
||||||
subject.find("//div[@id='keycode_value']")[0].text.should == "97"
|
keyCode_for("A").should == "65"
|
||||||
subject.find("//input")[0].set("A")
|
keyCode_for("\r").should == "13"
|
||||||
subject.find("//div[@id='keycode_value']")[0].text.should == "65"
|
|
||||||
subject.find("//input")[0].set("\r")
|
|
||||||
subject.find("//div[@id='keycode_value']")[0].text.should == "13"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the which for the keypressed" do
|
it "returns the which for the keypressed" do
|
||||||
subject.find("//input")[0].set("a")
|
which_for("a").should == "97"
|
||||||
subject.find("//div[@id='which_value']")[0].text.should == "97"
|
which_for("A").should == "65"
|
||||||
subject.find("//input")[0].set("A")
|
which_for("\r").should == "13"
|
||||||
subject.find("//div[@id='which_value']")[0].text.should == "65"
|
end
|
||||||
subject.find("//input")[0].set("\r")
|
end
|
||||||
subject.find("//div[@id='which_value']")[0].text.should == "13"
|
|
||||||
|
shared_examples "a keyupdown app" do
|
||||||
|
it "returns a 0 charCode for the event" do
|
||||||
|
charCode_for("a").should == "0"
|
||||||
|
charCode_for("A").should == "0"
|
||||||
|
charCode_for("\r").should == "0"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns the keyCode for the event" do
|
||||||
|
keyCode_for("a").should == "65"
|
||||||
|
keyCode_for("A").should == "65"
|
||||||
|
keyCode_for("\r").should == "13"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns the which for the event" do
|
||||||
|
which_for("a").should == "65"
|
||||||
|
which_for("A").should == "65"
|
||||||
|
which_for("\r").should == "13"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1475,29 +1503,7 @@ describe Capybara::Driver::Webkit do
|
||||||
[200, { 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s }, [body]]
|
[200, { 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s }, [body]]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
it_behaves_like "a keyupdown app"
|
||||||
it "returns 0 charCode for the keyup" do
|
|
||||||
subject.find("//input")[0].set("a")
|
|
||||||
subject.find("//div[@id='charcode_value']")[0].text.should == "0"
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns the keyCode for the keyup" do
|
|
||||||
subject.find("//input")[0].set("a")
|
|
||||||
subject.find("//div[@id='keycode_value']")[0].text.should == "65"
|
|
||||||
subject.find("//input")[0].set("A")
|
|
||||||
subject.find("//div[@id='keycode_value']")[0].text.should == "65"
|
|
||||||
subject.find("//input")[0].set("\r")
|
|
||||||
subject.find("//div[@id='keycode_value']")[0].text.should == "13"
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns the which for the keyup" do
|
|
||||||
subject.find("//input")[0].set("a")
|
|
||||||
subject.find("//div[@id='which_value']")[0].text.should == "65"
|
|
||||||
subject.find("//input")[0].set("A")
|
|
||||||
subject.find("//div[@id='which_value']")[0].text.should == "65"
|
|
||||||
subject.find("//input")[0].set("\r")
|
|
||||||
subject.find("//div[@id='which_value']")[0].text.should == "13"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "keyup app" do
|
context "keyup app" do
|
||||||
|
@ -1508,27 +1514,6 @@ describe Capybara::Driver::Webkit do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns 0 charCode for the keyup" do
|
it_behaves_like "a keyupdown app"
|
||||||
subject.find("//input")[0].set("a")
|
|
||||||
subject.find("//div[@id='charcode_value']")[0].text.should == "0"
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns the keyCode for the keyup" do
|
|
||||||
subject.find("//input")[0].set("a")
|
|
||||||
subject.find("//div[@id='keycode_value']")[0].text.should == "65"
|
|
||||||
subject.find("//input")[0].set("A")
|
|
||||||
subject.find("//div[@id='keycode_value']")[0].text.should == "65"
|
|
||||||
subject.find("//input")[0].set("\r")
|
|
||||||
subject.find("//div[@id='keycode_value']")[0].text.should == "13"
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns the which for the keyup" do
|
|
||||||
subject.find("//input")[0].set("a")
|
|
||||||
subject.find("//div[@id='which_value']")[0].text.should == "65"
|
|
||||||
subject.find("//input")[0].set("A")
|
|
||||||
subject.find("//div[@id='which_value']")[0].text.should == "65"
|
|
||||||
subject.find("//input")[0].set("\r")
|
|
||||||
subject.find("//div[@id='which_value']")[0].text.should == "13"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue