capybara-typhoeus 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d47a174ccfacb40f34d85580cc59edeb5504498
4
- data.tar.gz: 4c68438940a7ced8999b840e73a31badc8bc8ce3
3
+ metadata.gz: 976fa14fb8f2e89fafd33627cccad6fc6eb5e608
4
+ data.tar.gz: 8bdfbdad63eb49903137ededceda11a0601033c8
5
5
  SHA512:
6
- metadata.gz: 0ba0d5e3e65479ef80b00bde6be3ee9cd1c6330352412f723e708fd248b961a14cac7db6dd05e848d165161752cdd469ac2ebd3a972f53271318671a0d9587c4
7
- data.tar.gz: fb8a7ab2d5cd59c3454ebf3abb13b09140c3d6ea65e37ca3445c2ffb0b2adfce6df123e99a3137b0f74fdfd0224570c9fdf86057bd2bb1f6631dba5cb9cd57cc
6
+ metadata.gz: 01eebe64bf5ba365d3839e54f8ff6128dd3d67fc9079cc41cbc04e9d067493a84cbad75cf1334149d509ac036e3ca26b107f042eeb788cefb4bb23af47047ded
7
+ data.tar.gz: 95dd04c59b0c133f4de0c64690ba8045d9fe553019747e06b24b2626c2e110640b56a1058ba57947f0b5d33e7c80efe617219c5d4c302b678fcceaecf49d76bc
@@ -4,21 +4,7 @@ class Capybara::Typhoeus::Session < Capybara::Session
4
4
  define_method(method) do |url, params={}, headers={}, &block|
5
5
  @touched = true
6
6
 
7
- if url !~ /^http/ and Capybara.app_host
8
- url = Capybara.app_host + url.to_s
9
- end
10
-
11
- if @server
12
- url = "http://#{@server.host}:#{@server.port}" + url.to_s unless url =~ /^http/
13
-
14
- if Capybara.always_include_port
15
- uri = URI.parse url
16
- uri.port = @server.port if uri.port == uri.default_port
17
- url = uri.to_s
18
- end
19
- end
20
-
21
- driver.send method, url, params, headers, &block
7
+ driver.send method, host_url(url), params, headers, &block
22
8
  end
23
9
  end
24
10
 
@@ -30,4 +16,22 @@ class Capybara::Typhoeus::Session < Capybara::Session
30
16
  driver.timed_out?
31
17
  end
32
18
 
19
+ def host_url(url)
20
+ if url !~ /^http/ and Capybara.app_host
21
+ url = Capybara.app_host + url.to_s
22
+ end
23
+
24
+ if @server
25
+ url = "http://#{@server.host}:#{@server.port}" + url.to_s unless url =~ /^http/
26
+
27
+ if Capybara.always_include_port
28
+ uri = URI.parse url
29
+ uri.port = @server.port if uri.port == uri.default_port
30
+ url = uri.to_s
31
+ end
32
+ end
33
+
34
+ url
35
+ end
36
+
33
37
  end
@@ -68,5 +68,21 @@ describe Capybara::Typhoeus::Session do
68
68
  end
69
69
  end
70
70
  end
71
+
72
+ context "#host_url returns url with scheme, host, port and path" do
73
+ subject{ described_class.new :typhoeus, TestApp }
74
+
75
+ it "with empty url" do
76
+ subject.host_url("").should =~ /\A#{Regexp.escape("http://127.0.0.1")}:\d+\z/
77
+ end
78
+
79
+ it "with relative url" do
80
+ subject.host_url("/demo/test").should =~ /\A#{Regexp.escape("http://127.0.0.1")}:\d+\/demo\/test\z/
81
+ end
82
+
83
+ it "with absolute url" do
84
+ subject.host_url("http://www.example.com:443/demo/test").should == "http://www.example.com:443/demo/test"
85
+ end
86
+ end
71
87
  end
72
88
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-typhoeus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph HALTER