frameworks-capybara 0.1.1 → 0.1.2

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{frameworks-capybara}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["mcrmfc"]
12
- s.date = %q{2011-10-10}
12
+ s.date = %q{2011-11-07}
13
13
  s.description = %q{gem to aid setup of Capybara for testing bbc sites}
14
14
  s.email = %q{mcrobbins@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -12,7 +12,7 @@ class CapybaraSetup
12
12
  attr_reader :driver
13
13
 
14
14
  def initialize
15
- 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']}
15
+ 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']}
16
16
  selenium_remote_opts = {:platform => ENV['PLATFORM'], :browser_name => ENV['REMOTE_BROWSER'], :version => ENV['REMOTE_BROWSER_VERSION'], :url => ENV['REMOTE_URL']}
17
17
  custom_opts = {:job_name => ENV['SAUCE_JOB_NAME'], :max_duration => ENV['SAUCE_MAX_DURATION']}
18
18
 
@@ -63,12 +63,14 @@ class CapybaraSetup
63
63
  Capybara.register_driver :selenium do |app|
64
64
 
65
65
  opts[:profile] = create_profile(opts[:profile]) if(opts[:profile])
66
+ opts[:switches] = [opts.delete(:chrome_switches)] if(opts[:chrome_switches])
66
67
 
67
68
  if opts[:browser] == :remote
68
69
  client = Selenium::WebDriver::Remote::Http::Default.new
69
70
  client.proxy = set_client_proxy(opts)
70
71
 
71
- remote_opts[:firefox_profile] = opts.delete :profile
72
+ remote_opts[:firefox_profile] = opts.delete :profile if opts[:profile]
73
+ remote_opts['chrome.switches'] = opts.delete :switches if opts[:switches]
72
74
  caps = Selenium::WebDriver::Remote::Capabilities.new(remote_opts)
73
75
 
74
76
  add_custom_caps(caps, custom_opts) if remote_opts[:url].include? 'saucelabs' #set sauce specific parameters - will this scupper other on sauce remote jobs?
@@ -26,6 +26,7 @@ shared_examples_for "Selenium Driver Options Array" do
26
26
  Capybara.current_session.driver.options[:browser_name].should == nil
27
27
  Capybara.current_session.driver.options[:version].should == nil
28
28
  Capybara.current_session.driver.options[:job_name].should == nil
29
+ Capybara.current_session.driver.options[:chrome_switches].should == nil
29
30
  Capybara.current_session.driver.options[:max_duration].should == nil
30
31
  Capybara.current_session.driver.options[:profile].should_not be_a_kind_of String
31
32
  Capybara.current_session.driver.options[:browser].should_not be_a_kind_of String
@@ -133,6 +134,22 @@ describe CapybaraSetup do
133
134
  it_behaves_like "Selenium Driver Options Array"
134
135
  end
135
136
 
137
+ context "with Selenium driver and custom chrome options" do
138
+ before do
139
+ ENV['BROWSER'] = 'chrome'
140
+ ENV['CHROME_SWITCHES'] = '--user-agent=Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10'
141
+ end
142
+
143
+ it "should be initialized correctly" do
144
+ Capybara.delete_session
145
+ CapybaraSetup.new.driver.should == :selenium
146
+ Capybara.current_session.driver.should be_a_kind_of Capybara::Driver::Selenium
147
+ Capybara.current_session.driver.options[:browser].should == :chrome
148
+ Capybara.current_session.driver.options[:switches].should == ['--user-agent=Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10']
149
+ end
150
+ it_behaves_like "Selenium Driver Options Array"
151
+ end
152
+
136
153
 
137
154
  context "with Remote Selenium driver" do
138
155
  before do
@@ -238,6 +255,30 @@ describe CapybaraSetup do
238
255
  it_behaves_like "Selenium Driver Options Array"
239
256
  end
240
257
 
258
+ context "with Remote Selenium driver and specified Chrome Switches" do
259
+ before do
260
+ ENV['BROWSER'] = 'remote'
261
+ ENV['REMOTE_BROWSER'] = 'chrome'
262
+ ENV['REMOTE_URL'] = 'http://saucelabs.com'
263
+ ENV['CHROME_SWITCHES'] = '--user-agent=Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10'
264
+ end
265
+
266
+ it "should be initialized correctly" do
267
+ Capybara.delete_session
268
+ CapybaraSetup.new.driver.should == :selenium
269
+ Capybara.current_session.driver.should be_a_kind_of Capybara::Driver::Selenium
270
+ Capybara.current_session.driver.options[:browser].should == :remote
271
+ Capybara.current_session.driver.options[:switches].should == nil
272
+ Capybara.current_session.driver.options[:url].should == 'http://saucelabs.com'
273
+ Capybara.current_session.driver.options[:http_client].should be_a_kind_of Selenium::WebDriver::Remote::Http::Default
274
+ Capybara.current_session.driver.options[:http_client].instance_variable_get(:@proxy).should == nil
275
+ Capybara.current_session.driver.options[:desired_capabilities].should be_a_kind_of Selenium::WebDriver::Remote::Capabilities
276
+ Capybara.current_session.driver.options[:desired_capabilities].instance_variable_get(:@capabilities)[:browser_name].should == :chrome
277
+ Capybara.current_session.driver.options[:desired_capabilities].instance_variable_get(:@capabilities)['chrome.switches'].should == ['--user-agent=Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10']
278
+ end
279
+ it_behaves_like "Selenium Driver Options Array"
280
+ end
281
+
241
282
  context "with Remote Selenium driver and specified Custom Capabilites (e.g. for Sauce Labs)" do
242
283
  before do
243
284
  ENV['BROWSER'] = 'remote'
@@ -266,6 +307,8 @@ describe CapybaraSetup do
266
307
  end
267
308
  it_behaves_like "Selenium Driver Options Array"
268
309
  end
310
+
311
+
269
312
  end
270
313
 
271
314
  describe "should allow Mechanize driver to be created" do
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: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - mcrmfc
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-10 00:00:00 +01:00
18
+ date: 2011-11-07 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency