Skip to content
This repository
Browse code

create specs to define current_url/pushState behavior

  • Loading branch information...
commit 5eacd085dac60fe545542ed0282044141e6680ff 1 parent 9eb8e55
Marc Schwieterman authored February 05, 2012 halogenandtoast committed February 17, 2012

Showing 1 changed file with 26 additions and 0 deletions. Show diff stats Hide diff stats

  1. 26  spec/driver_spec.rb
26  spec/driver_spec.rb
@@ -132,6 +132,20 @@
132 132
       subject.find("//input").first.click
133 133
       subject.find("//p").first.text.should == ""
134 134
     end
  135
+
  136
+    it "returns the current URL when changed by pushState after a redirect" do
  137
+      subject.visit("/redirect-me")
  138
+      port = subject.instance_variable_get("@rack_server").port
  139
+      subject.execute_script("window.history.pushState({}, '', '/pushed-after-redirect')")
  140
+      subject.current_url.should == "http://127.0.0.1:#{port}/pushed-after-redirect"
  141
+    end
  142
+
  143
+    it "returns the current URL when changed by replaceState after a redirect" do
  144
+      subject.visit("/redirect-me")
  145
+      port = subject.instance_variable_get("@rack_server").port
  146
+      subject.execute_script("window.history.replaceState({}, '', '/replaced-after-redirect')")
  147
+      subject.current_url.should == "http://127.0.0.1:#{port}/replaced-after-redirect"
  148
+    end
135 149
   end
136 150
 
137 151
   context "css app" do
@@ -223,6 +237,18 @@
223 237
       subject.current_url.should == "http://127.0.0.1:#{port}/hello/world?success=true"
224 238
     end
225 239
 
  240
+    it "returns the current URL when changed by pushState" do
  241
+      port = subject.instance_variable_get("@rack_server").port
  242
+      subject.execute_script("window.history.pushState({}, '', '/pushed')")
  243
+      subject.current_url.should == "http://127.0.0.1:#{port}/pushed"
  244
+    end
  245
+
  246
+    it "returns the current URL when changed by replaceState" do
  247
+      port = subject.instance_variable_get("@rack_server").port
  248
+      subject.execute_script("window.history.replaceState({}, '', '/replaced')")
  249
+      subject.current_url.should == "http://127.0.0.1:#{port}/replaced"
  250
+    end
  251
+
226 252
     it "does not double-encode URLs" do
227 253
       subject.visit("/hello/world?success=%25true")
228 254
       subject.current_url.should =~ /success=\%25true/

0 notes on commit 5eacd08

Please sign in to comment.
Something went wrong with that request. Please try again.