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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NGQ0MTAwMGMxNjgxNjc0MWZkYjdmNTBiYWJkOWM0N2MwMjRlNWY0Yw==
4
+ NmVhYjExYzE4MTljZTI0NDdlOGI2MDkxOTU2ZmRjM2U2OWVjNGRjZQ==
5
5
  data.tar.gz: !binary |-
6
- ODdmYmQyZWE1NGUxODJmN2ZmZTI3YTNhNjI0NGExYzE0NGY3NWI3ZA==
6
+ N2QxY2MzMDI4NGEwZWIwYmI5MDU4ODQ5YzhmMzVlZmM4M2I1MGI0Ng==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTQxYjczYTljMThkMWVlZGRjNTMyNTJmZjQ2ZmY2NDQwMzhmM2NkNDMyNzg3
10
- YWI2NjAyZmZmMmFjYzU2ZjIwYjk4YjNhNWZhYTBiNWJlNWNmZGU0ZWZlMDlh
11
- MDkzZWRiOGU4NjBmMDQ3ODZkZmQxMTVkNTY5YTQ0ODcwZDUyMTk=
9
+ OTFhNjliOTY5Y2YwMzYwNjRiMDhlMWRmODc2ZmY4ZDE5YzcwNzlmYzYyYzJl
10
+ MjU5ZTkyYmNhNjM3NTY2OTZiMGMzMTBlNGZhNzJkMDQzNjUyNmYwOWU4YWIy
11
+ OTJkZGYyZjFiZGNkODNkZWY4YzIwYTk4Zjk5MGY2NTZlZDBiZTU=
12
12
  data.tar.gz: !binary |-
13
- Mjc1NWU3MzIxY2MzNzI0NzFjMzc5MTkzZmMyNDU4MTg1ZTk1YWRlOTA5ZWFk
14
- Y2NlMThhMmZhMTg0ODE2YWMzYzQ4NWQyNmViYTdmMzkyZmQ2N2U1NDJjMDI2
15
- OWUyYjU0ZDMyOGYyNDEyNmJiMmZkYjJkNjBjZjAxN2FmZmI2NTk=
13
+ YTM1MmJmYjBmY2UxYWIzY2IzMmYyYTk3ZTIzZGFlZDgxYTExMzA5YTJiNGE5
14
+ OTc5MDNkZTNlYjRiNTAzODg1YWJlNzdkZDlkNDg4OTQ0MmNlZWVmN2I3OWE3
15
+ ZGZjYzdmN2IzMjc3YzgxYzQwYzdhZmU0N2ExMTFhOTYzMDU3MTU=
data/CHANGES CHANGED
@@ -1,3 +1,6 @@
1
+ 1.1.0
2
+ BBC_INTERNAL firefox profile creation now works correctly whether working behind a firewall or not.
3
+
1
4
  1.0.0
2
5
  Base required Ruby version now 1.9.3 or later
3
6
  Bumped gem dependency versions
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- frameworks-capybara (1.0.0)
4
+ frameworks-capybara (1.1.0)
5
5
  capybara (~> 1.1.2)
6
6
  capybara-celerity
7
7
  capybara-mechanize (>= 0.3.0, < 1.0.0)
@@ -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
- :proxy => http_proxy,
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
- :proxy_on => ENV['PROXY_ON'],
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
- @proxy_host = capybara_opts[:proxy].gsub(/http:\/\//,'').gsub(/:80.*/,'') unless capybara_opts[:proxy].nil?
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, :proxy, :proxy_on, :firefox_prefs)
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[:proxy]) if opts[:proxy] && opts[: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
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
- profile["network.proxy.type"] = 1
161
- profile["network.proxy.no_proxies_on"] = "*.sandbox.dev.bbc.co.uk,*.sandbox.bbc.co.uk"
162
- profile["network.proxy.http"] = @proxy_host
163
- profile["network.proxy.ssl"] = @proxy_host
164
- profile["network.proxy.http_port"] = 80
165
- profile["network.proxy.ssl_port"] = 80
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[:proxy] = "#{@proxy_host}:80" unless opts[:proxy].nil?
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
@@ -1,3 +1,3 @@
1
1
  module FrameworksCapybara
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -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[:proxy].should == nil
24
- Capybara.current_session.driver.options[:proxy_on].should == nil
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[:proxy].should == 'example.cache.co.uk:80'
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[:proxy].should == 'example.cache.co.uk:80'
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.0.0
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-02-21 00:00:00.000000000 Z
11
+ date: 2014-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types