frameworks-capybara 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.rdoc +4 -4
- data/lib/frameworks/capybara.rb +32 -16
- data/lib/frameworks/cucumber.rb +2 -1
- data/lib/monkey-patches/capybara-patches.rb +1 -35
- data/lib/tasks/frameworks-tasks.rb +77 -0
- data/lib/version.rb +1 -1
- data/spec/frameworks_capybara_spec.rb +41 -8
- data/spec/frameworks_cucumber_spec.rb +3 -0
- metadata +4 -12
- data/lib/tasks/frameworks-tasks.rake +0 -75
- data/schemas/xhtml-lat1.ent +0 -196
- data/schemas/xhtml-rdfa-1.dtd +0 -438
- data/schemas/xhtml-special.ent +0 -80
- data/schemas/xhtml-symbol.ent +0 -237
- data/schemas/xhtml1-strict.dtd +0 -978
- data/schemas/xhtml1-strict.xsd +0 -2211
- data/schemas/xhtml1-transitional.dtd +0 -1201
- data/schemas/xml.xsd +0 -287
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -29,10 +29,10 @@ The following environment variables can be set to configure your tests:
|
|
29
29
|
|
30
30
|
ENVIRONMENT - this must be one of either 'sandbox', 'int', 'test', 'stage', 'live'
|
31
31
|
BROWSER - this must be one of either 'ie', 'firefox', 'chrome', 'headless', 'remote'
|
32
|
-
|
32
|
+
HTTP_PROXY - url of proxy if required e.g. 'http://proxyhost:80', when running a headless browser this sets the proxy for the browser itself, when running a remote browser this sets the proxy for the client which will connect to the remote selenium server
|
33
33
|
PLATFORM - used when specifying remote test on a grid that provides a choice of platforms, this must be one of either 'WINDOWS' or 'LINUX'
|
34
|
-
REMOTE_BROWSER - used when specifying remote test, must be one of either 'ie', 'firefox', 'chrome', 'headless', 'remote'
|
35
|
-
|
34
|
+
REMOTE_BROWSER - used when specifying remote test, must be one of either 'ie', 'firefox', 'chrome', 'headless', 'remote':w
|
35
|
+
|
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)
|
@@ -55,7 +55,7 @@ Here is a sample cucumber.yml:
|
|
55
55
|
<%browser_firefox='BROWSER=firefox'%>
|
56
56
|
<%browser_chrome='BROWSER=chrome'%>
|
57
57
|
<%browser_remote='BROWSER=remote'%>
|
58
|
-
<%proxy_on='
|
58
|
+
<%proxy_on='=http://proxyhost:proxyport'%>
|
59
59
|
<%sauce_remote_url='REMOTE_URL=http://mykey@ondemand.saucelabs.com:80/wd/hub'%>
|
60
60
|
<%demo_feature='features/demo.feature'%>
|
61
61
|
|
data/lib/frameworks/capybara.rb
CHANGED
@@ -2,7 +2,6 @@ require 'capybara/cucumber'
|
|
2
2
|
require 'monkey-patches/webdriver-patches'
|
3
3
|
require 'monkey-patches/capybara-patches'
|
4
4
|
require 'monkey-patches/capybara-mechanize-patches'
|
5
|
-
#require 'monkey-patches/net-http-persistent-patches'
|
6
5
|
require 'monkey-patches/mechanize-patches'
|
7
6
|
require 'monkey-patches/send-keys'
|
8
7
|
require 'selenium-webdriver'
|
@@ -14,9 +13,26 @@ class CapybaraSetup
|
|
14
13
|
attr_reader :driver
|
15
14
|
|
16
15
|
def initialize
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
|
17
|
+
http_proxy = ENV['HTTP_PROXY'] || ENV['http_proxy']
|
18
|
+
|
19
|
+
capybara_opts = {:environment => ENV['ENVIRONMENT'],
|
20
|
+
:proxy => http_proxy,
|
21
|
+
:profile => ENV['FIREFOX_PROFILE'],
|
22
|
+
:browser => ENV['BROWSER'],
|
23
|
+
:javascript_enabled => ENV['CELERITY_JS_ENABLED'],
|
24
|
+
:proxy_on => ENV['PROXY_ON'],
|
25
|
+
:url => ENV['REMOTE_URL'],
|
26
|
+
:chrome_switches => ENV['CHROME_SWITCHES'],
|
27
|
+
:firefox_prefs => ENV['FIREFOX_PREFS']}
|
28
|
+
|
29
|
+
selenium_remote_opts = {:platform => ENV['PLATFORM'],
|
30
|
+
:browser_name => ENV['REMOTE_BROWSER'],
|
31
|
+
:version => ENV['REMOTE_BROWSER_VERSION'],
|
32
|
+
:url => ENV['REMOTE_URL']}
|
33
|
+
|
34
|
+
custom_opts = {:job_name => ENV['SAUCE_JOB_NAME'],
|
35
|
+
:max_duration => ENV['SAUCE_MAX_DURATION']}
|
20
36
|
|
21
37
|
validate_env_vars(capybara_opts.merge(selenium_remote_opts)) #validate environment variables set using cucumber.yml or passed via command line
|
22
38
|
|
@@ -27,7 +43,7 @@ class CapybaraSetup
|
|
27
43
|
Capybara.run_server = false #Disable rack server
|
28
44
|
|
29
45
|
[capybara_opts, selenium_remote_opts, custom_opts].each do |opts| #delete nil options and environment (which is only used for validation)
|
30
|
-
|
46
|
+
|
31
47
|
opts.delete_if {|k,v| (v.nil? or k == :environment)}
|
32
48
|
end
|
33
49
|
|
@@ -40,7 +56,6 @@ class CapybaraSetup
|
|
40
56
|
@driver = register_selenium_driver(capybara_opts, selenium_remote_opts, custom_opts)
|
41
57
|
end
|
42
58
|
|
43
|
-
|
44
59
|
Capybara.default_driver = @driver
|
45
60
|
end
|
46
61
|
|
@@ -48,8 +63,8 @@ class CapybaraSetup
|
|
48
63
|
|
49
64
|
def validate_env_vars(opts)
|
50
65
|
|
51
|
-
msg1 = 'Please ensure following environment variables are set ENVIRONMENT [int|test|stage|live], BROWSER[headless|ie|chrome|firefox] and
|
52
|
-
msg2 = 'Please ensure the following environment variables are set PLATFORM, REMOTE_URL, REMOTE_BROWSER (browser to use on remote machine),
|
66
|
+
msg1 = 'Please ensure following environment variables are set ENVIRONMENT [int|test|stage|live], BROWSER[headless|ie|chrome|firefox] and HTTP_PROXY (if required)'
|
67
|
+
msg2 = 'Please ensure the following environment variables are set PLATFORM, REMOTE_URL, REMOTE_BROWSER (browser to use on remote machine), HTTP_PROXY (if required), REMOTE_BROWSER_PROXY (if required) and BROWSER_VERSION (if required)'
|
53
68
|
|
54
69
|
[:environment, :browser].each do |item|
|
55
70
|
!opts.has_key?(item) or opts[item]==nil ? raise(msg1) : ''
|
@@ -65,8 +80,8 @@ class CapybaraSetup
|
|
65
80
|
def register_selenium_driver(opts,remote_opts,custom_opts)
|
66
81
|
Capybara.register_driver :selenium do |app|
|
67
82
|
|
68
|
-
if opts[:
|
69
|
-
opts[:profile] = create_profile(opts[:profile],
|
83
|
+
if opts[:firefox_prefs] || opts[:profile]
|
84
|
+
opts[:profile] = create_profile(opts[:profile], opts[:firefox_prefs])
|
70
85
|
end
|
71
86
|
|
72
87
|
opts[:switches] = [opts.delete(:chrome_switches)] if(opts[:chrome_switches])
|
@@ -85,7 +100,7 @@ class CapybaraSetup
|
|
85
100
|
opts[:http_client] = client
|
86
101
|
end
|
87
102
|
|
88
|
-
clean_opts(opts, :proxy, :proxy_on, :firefox_prefs
|
103
|
+
clean_opts(opts, :proxy, :proxy_on, :firefox_prefs)
|
89
104
|
Capybara::Selenium::Driver.new(app,opts)
|
90
105
|
end
|
91
106
|
:selenium
|
@@ -97,12 +112,15 @@ class CapybaraSetup
|
|
97
112
|
end
|
98
113
|
|
99
114
|
def set_client_proxy(opts)
|
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['
|
115
|
+
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
|
101
116
|
end
|
102
117
|
|
103
|
-
def create_profile(profile_name = nil,
|
118
|
+
def create_profile(profile_name = nil, additional_prefs = nil)
|
104
119
|
additional_prefs = JSON.parse(additional_prefs) if additional_prefs
|
105
|
-
if(
|
120
|
+
if(additional_prefs && !profile_name)
|
121
|
+
profile = Selenium::WebDriver::Firefox::Profile.new
|
122
|
+
profile.native_events = true
|
123
|
+
elsif(profile_name == 'BBC_INTERNAL')
|
106
124
|
profile = Selenium::WebDriver::Firefox::Profile.new
|
107
125
|
profile["network.proxy.type"] = 1
|
108
126
|
profile["network.proxy.no_proxies_on"] = "*.sandbox.dev.bbc.co.uk"
|
@@ -111,8 +129,6 @@ class CapybaraSetup
|
|
111
129
|
profile["network.proxy.http_port"] = 80
|
112
130
|
profile["network.proxy.ssl_port"] = 80
|
113
131
|
profile.native_events = true
|
114
|
-
elsif new_profile
|
115
|
-
profile = Selenium::WebDriver::Firefox::Profile.new
|
116
132
|
else
|
117
133
|
profile = Selenium::WebDriver::Firefox::Profile.from_name profile_name
|
118
134
|
profile.native_events = true
|
data/lib/frameworks/cucumber.rb
CHANGED
@@ -86,11 +86,12 @@ World(Frameworks::EnvHelper)
|
|
86
86
|
Before do
|
87
87
|
#This is ugly but unavoidable since Capybara::RackTest::Driver.reset_host! does @browser = nil and wipes all brower level settings
|
88
88
|
#it was either this or a monkey patch - need to think about pushing a softer reset change to capybara-mechanize to override this
|
89
|
+
http_proxy = ENV['HTTP_PROXY'] || ENV['http_proxy']
|
89
90
|
if page.driver.class == Capybara::Mechanize::Driver
|
90
91
|
page.driver.browser.agent.cert, page.driver.browser.agent.key = ENV['FW_CERT_LOCATION'], ENV['FW_CERT_LOCATION'] if ENV['FW_CERT_LOCATION']
|
91
92
|
page.driver.browser.agent.ca_file = ENV['CA_CERT_LOCATION'] if ENV['CA_CERT_LOCATION']
|
92
93
|
#TODO: Fix proxy logic globally...use system proxy instead of PROXY_URL
|
93
|
-
page.driver.browser.agent.set_proxy(
|
94
|
+
page.driver.browser.agent.set_proxy(http_proxy.scan(/http:\/\/(.*):80/).to_s,80) if http_proxy
|
94
95
|
#This is necessary because Mech2 does not ship with root certs like Mech1 did and boxes may not have the OpenSSL set installed
|
95
96
|
page.driver.browser.agent.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
96
97
|
end
|
@@ -78,40 +78,6 @@ module Capybara
|
|
78
78
|
driver.add_cookie(attribs)
|
79
79
|
end
|
80
80
|
|
81
|
-
DTD_REFS = {
|
82
|
-
"-//W3C//DTD XHTML 1.0 Strict//EN" => {:dtd => "#{File.dirname( __FILE__)}/../../schemas/xhtml1-strict.dtd", :type => :strict},
|
83
|
-
"-//W3C//DTD XHTML 1.0 Transitional//EN" => {:dtd => "#{File.dirname( __FILE__)}/../../schemas/xhtml1-transitional.dtd", :type => :transitional},
|
84
|
-
"-//W3C//DTD XHTML+RDFa 1.0//EN" => {:dtd => "#{File.dirname( __FILE__)}/../../schemas/xhtml-rdfa-1.dtd", :type => :rdfa}}
|
85
|
-
#I highly recomment NOT using this method
|
86
|
-
def validate(source)
|
87
|
-
doctype = source.scan(/\"(.*?)\"/)[0].to_s
|
88
|
-
|
89
|
-
if(DTD_REFS[doctype])
|
90
|
-
dtd = DTD_REFS[doctype][:dtd]
|
91
|
-
type = DTD_REFS[doctype][:type]
|
92
|
-
end
|
93
|
-
|
94
|
-
raise "RDFA Validation not currently supported due to issues in Nokogiri" if type == :rdfa
|
95
|
-
|
96
|
-
if(RUBY_PLATFORM == 'java') #this works
|
97
|
-
source = source.gsub(/PUBLIC \"-\/\/W3C\/\/DTD XHTML.*?\/\/EN\" \"http:\/\/www.w3.org.*?\"/, "SYSTEM \"#{dtd}\"")
|
98
|
-
doc = Nokogiri::XML(source) { |cfg|
|
99
|
-
cfg.noent.dtdload.dtdvalid
|
100
|
-
}
|
101
|
-
doc = Nokogiri::XML(source)
|
102
|
-
errors = doc.validate
|
103
|
-
else #this doesn't - nokogiri issues
|
104
|
-
require 'open-uri'
|
105
|
-
doc = Nokogiri::XML(open(driver.current_url, :proxy => ENV['PROXY_URL'])) do |config|
|
106
|
-
config.strict.noent
|
107
|
-
end
|
108
|
-
#xsd = Nokogiri::XML::Schema(File.read("#{File.dirname( __FILE__)}/../../schemas/xhtml1-strict.xsd"))
|
109
|
-
xsd = Nokogiri::XML::Schema(open('http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd', :proxy => ENV['PROXY_URL']))
|
110
|
-
errors = xsd.validate(doc)
|
111
|
-
end
|
112
|
-
raise "Page (#{current_url}) failed XHTML vaidation (or Nokogiri Freaked out...please manually check against W3C), errors:#{errors.to_s}" unless errors == []
|
113
|
-
end
|
114
81
|
end
|
115
|
-
end
|
116
|
-
|
117
82
|
|
83
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
class RakeHelpers
|
2
|
+
INVOKE_CUCUMBER = "bin/cucumber -r features"
|
3
|
+
|
4
|
+
class << self
|
5
|
+
def install
|
6
|
+
system('bundle install --no-cache --binstubs --path vendor/bundle')
|
7
|
+
end
|
8
|
+
|
9
|
+
def color(text, options = {})
|
10
|
+
#ANSI color codes
|
11
|
+
case options[:color]
|
12
|
+
when :red
|
13
|
+
text = "\033[31m#{text}\033[0m"
|
14
|
+
when :green
|
15
|
+
text = "\033[32m#{text}\033[0m"
|
16
|
+
when :yellow
|
17
|
+
text = "\033[33m#{text}\033[0m"
|
18
|
+
end
|
19
|
+
text
|
20
|
+
end
|
21
|
+
|
22
|
+
def list_profiles
|
23
|
+
puts 'Available profiles:'
|
24
|
+
f = File.open('config/cucumber.yml', 'r')
|
25
|
+
linenum = 0
|
26
|
+
@profiles = {}
|
27
|
+
f.read.each do |line|
|
28
|
+
line.scan(/.*?: /) do |match|
|
29
|
+
linenum += 1
|
30
|
+
puts color(linenum.to_s + '. ', :color => :yellow) + color(match.gsub(':',''), :color => :green)
|
31
|
+
@profiles[linenum.to_s] = match.gsub(':','')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def update
|
37
|
+
system('bundle update')
|
38
|
+
end
|
39
|
+
|
40
|
+
def run_feature(feature, profile='default')
|
41
|
+
system("#{INVOKE_CUCUMBER} -p #{profile} features/#{feature}.feature")
|
42
|
+
end
|
43
|
+
|
44
|
+
def run_profile(profile='default')
|
45
|
+
system("#{INVOKE_CUCUMBER} -p #{profile}")
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
def start_app
|
50
|
+
$: << File.dirname( __FILE__)
|
51
|
+
require 'lib/spec/test_app'
|
52
|
+
Rack::Handler::WEBrick.run TestApp, :Port => 8070
|
53
|
+
end
|
54
|
+
|
55
|
+
def run_local
|
56
|
+
if(RUBY_PLATFORM == 'java')
|
57
|
+
abort color("This script only works if you are running on MRI ('normal') Ruby....sorry....", :color => :red)
|
58
|
+
end
|
59
|
+
puts color('*********************************************',:color => :green)
|
60
|
+
puts color('* *',:color => :green)
|
61
|
+
puts color('* Cucumber Acceptance Tests *',:color => :green)
|
62
|
+
puts color('* Pre-Requisites: *',:color => :green)
|
63
|
+
puts color('* ruby 1.8.7, bundler, rake *',:color => :green)
|
64
|
+
puts color('* *',:color => :green)
|
65
|
+
puts color('*********************************************',:color => :green)
|
66
|
+
list_profiles
|
67
|
+
puts 'Above is a list of the available profiles, please enter the number of the profile you wish to run: '
|
68
|
+
profile = STDIN.gets.chomp
|
69
|
+
#TODO: Add some input validation?
|
70
|
+
puts "The profile chosen is: #{color(@profiles[profile], :color => :red)}"
|
71
|
+
puts 'Preparing to bundle required gems...'
|
72
|
+
install
|
73
|
+
puts 'Preparing to run tests...'
|
74
|
+
run_profile(@profiles[profile])
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/lib/version.rb
CHANGED
@@ -49,13 +49,13 @@ describe CapybaraSetup do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should require as a minimum ENVIRONMENT and BROWSER" do
|
52
|
-
lambda {CapybaraSetup.new}.should raise_error(RuntimeError,'Please ensure following environment variables are set ENVIRONMENT [int|test|stage|live], BROWSER[headless|ie|chrome|firefox] and
|
52
|
+
lambda {CapybaraSetup.new}.should raise_error(RuntimeError,'Please ensure following environment variables are set ENVIRONMENT [int|test|stage|live], BROWSER[headless|ie|chrome|firefox] and HTTP_PROXY (if required)')
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should require as a minimum ENVIRONMENT, BROWSER and REMOTE_BROWSER if running a Remote Selenium Instance" do
|
56
56
|
ENV['BROWSER'] = 'remote'
|
57
57
|
ENV['ENVIRONMENT'] = 'test'
|
58
|
-
lambda {CapybaraSetup.new}.should raise_error(RuntimeError,'Please ensure the following environment variables are set PLATFORM, REMOTE_URL, REMOTE_BROWSER (browser to use on remote machine),
|
58
|
+
lambda {CapybaraSetup.new}.should raise_error(RuntimeError,'Please ensure the following environment variables are set PLATFORM, REMOTE_URL, REMOTE_BROWSER (browser to use on remote machine), HTTP_PROXY (if required), REMOTE_BROWSER_PROXY (if required) and BROWSER_VERSION (if required)')
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should not error if ENVIRONMENT and BROWSER are provided" do
|
@@ -116,7 +116,7 @@ describe CapybaraSetup do
|
|
116
116
|
before do
|
117
117
|
ENV['BROWSER'] = 'firefox'
|
118
118
|
ENV['FIREFOX_PROFILE'] = 'BBC_INTERNAL'
|
119
|
-
ENV['
|
119
|
+
ENV['HTTP_PROXY'] = 'http://example.cache.co.uk:80'
|
120
120
|
ENV['PROXY_ON'] = 'false'
|
121
121
|
end
|
122
122
|
|
@@ -183,7 +183,7 @@ describe CapybaraSetup do
|
|
183
183
|
ENV['REMOTE_BROWSER'] = 'firefox'
|
184
184
|
ENV['FIREFOX_PROFILE'] = 'default'
|
185
185
|
ENV['REMOTE_URL'] = 'http://example.com'
|
186
|
-
ENV['
|
186
|
+
ENV['HTTP_PROXY'] = 'http://example.cache.co.uk:80'
|
187
187
|
end
|
188
188
|
|
189
189
|
it "should be initialized correctly" do
|
@@ -205,7 +205,7 @@ describe CapybaraSetup do
|
|
205
205
|
ENV['REMOTE_BROWSER'] = 'firefox'
|
206
206
|
ENV['FIREFOX_PROFILE'] = 'BBC_INTERNAL'
|
207
207
|
ENV['REMOTE_URL'] = 'http://example.cache.co.uk:80'
|
208
|
-
ENV['
|
208
|
+
ENV['HTTP_PROXY'] = 'http://example.cache.co.uk:80'
|
209
209
|
ENV['PROXY_ON'] = 'false'
|
210
210
|
end
|
211
211
|
|
@@ -257,6 +257,26 @@ describe CapybaraSetup do
|
|
257
257
|
it_behaves_like "Selenium Driver Options Array"
|
258
258
|
end
|
259
259
|
|
260
|
+
context "with Selenium driver and hardcoded bbc internal profile and additional firefox preferences" do
|
261
|
+
before do
|
262
|
+
ENV['BROWSER'] = 'firefox'
|
263
|
+
ENV['HTTP_PROXY'] = 'http://example.cache.co.uk:80'
|
264
|
+
ENV['FIREFOX_PROFILE'] = 'BBC_INTERNAL'
|
265
|
+
ENV['FIREFOX_PREFS'] = '{"javascript.enabled":false}'
|
266
|
+
end
|
267
|
+
|
268
|
+
it "should be initialized correctly" do
|
269
|
+
Capybara.delete_session
|
270
|
+
CapybaraSetup.new.driver.should == :selenium
|
271
|
+
Capybara.current_session.driver.should be_a_kind_of Capybara::Selenium::Driver
|
272
|
+
Capybara.current_session.driver.options[:browser].should == :firefox
|
273
|
+
Capybara.current_session.driver.options[:profile].should be_a_kind_of Selenium::WebDriver::Firefox::Profile
|
274
|
+
Capybara.current_session.driver.options[:profile].instance_variable_get(:@additional_prefs)['javascript.enabled'].should == false
|
275
|
+
end
|
276
|
+
it_behaves_like "Selenium Driver Options Array"
|
277
|
+
end
|
278
|
+
|
279
|
+
|
260
280
|
context "with Selenium driver and additional firefox preferences" do
|
261
281
|
before do
|
262
282
|
ENV['BROWSER'] = 'firefox'
|
@@ -279,7 +299,6 @@ describe CapybaraSetup do
|
|
279
299
|
context "with Selenium driver and new profile and custom prefs" do
|
280
300
|
before do
|
281
301
|
ENV['BROWSER'] = 'firefox'
|
282
|
-
ENV['CREATE_NEW_FF_PROFILE'] = 'true'
|
283
302
|
ENV['FIREFOX_PREFS'] = '{"javascript.enabled":false}'
|
284
303
|
end
|
285
304
|
|
@@ -366,7 +385,7 @@ describe CapybaraSetup do
|
|
366
385
|
before do
|
367
386
|
ENV['BROWSER'] = 'mechanize'
|
368
387
|
ENV['ENVIRONMENT'] = 'test'
|
369
|
-
ENV['
|
388
|
+
ENV['HTTP_PROXY'] = 'http://example.cache.co.uk:80'
|
370
389
|
end
|
371
390
|
|
372
391
|
it "should be initialized correctly" do
|
@@ -402,7 +421,7 @@ describe CapybaraSetup do
|
|
402
421
|
before do
|
403
422
|
ENV['BROWSER'] = 'headless'
|
404
423
|
ENV['CELERITY_JS_ENABLED'] = 'true'
|
405
|
-
ENV['
|
424
|
+
ENV['HTTP_PROXY'] = 'http://example.cache.co.uk:80'
|
406
425
|
end
|
407
426
|
|
408
427
|
it "should be initialized correctly" do
|
@@ -415,6 +434,20 @@ describe CapybaraSetup do
|
|
415
434
|
Capybara.current_session.driver.options[:browser].should == nil
|
416
435
|
end
|
417
436
|
end
|
437
|
+
|
438
|
+
context "with maximal Celerity driver" do
|
439
|
+
before do
|
440
|
+
ENV['BROWSER'] = 'headless'
|
441
|
+
ENV['CELERITY_JS_ENABLED'] = 'true'
|
442
|
+
ENV['http_proxy'] = 'http://example.cache.co.uk:80'
|
443
|
+
end
|
444
|
+
|
445
|
+
it "should cope with http_proxy and HTTP_PROXY " do
|
446
|
+
Capybara.delete_session
|
447
|
+
Capybara.current_session.driver.options[:proxy].should == 'example.cache.co.uk:80'
|
448
|
+
end
|
449
|
+
end
|
450
|
+
|
418
451
|
end
|
419
452
|
end
|
420
453
|
end
|
@@ -3,6 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Frameworks::EnvHelper do
|
4
4
|
|
5
5
|
before do
|
6
|
+
ENV.clear
|
6
7
|
ENV['BROWSER'] = 'test' #mandatory data to prevent validation exception
|
7
8
|
end
|
8
9
|
|
@@ -75,12 +76,14 @@ describe Frameworks::EnvHelper do
|
|
75
76
|
end
|
76
77
|
|
77
78
|
it "should be able to set proxy host correctly to use in tests using HTTP_PROXY env variable" do
|
79
|
+
ENV['ENVIRONMENT'] = 'foo'
|
78
80
|
ENV['HTTP_PROXY'] = 'http://mycache.co.uk:80'
|
79
81
|
generate_base_urls
|
80
82
|
@proxy_host.should == "mycache.co.uk"
|
81
83
|
end
|
82
84
|
|
83
85
|
it "should be able to set proxy host correctly to use in tests using http_proxy env variable" do
|
86
|
+
ENV['ENVIRONMENT'] = 'foo'
|
84
87
|
ENV['http_proxy'] = 'http://mycache.co.uk:80'
|
85
88
|
generate_base_urls
|
86
89
|
@proxy_host.should == "mycache.co.uk"
|
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: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 6
|
10
|
+
version: 0.2.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- matt robbins
|
@@ -167,16 +167,8 @@ files:
|
|
167
167
|
- lib/monkey-patches/mechanize-patches.rb
|
168
168
|
- lib/monkey-patches/send-keys.rb
|
169
169
|
- lib/monkey-patches/webdriver-patches.rb
|
170
|
-
- lib/tasks/frameworks-tasks.
|
170
|
+
- lib/tasks/frameworks-tasks.rb
|
171
171
|
- lib/version.rb
|
172
|
-
- schemas/xhtml-lat1.ent
|
173
|
-
- schemas/xhtml-rdfa-1.dtd
|
174
|
-
- schemas/xhtml-special.ent
|
175
|
-
- schemas/xhtml-symbol.ent
|
176
|
-
- schemas/xhtml1-strict.dtd
|
177
|
-
- schemas/xhtml1-strict.xsd
|
178
|
-
- schemas/xhtml1-transitional.dtd
|
179
|
-
- schemas/xml.xsd
|
180
172
|
- spec/frameworks_capybara_spec.rb
|
181
173
|
- spec/frameworks_cucumber_spec.rb
|
182
174
|
- spec/mock.default/prefs.js
|
@@ -1,75 +0,0 @@
|
|
1
|
-
INVOKE_CUCUMBER = "bin/cucumber"
|
2
|
-
|
3
|
-
task :install do
|
4
|
-
system('bundle install --no-cache --binstubs --path vendor/bundle')
|
5
|
-
end
|
6
|
-
|
7
|
-
def color(text, options = {})
|
8
|
-
#ANSI color codes
|
9
|
-
case options[:color]
|
10
|
-
when :red
|
11
|
-
text = "\033[31m#{text}\033[0m"
|
12
|
-
when :green
|
13
|
-
text = "\033[32m#{text}\033[0m"
|
14
|
-
when :yellow
|
15
|
-
text = "\033[33m#{text}\033[0m"
|
16
|
-
end
|
17
|
-
text
|
18
|
-
end
|
19
|
-
|
20
|
-
task :list_profiles do
|
21
|
-
puts 'Available profiles:'
|
22
|
-
f = File.open('config/cucumber.yml', 'r')
|
23
|
-
linenum = 0
|
24
|
-
@profiles = {}
|
25
|
-
f.read.each do |line|
|
26
|
-
line.scan(/.*?: /) do |match|
|
27
|
-
linenum += 1
|
28
|
-
puts color(linenum.to_s + '. ', :color => :yellow) + color(match.gsub(':',''), :color => :green)
|
29
|
-
@profiles[linenum.to_s] = match.gsub(':','')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
task :update do
|
35
|
-
system('bundle update')
|
36
|
-
end
|
37
|
-
|
38
|
-
task :run_feature, :feature, :profile do |t, args|
|
39
|
-
args.with_defaults(:profile => 'default')
|
40
|
-
system("#{INVOKE_CUCUMBER} -p #{args[:profile]} features/#{args[:feature]}.feature")
|
41
|
-
end
|
42
|
-
|
43
|
-
task :run_profile, :profile do |t, args|
|
44
|
-
args.with_defaults(:profile => 'default')
|
45
|
-
system("#{INVOKE_CUCUMBER} -p #{args[:profile]}")
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
task :start_app do
|
50
|
-
$: << File.dirname( __FILE__)
|
51
|
-
require 'lib/spec/test_app'
|
52
|
-
Rack::Handler::WEBrick.run TestApp, :Port => 8070
|
53
|
-
end
|
54
|
-
|
55
|
-
task :run_local do
|
56
|
-
if(RUBY_PLATFORM == 'java')
|
57
|
-
abort color("This script only works if you are running on MRI ('normal') Ruby....sorry....", :color => :red)
|
58
|
-
end
|
59
|
-
puts color('*********************************************',:color => :green)
|
60
|
-
puts color('* *',:color => :green)
|
61
|
-
puts color('* Cucumber Acceptance Tests *',:color => :green)
|
62
|
-
puts color('* Pre-Requisites: *',:color => :green)
|
63
|
-
puts color('* ruby 1.8.7, bundler, rake *',:color => :green)
|
64
|
-
puts color('* *',:color => :green)
|
65
|
-
puts color('*********************************************',:color => :green)
|
66
|
-
Rake::Task[:list_profiles].invoke
|
67
|
-
puts 'Above is a list of the available profiles, please enter the number of the profile you wish to run: '
|
68
|
-
profile = STDIN.gets.chomp
|
69
|
-
#TODO: Add some input validation?
|
70
|
-
puts "The profile chosen is: #{color(@profiles[profile], :color => :red)}"
|
71
|
-
puts 'Preparing to bundle required gems...'
|
72
|
-
Rake::Task[:install].invoke
|
73
|
-
puts 'Preparing to run tests...'
|
74
|
-
Rake::Task[:run_profile].invoke(@profiles[profile])
|
75
|
-
end
|