Navigation Menu

Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
create specs to define current_url/pushState behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
marcisme authored and halogenandtoast committed Feb 17, 2012
1 parent 9eb8e55 commit 5eacd08
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions spec/driver_spec.rb
Expand Up @@ -132,6 +132,20 @@
subject.find("//input").first.click
subject.find("//p").first.text.should == ""
end

it "returns the current URL when changed by pushState after a redirect" do
subject.visit("/redirect-me")
port = subject.instance_variable_get("@rack_server").port
subject.execute_script("window.history.pushState({}, '', '/pushed-after-redirect')")
subject.current_url.should == "http://127.0.0.1:#{port}/pushed-after-redirect"
end

it "returns the current URL when changed by replaceState after a redirect" do
subject.visit("/redirect-me")
port = subject.instance_variable_get("@rack_server").port
subject.execute_script("window.history.replaceState({}, '', '/replaced-after-redirect')")
subject.current_url.should == "http://127.0.0.1:#{port}/replaced-after-redirect"
end
end

context "css app" do
Expand Down Expand Up @@ -223,6 +237,18 @@
subject.current_url.should == "http://127.0.0.1:#{port}/hello/world?success=true"
end

it "returns the current URL when changed by pushState" do
port = subject.instance_variable_get("@rack_server").port
subject.execute_script("window.history.pushState({}, '', '/pushed')")
subject.current_url.should == "http://127.0.0.1:#{port}/pushed"
end

it "returns the current URL when changed by replaceState" do
port = subject.instance_variable_get("@rack_server").port
subject.execute_script("window.history.replaceState({}, '', '/replaced')")
subject.current_url.should == "http://127.0.0.1:#{port}/replaced"
end

it "does not double-encode URLs" do
subject.visit("/hello/world?success=%25true")
subject.current_url.should =~ /success=\%25true/
Expand Down

0 comments on commit 5eacd08

Please sign in to comment.