frameworks-capybara 0.2.4 → 0.2.5
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.lock +1 -1
- data/README.rdoc +1 -0
- data/lib/frameworks/capybara.rb +8 -7
- data/lib/version.rb +1 -1
- data/spec/frameworks_capybara_spec.rb +19 -19
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -37,6 +37,7 @@ The following environment variables can be set to configure your tests:
|
|
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
39
|
FIREFOX_PREFS - specify a json string of additional preferences e.g. FIREFOX_PREFS='{"javascript.enabled": false}'
|
40
|
+
CREATE_NEW_FF_PROFILE - create a new Firefox profile with name provided by FIREFOX_PROFILE
|
40
41
|
CELERITY_JS_ENABLED (string - 'true', 'false') - determines whether Celerity (HTMLUnit) attempts to execute javascript
|
41
42
|
XVFB - (string - 'true', 'false') - determines whether XVFB is used to run browser (i.e. headless Firefox on *nix platform)
|
42
43
|
FW_CERT_LOCATION - path to client certificate (combined pem)
|
data/lib/frameworks/capybara.rb
CHANGED
@@ -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'], :firefox_prefs => ENV['FIREFOX_PREFS']}
|
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'], :create_new_ff_profile => ENV['CREATE_NEW_FF_PROFILE']}
|
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
|
|
@@ -65,7 +65,10 @@ class CapybaraSetup
|
|
65
65
|
def register_selenium_driver(opts,remote_opts,custom_opts)
|
66
66
|
Capybara.register_driver :selenium do |app|
|
67
67
|
|
68
|
-
opts[:
|
68
|
+
if opts[:create_new_ff_profile] || opts[:profile]
|
69
|
+
opts[:profile] = create_profile(opts[:profile], opts[:create_new_ff_profile], opts[:firefox_prefs])
|
70
|
+
end
|
71
|
+
|
69
72
|
opts[:switches] = [opts.delete(:chrome_switches)] if(opts[:chrome_switches])
|
70
73
|
|
71
74
|
if opts[:browser] == :remote
|
@@ -82,7 +85,7 @@ class CapybaraSetup
|
|
82
85
|
opts[:http_client] = client
|
83
86
|
end
|
84
87
|
|
85
|
-
clean_opts(opts, :proxy, :proxy_on, :firefox_prefs)
|
88
|
+
clean_opts(opts, :proxy, :proxy_on, :firefox_prefs, :create_new_ff_profile)
|
86
89
|
Capybara::Selenium::Driver.new(app,opts)
|
87
90
|
end
|
88
91
|
:selenium
|
@@ -97,7 +100,7 @@ class CapybaraSetup
|
|
97
100
|
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
|
98
101
|
end
|
99
102
|
|
100
|
-
def create_profile(profile_name, additional_prefs)
|
103
|
+
def create_profile(profile_name = nil, new_profile = nil, additional_prefs = nil)
|
101
104
|
additional_prefs = JSON.parse(additional_prefs) if additional_prefs
|
102
105
|
if(profile_name == 'BBC_INTERNAL')
|
103
106
|
profile = Selenium::WebDriver::Firefox::Profile.new
|
@@ -108,10 +111,8 @@ class CapybaraSetup
|
|
108
111
|
profile["network.proxy.http_port"] = 80
|
109
112
|
profile["network.proxy.ssl_port"] = 80
|
110
113
|
profile.native_events = true
|
111
|
-
elsif
|
114
|
+
elsif new_profile
|
112
115
|
profile = Selenium::WebDriver::Firefox::Profile.new
|
113
|
-
profile["network.http.sendRefererHeader"] = 0
|
114
|
-
profile.native_events = true
|
115
116
|
else
|
116
117
|
profile = Selenium::WebDriver::Firefox::Profile.from_name profile_name
|
117
118
|
profile.native_events = true
|
data/lib/version.rb
CHANGED
@@ -136,24 +136,6 @@ describe CapybaraSetup do
|
|
136
136
|
it_behaves_like "Selenium Driver Options Array"
|
137
137
|
end
|
138
138
|
|
139
|
-
|
140
|
-
context "with Selenium driver and programtically created profile with referer disabled" do
|
141
|
-
before do
|
142
|
-
ENV['BROWSER'] = 'firefox'
|
143
|
-
ENV['FIREFOX_PROFILE'] = 'DISABLED_REFERER'
|
144
|
-
end
|
145
|
-
|
146
|
-
it "should be initialized correctly" do
|
147
|
-
Capybara.delete_session
|
148
|
-
CapybaraSetup.new.driver.should == :selenium
|
149
|
-
Capybara.current_session.driver.should be_a_kind_of Capybara::Selenium::Driver
|
150
|
-
Capybara.current_session.driver.options[:browser].should == :firefox
|
151
|
-
Capybara.current_session.driver.options[:profile].should be_a_kind_of Selenium::WebDriver::Firefox::Profile
|
152
|
-
Capybara.current_session.driver.options[:profile].instance_variable_get(:@additional_prefs)['network.http.sendRefererHeader'].should == 0
|
153
|
-
end
|
154
|
-
it_behaves_like "Selenium Driver Options Array"
|
155
|
-
end
|
156
|
-
|
157
139
|
context "with Selenium driver and custom chrome options" do
|
158
140
|
before do
|
159
141
|
ENV['BROWSER'] = 'chrome'
|
@@ -279,7 +261,7 @@ describe CapybaraSetup do
|
|
279
261
|
before do
|
280
262
|
ENV['BROWSER'] = 'firefox'
|
281
263
|
ENV['FIREFOX_PROFILE'] = 'default'
|
282
|
-
ENV['FIREFOX_PREFS'] = '{"javascript.enabled":
|
264
|
+
ENV['FIREFOX_PREFS'] = '{"javascript.enabled":false}'
|
283
265
|
end
|
284
266
|
|
285
267
|
it "should be initialized correctly" do
|
@@ -294,6 +276,24 @@ describe CapybaraSetup do
|
|
294
276
|
end
|
295
277
|
|
296
278
|
|
279
|
+
context "with Selenium driver and new profile and custom prefs" do
|
280
|
+
before do
|
281
|
+
ENV['BROWSER'] = 'firefox'
|
282
|
+
ENV['CREATE_NEW_FF_PROFILE'] = 'true'
|
283
|
+
ENV['FIREFOX_PREFS'] = '{"javascript.enabled":false}'
|
284
|
+
end
|
285
|
+
|
286
|
+
it "should be initialized correctly" do
|
287
|
+
Capybara.delete_session
|
288
|
+
CapybaraSetup.new.driver.should == :selenium
|
289
|
+
Capybara.current_session.driver.should be_a_kind_of Capybara::Selenium::Driver
|
290
|
+
Capybara.current_session.driver.options[:browser].should == :firefox
|
291
|
+
Capybara.current_session.driver.options[:profile].should be_a_kind_of Selenium::WebDriver::Firefox::Profile
|
292
|
+
Capybara.current_session.driver.options[:profile].instance_variable_get(:@additional_prefs)['javascript.enabled'].should == false
|
293
|
+
end
|
294
|
+
it_behaves_like "Selenium Driver Options Array"
|
295
|
+
end
|
296
|
+
|
297
297
|
context "with Remote Selenium driver and specified Chrome Switches" do
|
298
298
|
before do
|
299
299
|
ENV['BROWSER'] = 'remote'
|
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:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 5
|
10
|
+
version: 0.2.5
|
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-05-
|
18
|
+
date: 2012-05-15 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|