frameworks-capybara 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +35 -1
- data/VERSION +1 -1
- data/frameworks-capybara.gemspec +4 -3
- data/lib/{frameworks-capybara.rb → frameworks/capybara.rb} +10 -6
- data/lib/frameworks/cucumber.rb +28 -0
- metadata +21 -20
data/README.rdoc
CHANGED
@@ -1,6 +1,40 @@
|
|
1
1
|
= frameworks-capybara
|
2
2
|
|
3
|
-
|
3
|
+
Gem to simplify the configuration of Capybara when using multiple drivers, also exposes other useful utility methods.
|
4
|
+
|
5
|
+
Although utilising Capybara's API to run tests is extremely simple the configuration and setup of the tool can be a little confusing, particularly if you want to avoid ending up with a spaghetti like env.rb file
|
6
|
+
|
7
|
+
The principle behind this gem is to factor out all the common setup code for registering Capybara drivers and allow the user to pass all configuration options through Cucumber's command line interface (and typically using cucumber.yml to make this even easier).
|
8
|
+
|
9
|
+
Below are the current drivers that can be registered:
|
10
|
+
|
11
|
+
* Selenium-Webdriver (Selenium2) - LOCAL: This can be used to drive 'in-browser' tests runnong on your local machine in IE, Firefox and Chrome (and any other browsers as and when they are added into the Selenium-Webdriver project)
|
12
|
+
|
13
|
+
|
14
|
+
* Selenium-Webdriver (Selenium2) - REMOTE: This can be used to drive 'in-browser' tests on a remote macine, this could be another macine on your local network which is running a Selenium-Webdriver server or indeed a cloud service such as 'Sauce Labs'
|
15
|
+
|
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
|
+
|
18
|
+
To be added in the near future:
|
19
|
+
|
20
|
+
* Mechanize-Caybara: There is a Caybara driver for mechanize which has recent;y 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.
|
21
|
+
|
22
|
+
How to use this gem in your project:
|
23
|
+
|
24
|
+
In your env.rb simply add:
|
25
|
+
|
26
|
+
require 'frameworks/capybara'
|
27
|
+
|
28
|
+
The following environment variables can be set to configure your tests:
|
29
|
+
|
30
|
+
ENVIRONMENT - this must be one of either 'sandbox', 'int', 'test', 'stage', 'live'
|
31
|
+
BROWSER - this must be one of either 'ie', 'firefox', 'chrome', 'headless', 'remote'
|
32
|
+
PROXY_URL - url of proxy if required e.g. 'http://proxyhost:80'
|
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
|
+
REMOTE_BROWSER_PROXY - used when specifying remote test, sets proxy on remote browser (Firefox only at present, other browsers must have proxies set appropriately on remote machine)
|
36
|
+
REMOTE_URL - URL of remote Selenium-Webdriver server e.g. http://yourremotehost:4444/wd/hub
|
37
|
+
FIREFOX_PROFILE - specify a firefox profile to use when running in-browser tests (local or remote)
|
4
38
|
|
5
39
|
== Contributing to frameworks-capybara
|
6
40
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/frameworks-capybara.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
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.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"]
|
@@ -25,14 +25,15 @@ Gem::Specification.new do |s|
|
|
25
25
|
"Rakefile",
|
26
26
|
"VERSION",
|
27
27
|
"frameworks-capybara.gemspec",
|
28
|
-
"lib/frameworks
|
28
|
+
"lib/frameworks/capybara.rb",
|
29
|
+
"lib/frameworks/cucumber.rb",
|
29
30
|
"test/helper.rb",
|
30
31
|
"test/test_frameworks-capybara.rb"
|
31
32
|
]
|
32
33
|
s.homepage = %q{http://github.com/mcrmfc/frameworks-capybara}
|
33
34
|
s.licenses = ["MIT"]
|
34
35
|
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = %q{1.
|
36
|
+
s.rubygems_version = %q{1.4.2}
|
36
37
|
s.summary = %q{gem to aid setup of Capybara for testing bbc sites}
|
37
38
|
s.test_files = [
|
38
39
|
"test/helper.rb",
|
@@ -15,9 +15,9 @@ class CapybaraSetup
|
|
15
15
|
when 'headless' then
|
16
16
|
@driver = register_celerity_driver(false,ENV['PROXY_URL'])
|
17
17
|
when 'remote' then
|
18
|
-
@driver = register_remote_driver(ENV['PROXY_URL'], ENV['REMOTE_BROWSER_PROXY'], ENV['PLATFORM'],ENV['
|
18
|
+
@driver = register_remote_driver(ENV['PROXY_URL'], ENV['REMOTE_BROWSER_PROXY'], ENV['PLATFORM'],ENV['REMOTE_BROWSER'],ENV['REMOTE_URL'], ENV['FIREFOX_PROFILE'])
|
19
19
|
else
|
20
|
-
@driver = register_selenium_driver
|
20
|
+
@driver = register_selenium_driver(ENV['BROWSER'], ENV['FIREFOX_PROFILE'])
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -35,10 +35,10 @@ class CapybaraSetup
|
|
35
35
|
|
36
36
|
#if running remote test check for correct env variables
|
37
37
|
if(ENV['BROWSER']=='remote')
|
38
|
-
env_vars_remote = [ENV['PLATFORM'],ENV['REMOTE_URL'], ENV['
|
38
|
+
env_vars_remote = [ENV['PLATFORM'],ENV['REMOTE_URL'], ENV['REMOTE_BROWSER']]
|
39
39
|
env_vars_remote.each{ |var|
|
40
40
|
if(var==nil)
|
41
|
-
abort 'Please ensure the following environment variables are set PLATFORM, REMOTE_URL,
|
41
|
+
abort 'Please ensure the following environment variables are set PLATFORM, REMOTE_URL, REMOTE_BROWSER (browser to use on remote machine), PROXY_URL (if required) and REMOTE_BROWSER_PROXY (if required)'
|
42
42
|
end
|
43
43
|
}
|
44
44
|
end
|
@@ -68,15 +68,19 @@ class CapybaraSetup
|
|
68
68
|
|
69
69
|
def register_celerity_driver (js_enabled, proxy)
|
70
70
|
Capybara.register_driver :celerity do |app|
|
71
|
+
#remove http:// from proxy URL for Celerity
|
72
|
+
if(proxy)
|
73
|
+
proxy = proxy.gsub(/http:\/\//,'')
|
74
|
+
end
|
71
75
|
Capybara::Driver::Celerity.new(app, {:javascript_enabled=>js_enabled,:proxy=>proxy})
|
72
76
|
end
|
73
77
|
:celerity
|
74
78
|
end
|
75
79
|
|
76
|
-
def register_selenium_driver
|
80
|
+
def register_selenium_driver (browser, ff_profile)
|
77
81
|
Capybara.register_driver :selenium do |app|
|
78
82
|
#need to convert string to label to set browser for Selenium - hence .intern
|
79
|
-
Capybara::Driver::Selenium.new(app,:browser =>
|
83
|
+
Capybara::Driver::Selenium.new(app,:browser => browser.intern, :profile => ff_profile)
|
80
84
|
end
|
81
85
|
:selenium
|
82
86
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'frameworks/capybara'
|
2
|
+
|
3
|
+
module Frameworks
|
4
|
+
module EnvHelper
|
5
|
+
WWW_PREFIX = 'http://www.'
|
6
|
+
BBC_DOMAIN = '.bbc.co.uk'
|
7
|
+
SANDBOX = 'http://pal.sandbox.dev'
|
8
|
+
|
9
|
+
def generate_base_url
|
10
|
+
if(ENV['ENVIRONMENT']=='sandbox')
|
11
|
+
@base_url = SANDBOX + BBC_DOMAIN
|
12
|
+
else
|
13
|
+
@base_url = WWW_PREFIX + ENV['ENVIRONMENT'] + BBC_DOMAIN
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
#Set Capybara Driver - using frameworks-capybara gem
|
21
|
+
Capybara.default_driver = CapybaraSetup.new.driver
|
22
|
+
|
23
|
+
World(Frameworks::EnvHelper)
|
24
|
+
|
25
|
+
Before do
|
26
|
+
generate_base_url
|
27
|
+
end
|
28
|
+
|
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
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- mcrmfc
|
@@ -20,7 +20,7 @@ default_executable:
|
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
type: :development
|
23
|
-
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
25
25
|
requirements:
|
26
26
|
- - ">="
|
@@ -29,12 +29,12 @@ dependencies:
|
|
29
29
|
segments:
|
30
30
|
- 0
|
31
31
|
version: "0"
|
32
|
-
|
33
|
-
name: shoulda
|
32
|
+
requirement: *id001
|
34
33
|
prerelease: false
|
34
|
+
name: shoulda
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
type: :development
|
37
|
-
|
37
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
38
|
none: false
|
39
39
|
requirements:
|
40
40
|
- - ~>
|
@@ -45,12 +45,12 @@ dependencies:
|
|
45
45
|
- 0
|
46
46
|
- 0
|
47
47
|
version: 1.0.0
|
48
|
-
|
49
|
-
name: bundler
|
48
|
+
requirement: *id002
|
50
49
|
prerelease: false
|
50
|
+
name: bundler
|
51
51
|
- !ruby/object:Gem::Dependency
|
52
52
|
type: :development
|
53
|
-
|
53
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
54
54
|
none: false
|
55
55
|
requirements:
|
56
56
|
- - ~>
|
@@ -61,12 +61,12 @@ dependencies:
|
|
61
61
|
- 5
|
62
62
|
- 2
|
63
63
|
version: 1.5.2
|
64
|
-
|
65
|
-
name: jeweler
|
64
|
+
requirement: *id003
|
66
65
|
prerelease: false
|
66
|
+
name: jeweler
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
type: :development
|
69
|
-
|
69
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
70
70
|
none: false
|
71
71
|
requirements:
|
72
72
|
- - ">="
|
@@ -75,12 +75,12 @@ dependencies:
|
|
75
75
|
segments:
|
76
76
|
- 0
|
77
77
|
version: "0"
|
78
|
-
|
79
|
-
name: rcov
|
78
|
+
requirement: *id004
|
80
79
|
prerelease: false
|
80
|
+
name: rcov
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
type: :runtime
|
83
|
-
|
83
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ">="
|
@@ -89,9 +89,9 @@ dependencies:
|
|
89
89
|
segments:
|
90
90
|
- 0
|
91
91
|
version: "0"
|
92
|
-
|
93
|
-
name: capybara
|
92
|
+
requirement: *id005
|
94
93
|
prerelease: false
|
94
|
+
name: capybara
|
95
95
|
description: gem ti aid setup of Capybara for testing bbc sites
|
96
96
|
email: mcrobbins@gmail.com
|
97
97
|
executables: []
|
@@ -110,7 +110,8 @@ files:
|
|
110
110
|
- Rakefile
|
111
111
|
- VERSION
|
112
112
|
- frameworks-capybara.gemspec
|
113
|
-
- lib/frameworks
|
113
|
+
- lib/frameworks/capybara.rb
|
114
|
+
- lib/frameworks/cucumber.rb
|
114
115
|
- test/helper.rb
|
115
116
|
- test/test_frameworks-capybara.rb
|
116
117
|
has_rdoc: true
|
@@ -143,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
144
|
requirements: []
|
144
145
|
|
145
146
|
rubyforge_project:
|
146
|
-
rubygems_version: 1.
|
147
|
+
rubygems_version: 1.4.2
|
147
148
|
signing_key:
|
148
149
|
specification_version: 3
|
149
150
|
summary: gem to aid setup of Capybara for testing bbc sites
|