frameworks-capybara 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGES +3 -0
- data/Gemfile.lock +1 -1
- data/lib/frameworks/capybara.rb +18 -12
- data/lib/version.rb +1 -1
- data/spec/frameworks_capybara_spec.rb +45 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmVhYjExYzE4MTljZTI0NDdlOGI2MDkxOTU2ZmRjM2U2OWVjNGRjZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
N2QxY2MzMDI4NGEwZWIwYmI5MDU4ODQ5YzhmMzVlZmM4M2I1MGI0Ng==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTFhNjliOTY5Y2YwMzYwNjRiMDhlMWRmODc2ZmY4ZDE5YzcwNzlmYzYyYzJl
|
10
|
+
MjU5ZTkyYmNhNjM3NTY2OTZiMGMzMTBlNGZhNzJkMDQzNjUyNmYwOWU4YWIy
|
11
|
+
OTJkZGYyZjFiZGNkODNkZWY4YzIwYTk4Zjk5MGY2NTZlZDBiZTU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTM1MmJmYjBmY2UxYWIzY2IzMmYyYTk3ZTIzZGFlZDgxYTExMzA5YTJiNGE5
|
14
|
+
OTc5MDNkZTNlYjRiNTAzODg1YWJlNzdkZDlkNDg4OTQ0MmNlZWVmN2I3OWE3
|
15
|
+
ZGZjYzdmN2IzMjc3YzgxYzQwYzdhZmU0N2ExMTFhOTYzMDU3MTU=
|
data/CHANGES
CHANGED
data/Gemfile.lock
CHANGED
data/lib/frameworks/capybara.rb
CHANGED
@@ -18,11 +18,11 @@ class CapybaraSetup
|
|
18
18
|
http_proxy = ENV['HTTP_PROXY'] || ENV['http_proxy']
|
19
19
|
|
20
20
|
capybara_opts = {:environment => ENV['ENVIRONMENT'],
|
21
|
-
:
|
21
|
+
:http_proxy => http_proxy,
|
22
22
|
:profile => ENV['FIREFOX_PROFILE'],
|
23
23
|
:browser => ENV['BROWSER'],
|
24
24
|
:javascript_enabled => ENV['CELERITY_JS_ENABLED'],
|
25
|
-
:
|
25
|
+
:webdriver_proxy_on => ENV['PROXY_ON'],
|
26
26
|
:url => ENV['REMOTE_URL'],
|
27
27
|
:chrome_switches => ENV['CHROME_SWITCHES'],
|
28
28
|
:firefox_prefs => ENV['FIREFOX_PREFS'],
|
@@ -43,7 +43,11 @@ class CapybaraSetup
|
|
43
43
|
|
44
44
|
validate_env_vars(capybara_opts.merge(selenium_remote_opts)) #validate environment variables set using cucumber.yml or passed via command line
|
45
45
|
|
46
|
-
|
46
|
+
if(capybara_opts[:http_proxy])
|
47
|
+
proxy_uri = URI(capybara_opts[:http_proxy])
|
48
|
+
@proxy_host = proxy_uri.host
|
49
|
+
@proxy_port = proxy_uri.port
|
50
|
+
end
|
47
51
|
capybara_opts[:browser] = capybara_opts[:browser].intern #update :browser value to be a symbol, required for Selenium
|
48
52
|
selenium_remote_opts[:browser_name] = selenium_remote_opts[:browser_name].intern if selenium_remote_opts[:browser_name]#update :browser value to be a symbol, required for Selenium
|
49
53
|
|
@@ -135,7 +139,7 @@ class CapybaraSetup
|
|
135
139
|
opts[:http_client] = client
|
136
140
|
end
|
137
141
|
|
138
|
-
clean_opts(opts, :
|
142
|
+
clean_opts(opts, :http_proxy, :webdriver_proxy_on, :firefox_prefs)
|
139
143
|
Capybara::Selenium::Driver.new(app,opts)
|
140
144
|
end
|
141
145
|
:selenium
|
@@ -147,7 +151,7 @@ class CapybaraSetup
|
|
147
151
|
end
|
148
152
|
|
149
153
|
def set_client_proxy(opts)
|
150
|
-
Selenium::WebDriver::Proxy.new(:http => opts[:
|
154
|
+
Selenium::WebDriver::Proxy.new(:http => opts[:http_proxy]) if opts[:http_proxy] && opts[:webdriver_proxy_on] != 'false' #set proxy on client connection if required, note you may use ENV['HTTP_PROXY'] for setting in browser (ff profile) but not for client conection, hence allow for PROXY_ON=false
|
151
155
|
end
|
152
156
|
|
153
157
|
def create_profile(profile_name = nil, additional_prefs = nil)
|
@@ -157,12 +161,14 @@ class CapybaraSetup
|
|
157
161
|
profile.native_events = true
|
158
162
|
elsif(profile_name == 'BBC_INTERNAL')
|
159
163
|
profile = Selenium::WebDriver::Firefox::Profile.new
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
164
|
+
if(@proxy_host && @proxy_port)
|
165
|
+
profile["network.proxy.type"] = 1
|
166
|
+
profile["network.proxy.no_proxies_on"] = "*.sandbox.dev.bbc.co.uk,*.sandbox.bbc.co.uk"
|
167
|
+
profile["network.proxy.http"] = @proxy_host
|
168
|
+
profile["network.proxy.ssl"] = @proxy_host
|
169
|
+
profile["network.proxy.http_port"] = @proxy_port
|
170
|
+
profile["network.proxy.ssl_port"] = @proxy_port
|
171
|
+
end
|
166
172
|
profile.native_events = true
|
167
173
|
else
|
168
174
|
profile = Selenium::WebDriver::Firefox::Profile.from_name profile_name
|
@@ -182,7 +188,7 @@ class CapybaraSetup
|
|
182
188
|
Capybara.register_driver :celerity do |app|
|
183
189
|
opts.delete :browser #delete browser from options as value with be 'headless'
|
184
190
|
opts[:javascript_enabled] == 'true' ? opts[:javascript_enabled] = true : opts[:javascript_enabled] = false
|
185
|
-
opts[:
|
191
|
+
opts[:http_proxy] = "#{@proxy_host}:80" unless opts[:http_proxy].nil?
|
186
192
|
Capybara::Driver::Celerity.new(app,opts)
|
187
193
|
end
|
188
194
|
:celerity
|
data/lib/version.rb
CHANGED
@@ -20,8 +20,8 @@ shared_examples_for "Selenium Driver Options Array" do
|
|
20
20
|
#TODO: Test for nil elements in options - there shouldn't be any that we insert
|
21
21
|
#i.e. anything in our ENV options should not end up being nil in Selenium
|
22
22
|
Capybara.current_session.driver.options[:environment].should == nil
|
23
|
-
Capybara.current_session.driver.options[:
|
24
|
-
Capybara.current_session.driver.options[:
|
23
|
+
Capybara.current_session.driver.options[:http_proxy].should == nil
|
24
|
+
Capybara.current_session.driver.options[:webdriver_proxy_on].should == nil
|
25
25
|
Capybara.current_session.driver.options[:platform].should == nil
|
26
26
|
Capybara.current_session.driver.options[:browser_name].should == nil
|
27
27
|
Capybara.current_session.driver.options[:version].should == nil
|
@@ -430,7 +430,7 @@ describe CapybaraSetup do
|
|
430
430
|
CapybaraSetup.new.driver.should == :celerity
|
431
431
|
Capybara.current_session.driver.should be_a_kind_of Capybara::Driver::Celerity
|
432
432
|
Capybara.current_session.driver.options[:javascript_enabled].should == true
|
433
|
-
Capybara.current_session.driver.options[:
|
433
|
+
Capybara.current_session.driver.options[:http_proxy].should == 'example.cache.co.uk:80'
|
434
434
|
Capybara.current_session.driver.options[:environment].should == nil
|
435
435
|
Capybara.current_session.driver.options[:browser].should == nil
|
436
436
|
end
|
@@ -445,7 +445,7 @@ describe CapybaraSetup do
|
|
445
445
|
|
446
446
|
it "should cope with http_proxy and HTTP_PROXY " do
|
447
447
|
Capybara.delete_session
|
448
|
-
Capybara.current_session.driver.options[:
|
448
|
+
Capybara.current_session.driver.options[:http_proxy].should == 'example.cache.co.uk:80'
|
449
449
|
end
|
450
450
|
end
|
451
451
|
|
@@ -579,7 +579,47 @@ describe CapybaraSetup do
|
|
579
579
|
|
580
580
|
end
|
581
581
|
|
582
|
-
|
582
|
+
describe "The BBC-INTERNAL firefox profile should be set up with the correct proxy settings whether working behind a proxy or not" do
|
583
|
+
|
584
|
+
context "no proxy settings provided" do
|
585
|
+
before do
|
586
|
+
ENV['BROWSER'] = 'firefox'
|
587
|
+
ENV['ENVIRONMENT'] = 'test'
|
588
|
+
end
|
589
|
+
|
590
|
+
it "should create the firefox profile settings correctly" do
|
591
|
+
setup = CapybaraSetup.new
|
592
|
+
profile = setup.instance_exec('BBC_INTERNAL', nil) { |profile_name, additional_prefs|
|
593
|
+
create_profile(profile_name, additional_prefs)
|
594
|
+
}
|
595
|
+
|
596
|
+
profile.instance_variable_get('@additional_prefs')['network.proxy.type'].should be_nil
|
597
|
+
profile.instance_variable_get('@additional_prefs')['network.proxy.http'].should be_nil
|
598
|
+
profile.instance_variable_get('@additional_prefs')['network.proxy.http_port'].should be_nil
|
599
|
+
end
|
600
|
+
end
|
601
|
+
|
602
|
+
context "proxy settings provided" do
|
603
|
+
before do
|
604
|
+
@proxy_host = 'example.cache.co.uk'
|
605
|
+
@proxy_port = 6789
|
606
|
+
ENV['BROWSER'] = 'firefox'
|
607
|
+
ENV['ENVIRONMENT'] = 'test'
|
608
|
+
ENV['HTTP_PROXY'] = "http://#{@proxy_host}:#{@proxy_port}"
|
609
|
+
end
|
610
|
+
|
611
|
+
it "should create the firefox profile correctly" do
|
612
|
+
setup = CapybaraSetup.new
|
613
|
+
profile = setup.instance_exec('BBC_INTERNAL', nil) { |profile_name, additional_prefs|
|
614
|
+
create_profile(profile_name, additional_prefs)
|
615
|
+
}
|
616
|
+
|
617
|
+
profile.instance_variable_get('@additional_prefs')['network.proxy.type'].should == 1
|
618
|
+
profile.instance_variable_get('@additional_prefs')['network.proxy.http'].should == @proxy_host
|
619
|
+
profile.instance_variable_get('@additional_prefs')['network.proxy.http_port'].should == @proxy_port
|
620
|
+
end
|
621
|
+
end
|
622
|
+
end
|
583
623
|
end
|
584
624
|
end
|
585
625
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frameworks-capybara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- matt robbins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mime-types
|