frameworks-capybara 0.0.32 → 0.0.33
Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc
CHANGED
@@ -15,9 +15,7 @@ Below are the current drivers that can be registered:
|
|
15
15
|
|
16
16
|
* Celerity: This can be used to drive 'headless' tests. Celerity is a ruby wrapper for HTMLUnit and as such provides support for Javascript, though this is commonly quite fragile.
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
* Mechanize-Caybara: There is a Caybara driver for mechanize which has recently surfaced on Github. Many people still enjoy using Mechanize as despite its lack of support for Javascrit, it offers a much faster 'headless' option over Celerity. Once we have tested this driver and checked its robustness we will add an option to use it via this gem.
|
18
|
+
* Mechanize-Caybara: This can be used, by setting BROWSER=mechanize
|
21
19
|
|
22
20
|
How to use this gem in your project:
|
23
21
|
|
@@ -37,6 +35,7 @@ The following environment variables can be set to configure your tests:
|
|
37
35
|
REMOTE_URL - URL of remote Selenium-Webdriver server e.g. http://yourremotehost:4444/wd/hub
|
38
36
|
FIREFOX_PROFILE - specify a firefox profile to use when running in-browser tests (local or remote)
|
39
37
|
CELERITY_JS_ENABLED (string - 'true', 'false') - determines whether Celerity (HTMLUnit) attempts to execute javascript
|
38
|
+
XVFB - (string - 'true', 'false') - determines whether XVFB is used to run browser (i.e. headless Firefox on *nix platform)
|
40
39
|
|
41
40
|
Here is a sample cucumber.yml:
|
42
41
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.33
|
data/frameworks-capybara.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{frameworks-capybara}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.33"
|
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-
|
12
|
+
s.date = %q{2011-08-16}
|
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 = [
|
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
"lib/monkey-patches/capybara-mechanize-patches.rb",
|
32
32
|
"lib/monkey-patches/capybara-patches.rb",
|
33
33
|
"lib/monkey-patches/cucumber-patches.rb",
|
34
|
+
"lib/monkey-patches/mechanize-patches.rb",
|
34
35
|
"lib/monkey-patches/send-keys.rb",
|
35
36
|
"lib/monkey-patches/webdriver-patches.rb",
|
36
37
|
"test/helper.rb",
|
data/lib/frameworks/capybara.rb
CHANGED
@@ -2,6 +2,7 @@ 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/mechanize-patches'
|
5
6
|
require 'monkey-patches/send-keys'
|
6
7
|
require 'selenium-webdriver'
|
7
8
|
require 'capybara/mechanize/cucumber'
|
@@ -16,7 +17,7 @@ class CapybaraSetup
|
|
16
17
|
|
17
18
|
def initialize
|
18
19
|
|
19
|
-
capybara_opts = {:environment => ENV['ENVIRONMENT'], :proxy => ENV['PROXY_URL'], :remote_browser_proxy_url => ENV['REMOTE_BROWSER_PROXY_URL'], :platform => ENV['PLATFORM'], :browser_name => ENV['REMOTE_BROWSER'], :version => ENV['REMOTE_BROWSER_VERSION'], :url => ENV['REMOTE_URL'], :profile => ENV['FIREFOX_PROFILE'], :browser => ENV['BROWSER'], :javascript_enabled => ENV['CELERITY_JS_ENABLED'], :job_name => ENV['SAUCE_JOB_NAME'], :max_duration => ENV['SAUCE_MAX_DURATION']}
|
20
|
+
capybara_opts = {:environment => ENV['ENVIRONMENT'], :proxy => ENV['PROXY_URL'], :remote_browser_proxy_url => ENV['REMOTE_BROWSER_PROXY_URL'], :platform => ENV['PLATFORM'], :browser_name => ENV['REMOTE_BROWSER'], :version => ENV['REMOTE_BROWSER_VERSION'], :url => ENV['REMOTE_URL'], :profile => ENV['FIREFOX_PROFILE'], :browser => ENV['BROWSER'], :javascript_enabled => ENV['CELERITY_JS_ENABLED'], :job_name => ENV['SAUCE_JOB_NAME'], :max_duration => ENV['SAUCE_MAX_DURATION'], :proxy_on => ENV['PROXY_ON']}
|
20
21
|
|
21
22
|
validate_env_vars(capybara_opts) #validate environment variables set using cucumber.yml or passed via command line
|
22
23
|
|
@@ -82,11 +83,11 @@ class CapybaraSetup
|
|
82
83
|
if opts[:browser] == :remote
|
83
84
|
client = Selenium::WebDriver::Remote::Http::Default.new
|
84
85
|
|
85
|
-
#set proxy on client connection if required
|
86
|
-
if opts[:proxy]
|
86
|
+
#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
|
87
|
+
if opts[:proxy] && opts[:proxy_on] != 'false'
|
87
88
|
client.proxy = Selenium::WebDriver::Proxy.new(:http => opts[:proxy])
|
88
|
-
opts.delete :proxy
|
89
89
|
end
|
90
|
+
opts.delete_if {|k,v| [:proxy, :proxy_on].include? k}
|
90
91
|
|
91
92
|
#TODO: temp workaround - needs refactoring
|
92
93
|
cap_opts = opts.clone
|
@@ -100,7 +101,7 @@ class CapybaraSetup
|
|
100
101
|
opts[:desired_capabilities] = caps
|
101
102
|
opts[:http_client] = client
|
102
103
|
else
|
103
|
-
opts.delete_if {|k,v| [:proxy].include? k} #may want to pass env variables that are not relevant for in browser 'non-remote' tests e.g. proxy, so delete these before setting up driver
|
104
|
+
opts.delete_if {|k,v| [:proxy, :proxy_on].include? k} #may want to pass env variables that are not relevant for in browser 'non-remote' tests e.g. proxy, so delete these before setting up driver
|
104
105
|
end
|
105
106
|
Capybara::Driver::Selenium.new(app,opts)
|
106
107
|
end
|
data/lib/frameworks/cucumber.rb
CHANGED
@@ -2,7 +2,7 @@ require 'frameworks/capybara'
|
|
2
2
|
require 'monkey-patches/cucumber-patches'
|
3
3
|
|
4
4
|
if(ENV['XVFB']=='true')
|
5
|
-
puts "You have
|
5
|
+
puts "You have chosen to use XVFB - ensure you have yum installed Xvfb Xorg and firefox"
|
6
6
|
require 'headless'
|
7
7
|
headless = Headless.new
|
8
8
|
headless.start
|
@@ -14,13 +14,15 @@ end
|
|
14
14
|
module Frameworks
|
15
15
|
module EnvHelper
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
ENV['SCHEME']=='https' ? scheme = 'https' : scheme = 'http'
|
18
|
+
|
19
|
+
WWW_PREFIX = "#{scheme}://www."
|
20
|
+
STATIC_PREFIX = "#{scheme}://static."
|
21
|
+
OPEN_PREFIX = "#{scheme}://open."
|
20
22
|
BBC_DOMAIN = '.bbc.co.uk'
|
21
23
|
STATIC_BBC_DOMAIN = '.bbc.co.uk'
|
22
|
-
SANDBOX =
|
23
|
-
STATIC_SANDBOX =
|
24
|
+
SANDBOX = "#{scheme}://pal.sandbox.dev"
|
25
|
+
STATIC_SANDBOX = "#{scheme}://static.sandbox.dev"
|
24
26
|
|
25
27
|
#Generate base urls to use in Cucumber step defs
|
26
28
|
def generate_base_urls
|
@@ -32,7 +34,7 @@ module Frameworks
|
|
32
34
|
@static_base_url = STATIC_PREFIX + BBC_DOMAIN
|
33
35
|
@open_base_url = OPEN_PREFIX + BBC_DOMAIN
|
34
36
|
elsif (ENV['ENVIRONMENT'].split('.')[0].include? 'pal') #address specific box
|
35
|
-
@base_url = "
|
37
|
+
@base_url = "#{scheme}://#{ENV['ENVIRONMENT']}"
|
36
38
|
else
|
37
39
|
@base_url = WWW_PREFIX + ENV['ENVIRONMENT'] + BBC_DOMAIN
|
38
40
|
@static_base_url = STATIC_PREFIX + ENV['ENVIRONMENT'] + BBC_DOMAIN
|
@@ -1,12 +1,16 @@
|
|
1
1
|
require 'capybara/mechanize/cucumber'
|
2
|
+
require 'uri'
|
2
3
|
|
3
4
|
class Capybara::Driver::Mechanize
|
4
5
|
def process_remote_request(method, url, *options)
|
5
6
|
if remote?(url)
|
6
7
|
remote_uri = URI.parse(url)
|
8
|
+
|
9
|
+
@scheme = remote_uri.scheme if remote_uri.scheme
|
10
|
+
|
7
11
|
if remote_uri.host.nil?
|
8
12
|
#TODO: Ascertain whether this is really true...
|
9
|
-
if(method == :post && @prev_url) #patch
|
13
|
+
if(method == :post && url == "" && @prev_url) #patch
|
10
14
|
#require 'uri'
|
11
15
|
#url = "http://#{URI.parse(@prev_url).host}#{URI.parse(@prev_url).path}"
|
12
16
|
#p url
|
@@ -14,7 +18,8 @@ class Capybara::Driver::Mechanize
|
|
14
18
|
else
|
15
19
|
remote_host = @last_remote_host || Capybara.app_host || Capybara.default_host
|
16
20
|
url = File.join(remote_host, url)
|
17
|
-
url = "http://#{url}" unless url.include?("http")
|
21
|
+
#url = "http://#{url}" unless url.include?("http")
|
22
|
+
url = "#{@scheme}://#{url}" unless url.match(/^http.*/)
|
18
23
|
end
|
19
24
|
else
|
20
25
|
@last_remote_host = "#{remote_uri.host}:#{remote_uri.port}"
|
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: 93
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 33
|
10
|
+
version: 0.0.33
|
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-
|
18
|
+
date: 2011-08-16 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- lib/monkey-patches/capybara-mechanize-patches.rb
|
145
145
|
- lib/monkey-patches/capybara-patches.rb
|
146
146
|
- lib/monkey-patches/cucumber-patches.rb
|
147
|
+
- lib/monkey-patches/mechanize-patches.rb
|
147
148
|
- lib/monkey-patches/send-keys.rb
|
148
149
|
- lib/monkey-patches/webdriver-patches.rb
|
149
150
|
- test/helper.rb
|