frameworks-capybara 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -1,3 +1,7 @@
1
1
  source :rubygems
2
2
 
3
+ platforms :jruby do
4
+ gem "jruby-openssl"
5
+ end
6
+
3
7
  gemspec
data/Gemfile.lock CHANGED
@@ -1,16 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- frameworks-capybara (0.2.3)
4
+ frameworks-capybara (0.2.4)
5
5
  capybara (>= 1.0.0)
6
6
  capybara-celerity
7
7
  capybara-mechanize (>= 0.3.0)
8
+ cucumber (>= 0.10.5)
9
+ json
8
10
  w3c_validators
9
11
 
10
12
  GEM
11
13
  remote: http://rubygems.org/
12
14
  specs:
13
- addressable (2.2.7)
15
+ addressable (2.2.8)
16
+ bouncy-castle-java (1.5.0146.1)
14
17
  builder (3.0.0)
15
18
  capybara (1.1.2)
16
19
  mime-types (>= 1.16)
@@ -40,7 +43,9 @@ GEM
40
43
  ffi (1.0.11)
41
44
  gherkin (2.9.3)
42
45
  json (>= 1.4.6)
43
- json (1.6.6)
46
+ jruby-openssl (0.7.6.1)
47
+ bouncy-castle-java (>= 1.5.0146.1)
48
+ json (1.7.0)
44
49
  libwebsocket (0.1.3)
45
50
  addressable
46
51
  mechanize (2.4)
@@ -52,7 +57,7 @@ GEM
52
57
  ntlm-http (~> 0.1, >= 0.1.1)
53
58
  webrobots (~> 0.0, >= 0.0.9)
54
59
  mime-types (1.18)
55
- multi_json (1.3.2)
60
+ multi_json (1.3.4)
56
61
  net-http-digest_auth (1.2)
57
62
  net-http-persistent (2.6)
58
63
  nokogiri (1.5.2)
@@ -88,10 +93,11 @@ GEM
88
93
  nokogiri (~> 1.3)
89
94
 
90
95
  PLATFORMS
96
+ java
91
97
  ruby
92
98
 
93
99
  DEPENDENCIES
94
- cucumber (>= 0.10.5)
95
100
  frameworks-capybara!
101
+ jruby-openssl
96
102
  rake
97
103
  rspec (>= 1.0.0)
data/README.rdoc CHANGED
@@ -36,6 +36,7 @@ The following environment variables can be set to configure your tests:
36
36
  REMOTE_BROWSER_VERSION - used when specifying remote test on a grid the provides a choice of browser versions for a given browser
37
37
  REMOTE_URL - URL of remote Selenium-Webdriver server e.g. http://yourremotehost:4444/wd/hub
38
38
  FIREFOX_PROFILE - specify a firefox profile to use when running in-browser tests (local or remote)
39
+ FIREFOX_PREFS - specify a json string of additional preferences e.g. FIREFOX_PREFS='{"javascript.enabled": false}'
39
40
  CELERITY_JS_ENABLED (string - 'true', 'false') - determines whether Celerity (HTMLUnit) attempts to execute javascript
40
41
  XVFB - (string - 'true', 'false') - determines whether XVFB is used to run browser (i.e. headless Firefox on *nix platform)
41
42
  FW_CERT_LOCATION - path to client certificate (combined pem)
@@ -22,9 +22,10 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.add_runtime_dependency("capybara", [">=1.0.0"])
24
24
  s.add_runtime_dependency("capybara-mechanize", [">=0.3.0"])
25
+ s.add_runtime_dependency("json")
25
26
  s.add_runtime_dependency("capybara-celerity")
26
27
  s.add_runtime_dependency("w3c_validators")
27
- s.add_development_dependency("cucumber", [">= 0.10.5"])
28
+ s.add_runtime_dependency("cucumber", [">= 0.10.5"])
28
29
  s.add_development_dependency("rake")
29
30
  s.add_development_dependency("rspec", [">=1.0.0"])
30
31
 
@@ -14,7 +14,7 @@ class CapybaraSetup
14
14
  attr_reader :driver
15
15
 
16
16
  def initialize
17
- capybara_opts = {:environment => ENV['ENVIRONMENT'], :proxy => ENV['PROXY_URL'], :profile => ENV['FIREFOX_PROFILE'], :browser => ENV['BROWSER'], :javascript_enabled => ENV['CELERITY_JS_ENABLED'], :proxy_on => ENV['PROXY_ON'],:url => ENV['REMOTE_URL'], :chrome_switches => ENV['CHROME_SWITCHES']}
17
+ capybara_opts = {:environment => ENV['ENVIRONMENT'], :proxy => ENV['PROXY_URL'], :profile => ENV['FIREFOX_PROFILE'], :browser => ENV['BROWSER'], :javascript_enabled => ENV['CELERITY_JS_ENABLED'], :proxy_on => ENV['PROXY_ON'],:url => ENV['REMOTE_URL'], :chrome_switches => ENV['CHROME_SWITCHES'], :firefox_prefs => ENV['FIREFOX_PREFS']}
18
18
  selenium_remote_opts = {:platform => ENV['PLATFORM'], :browser_name => ENV['REMOTE_BROWSER'], :version => ENV['REMOTE_BROWSER_VERSION'], :url => ENV['REMOTE_URL']}
19
19
  custom_opts = {:job_name => ENV['SAUCE_JOB_NAME'], :max_duration => ENV['SAUCE_MAX_DURATION']}
20
20
 
@@ -27,6 +27,7 @@ class CapybaraSetup
27
27
  Capybara.run_server = false #Disable rack server
28
28
 
29
29
  [capybara_opts, selenium_remote_opts, custom_opts].each do |opts| #delete nil options and environment (which is only used for validation)
30
+
30
31
  opts.delete_if {|k,v| (v.nil? or k == :environment)}
31
32
  end
32
33
 
@@ -64,7 +65,7 @@ class CapybaraSetup
64
65
  def register_selenium_driver(opts,remote_opts,custom_opts)
65
66
  Capybara.register_driver :selenium do |app|
66
67
 
67
- opts[:profile] = create_profile(opts[:profile]) if(opts[:profile])
68
+ opts[:profile] = create_profile(opts[:profile], opts[:firefox_prefs]) if(opts[:profile])
68
69
  opts[:switches] = [opts.delete(:chrome_switches)] if(opts[:chrome_switches])
69
70
 
70
71
  if opts[:browser] == :remote
@@ -80,7 +81,8 @@ class CapybaraSetup
80
81
  opts[:desired_capabilities] = caps
81
82
  opts[:http_client] = client
82
83
  end
83
- clean_opts(opts, :proxy, :proxy_on)
84
+
85
+ clean_opts(opts, :proxy, :proxy_on, :firefox_prefs)
84
86
  Capybara::Selenium::Driver.new(app,opts)
85
87
  end
86
88
  :selenium
@@ -95,7 +97,8 @@ class CapybaraSetup
95
97
  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['PROXY_URL'] for setting in browser (ff profile) but not for client conection, hence allow for PROXY_ON=false
96
98
  end
97
99
 
98
- def create_profile(profile_name)
100
+ def create_profile(profile_name, additional_prefs)
101
+ additional_prefs = JSON.parse(additional_prefs) if additional_prefs
99
102
  if(profile_name == 'BBC_INTERNAL')
100
103
  profile = Selenium::WebDriver::Firefox::Profile.new
101
104
  profile["network.proxy.type"] = 1
@@ -113,6 +116,13 @@ class CapybaraSetup
113
116
  profile = Selenium::WebDriver::Firefox::Profile.from_name profile_name
114
117
  profile.native_events = true
115
118
  end
119
+
120
+ if additional_prefs
121
+ additional_prefs.each do |k, v|
122
+ profile[k] = v
123
+ end
124
+ end
125
+
116
126
  profile
117
127
  end
118
128
 
@@ -21,21 +21,24 @@ module Frameworks
21
21
  set_scheme
22
22
  if(environment =='sandbox')
23
23
  @base_url = @sandbox + @bbc_domain
24
+ @ssl_base_url = @sslsandbox + @bbc_domain
24
25
  @static_base_url = @static_sandbox + @bbc_domain
25
26
  elsif (environment =='live' && ENV['WWW_LIVE']=='false')
26
27
  @base_url = @www_prefix.chop + @bbc_domain
28
+ @ssl_base_url = @ssl_prefix.chop + @bbc_domain
27
29
  @static_base_url = @static_prefix.chop + @bbci_domain
28
30
  @open_base_url = @open_prefix.chop + @bbc_domain
29
31
  elsif (environment.split('.')[0].include? 'pal') #address specific box
30
32
  @base_url = "#{scheme}://#{ENV['ENVIRONMENT']}"
31
33
  else
32
34
  @base_url = @www_prefix + environment + @bbc_domain
35
+ @ssl_base_url = @ssl_prefix + environment + @bbc_domain
33
36
  @static_base_url = @static_prefix + environment + @bbci_domain
34
37
  @static_base_url = @static_prefix.chop + @bbci_domain if environment == 'live'
35
38
  @open_base_url = @open_prefix + environment + @bbc_domain
36
39
  end
37
40
  proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
38
- @proxy_host = proxy.scan(/http:\/\/(.*):80/).to_s if proxy
41
+ @proxy_host = proxy.scan(/http:\/\/(.*):80/)[0][0] if proxy
39
42
  end
40
43
 
41
44
  def validate_online(src)
@@ -62,11 +65,13 @@ module Frameworks
62
65
  def set_scheme
63
66
  ENV['SCHEME']=='https' ? scheme = 'https' : scheme = 'http'
64
67
  @www_prefix = "#{scheme}://www."
68
+ @ssl_prefix = "https://ssl."
65
69
  @static_prefix = "#{scheme}://static."
66
70
  @open_prefix = "#{scheme}://open."
67
71
  @bbc_domain = '.bbc.co.uk'
68
72
  @bbci_domain = '.bbci.co.uk'
69
73
  @sandbox = "#{scheme}://pal.sandbox.dev"
74
+ @sslsandbox = "https://ssl.sandbox.dev"
70
75
  @static_sandbox = "#{scheme}://static.sandbox.dev"
71
76
  end
72
77
 
data/lib/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module FrameworksCapybara
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.4'
3
3
  end
4
4
 
@@ -18,7 +18,6 @@ shared_examples_for "Selenium Driver Options Array" do
18
18
  it "should contain no nil values for unset options" do
19
19
  #TODO: Test for nil elements in options - there shouldn't be any that we insert
20
20
  #i.e. anything in our ENV options should not end up being nil in Selenium
21
-
22
21
  Capybara.current_session.driver.options[:environment].should == nil
23
22
  Capybara.current_session.driver.options[:proxy].should == nil
24
23
  Capybara.current_session.driver.options[:proxy_on].should == nil
@@ -27,6 +26,7 @@ shared_examples_for "Selenium Driver Options Array" do
27
26
  Capybara.current_session.driver.options[:version].should == nil
28
27
  Capybara.current_session.driver.options[:job_name].should == nil
29
28
  Capybara.current_session.driver.options[:chrome_switches].should == nil
29
+ Capybara.current_session.driver.options[:firefox_prefs].should == nil
30
30
  Capybara.current_session.driver.options[:max_duration].should == nil
31
31
  Capybara.current_session.driver.options[:profile].should_not be_a_kind_of String
32
32
  Capybara.current_session.driver.options[:browser].should_not be_a_kind_of String
@@ -275,6 +275,25 @@ describe CapybaraSetup do
275
275
  it_behaves_like "Selenium Driver Options Array"
276
276
  end
277
277
 
278
+ context "with Selenium driver and additional firefox preferences" do
279
+ before do
280
+ ENV['BROWSER'] = 'firefox'
281
+ ENV['FIREFOX_PROFILE'] = 'default'
282
+ ENV['FIREFOX_PREFS'] = '{"javascript.enabled": false}'
283
+ end
284
+
285
+ it "should be initialized correctly" do
286
+ Capybara.delete_session
287
+ CapybaraSetup.new.driver.should == :selenium
288
+ Capybara.current_session.driver.should be_a_kind_of Capybara::Selenium::Driver
289
+ Capybara.current_session.driver.options[:browser].should == :firefox
290
+ Capybara.current_session.driver.options[:profile].should be_a_kind_of Selenium::WebDriver::Firefox::Profile
291
+ Capybara.current_session.driver.options[:profile].instance_variable_get(:@additional_prefs)['javascript.enabled'].should == false
292
+ end
293
+ it_behaves_like "Selenium Driver Options Array"
294
+ end
295
+
296
+
278
297
  context "with Remote Selenium driver and specified Chrome Switches" do
279
298
  before do
280
299
  ENV['BROWSER'] = 'remote'
@@ -13,6 +13,7 @@ describe Frameworks::EnvHelper do
13
13
  ENV['ENVIRONMENT'] = 'sandbox'
14
14
  generate_base_urls
15
15
  @base_url.should == 'http://pal.sandbox.dev.bbc.co.uk'
16
+ @ssl_base_url.should == 'https://ssl.sandbox.dev.bbc.co.uk'
16
17
  @static_base_url.should == 'http://static.sandbox.dev.bbc.co.uk'
17
18
  end
18
19
 
@@ -20,6 +21,7 @@ describe Frameworks::EnvHelper do
20
21
  ENV['ENVIRONMENT'] = 'foo'
21
22
  generate_base_urls
22
23
  @base_url.should == 'http://www.foo.bbc.co.uk'
24
+ @ssl_base_url.should == 'https://ssl.foo.bbc.co.uk'
23
25
  @static_base_url.should == 'http://static.foo.bbci.co.uk'
24
26
  @open_base_url.should == 'http://open.foo.bbc.co.uk'
25
27
  end
@@ -28,6 +30,7 @@ describe Frameworks::EnvHelper do
28
30
  ENV['ENVIRONMENT'] = 'live'
29
31
  generate_base_urls
30
32
  @base_url.should == 'http://www.live.bbc.co.uk'
33
+ @ssl_base_url.should == 'https://ssl.live.bbc.co.uk'
31
34
  @static_base_url.should == 'http://static.bbci.co.uk'
32
35
  @open_base_url.should == 'http://open.live.bbc.co.uk'
33
36
  end
@@ -36,6 +39,7 @@ describe Frameworks::EnvHelper do
36
39
  ENV['ENVIRONMENT'] = 'fOo'
37
40
  generate_base_urls
38
41
  @base_url.should == 'http://www.foo.bbc.co.uk'
42
+ @ssl_base_url.should == 'https://ssl.foo.bbc.co.uk'
39
43
  @static_base_url.should == 'http://static.foo.bbci.co.uk'
40
44
  @open_base_url.should == 'http://open.foo.bbc.co.uk'
41
45
  end
@@ -44,6 +48,7 @@ describe Frameworks::EnvHelper do
44
48
  ENV['ENVIRONMENT'] = 'LiVe'
45
49
  generate_base_urls
46
50
  @base_url.should == 'http://www.live.bbc.co.uk'
51
+ @ssl_base_url.should == 'https://ssl.live.bbc.co.uk'
47
52
  @static_base_url.should == 'http://static.bbci.co.uk'
48
53
  @open_base_url.should == 'http://open.live.bbc.co.uk'
49
54
  end
@@ -54,6 +59,7 @@ describe Frameworks::EnvHelper do
54
59
  ENV['WWW_LIVE'] = 'false'
55
60
  generate_base_urls
56
61
  @base_url.should == 'http://www.bbc.co.uk'
62
+ @ssl_base_url.should == 'https://ssl.bbc.co.uk'
57
63
  @static_base_url.should == 'http://static.bbci.co.uk'
58
64
  @open_base_url.should == 'http://open.bbc.co.uk'
59
65
  end
@@ -63,6 +69,7 @@ describe Frameworks::EnvHelper do
63
69
  ENV['ENVIRONMENT'] = 'foo'
64
70
  generate_base_urls
65
71
  @base_url.should == 'https://www.foo.bbc.co.uk'
72
+ @ssl_base_url.should == 'https://ssl.foo.bbc.co.uk'
66
73
  @static_base_url.should == 'https://static.foo.bbci.co.uk'
67
74
  @open_base_url.should == 'https://open.foo.bbc.co.uk'
68
75
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frameworks-capybara
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - matt robbins
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-30 00:00:00 +01:00
18
+ date: 2012-05-10 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -61,7 +61,7 @@ dependencies:
61
61
  segments:
62
62
  - 0
63
63
  version: "0"
64
- name: capybara-celerity
64
+ name: json
65
65
  version_requirements: *id003
66
66
  prerelease: false
67
67
  - !ruby/object:Gem::Dependency
@@ -75,12 +75,26 @@ dependencies:
75
75
  segments:
76
76
  - 0
77
77
  version: "0"
78
- name: w3c_validators
78
+ name: capybara-celerity
79
79
  version_requirements: *id004
80
80
  prerelease: false
81
81
  - !ruby/object:Gem::Dependency
82
- type: :development
82
+ type: :runtime
83
83
  requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
92
+ name: w3c_validators
93
+ version_requirements: *id005
94
+ prerelease: false
95
+ - !ruby/object:Gem::Dependency
96
+ type: :runtime
97
+ requirement: &id006 !ruby/object:Gem::Requirement
84
98
  none: false
85
99
  requirements:
86
100
  - - ">="
@@ -92,11 +106,11 @@ dependencies:
92
106
  - 5
93
107
  version: 0.10.5
94
108
  name: cucumber
95
- version_requirements: *id005
109
+ version_requirements: *id006
96
110
  prerelease: false
97
111
  - !ruby/object:Gem::Dependency
98
112
  type: :development
99
- requirement: &id006 !ruby/object:Gem::Requirement
113
+ requirement: &id007 !ruby/object:Gem::Requirement
100
114
  none: false
101
115
  requirements:
102
116
  - - ">="
@@ -106,11 +120,11 @@ dependencies:
106
120
  - 0
107
121
  version: "0"
108
122
  name: rake
109
- version_requirements: *id006
123
+ version_requirements: *id007
110
124
  prerelease: false
111
125
  - !ruby/object:Gem::Dependency
112
126
  type: :development
113
- requirement: &id007 !ruby/object:Gem::Requirement
127
+ requirement: &id008 !ruby/object:Gem::Requirement
114
128
  none: false
115
129
  requirements:
116
130
  - - ">="
@@ -122,7 +136,7 @@ dependencies:
122
136
  - 0
123
137
  version: 1.0.0
124
138
  name: rspec
125
- version_requirements: *id007
139
+ version_requirements: *id008
126
140
  prerelease: false
127
141
  description: Gem to ease the pain of managing capybara driver config and provide a home for common utils and patches
128
142
  email: