acceptance_test 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +18 -0
- data/.idea/misc.xml +5 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CHANGES +5 -0
- data/Gemfile +36 -0
- data/Gemfile.lock +88 -0
- data/LICENSE +22 -0
- data/README.md +78 -0
- data/Rakefile +43 -0
- data/acceptance_test.gemspec +23 -0
- data/acceptance_test.gemspec.erb +20 -0
- data/lib/acceptance_test/acceptance_shared_context.rb +17 -0
- data/lib/acceptance_test/acceptance_test.rb +245 -0
- data/lib/acceptance_test/version.rb +3 -0
- data/lib/acceptance_test.rb +3 -0
- data/spec/features/features_spec_helper.rb +3 -0
- data/spec/features/google_search_spec.rb +52 -0
- data/spec/features/selenium.yml +15 -0
- data/spec/features/with_selenium_conf_spec.rb +17 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZDk2YzcyMGIwNmMwYWE5MzkzMjk5MDdlOTM3YzFjYzQyZTNmYjg5ZA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NWQ5Zjk2ZGY1MmViNmQxMDM4YmMyOThmYTgwMmM2NmI1NTFiMzBjOQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MGM4N2FjNWM2OWEwNjNhNzBlMWVmMzRlNzIyNjEzODM0MWQ1NDg2YjQyYjIw
|
10
|
+
MGU0OTlhYmI5MjFiMWM3NzM0NDc2ODc0NzE0OTdlMTIwMjFjNDAyYWEwMWYz
|
11
|
+
NTI5YTc1NDM1MTdlZThmOGY5OGFmM2Y5Mzk5MzY1MDJkZDQwMmQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NWI4ZDZjOGRiOGIzNjgzM2VhYTNlMjg5NWMzYzUzYmM1NThlNGI5YzdmMzgz
|
14
|
+
MDU2MzRiOGY3ZDI3NTkzODdkNzYxOTRlOTc4MmE1NTJkYTMzNzJkNWI2ZjNl
|
15
|
+
YTgxOTVkN2NkMzNhNWEzMTUxZDY2MzdiMWJhZjY0N2JjODgwY2M=
|
data/.gitignore
ADDED
data/.idea/misc.xml
ADDED
data/.idea/vcs.xml
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
acceptance_test
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-1.9.3
|
data/CHANGES
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
group :development do
|
4
|
+
gem "gemspec_deps_gen"
|
5
|
+
gem "gemcutter"
|
6
|
+
end
|
7
|
+
|
8
|
+
group :test do
|
9
|
+
gem "mocha", :require => false
|
10
|
+
gem "rspec"
|
11
|
+
end
|
12
|
+
|
13
|
+
group :acceptance_test do
|
14
|
+
gem "activesupport", "~>3.2.14"
|
15
|
+
gem "capybara", "2.1.0"
|
16
|
+
gem "capybara-firebug"
|
17
|
+
|
18
|
+
gem "selenium-webdriver"
|
19
|
+
|
20
|
+
gem "capybara-webkit", "1.0.0"
|
21
|
+
# Note: You need to install qt:
|
22
|
+
# Mac: brew install qt
|
23
|
+
# Ubuntu: sudo apt-get install libqt4-dev libqtwebkit-dev
|
24
|
+
# Debian: sudo apt-get install libqt4-dev
|
25
|
+
# Fedora: yum install qt-webkit-devell
|
26
|
+
|
27
|
+
# brew install phantomjs
|
28
|
+
gem "poltergeist"
|
29
|
+
end
|
30
|
+
|
31
|
+
group :debug do
|
32
|
+
gem "debugger-ruby_core_source"
|
33
|
+
gem "ruby-debug-base19x", "0.11.30.pre12"
|
34
|
+
gem "ruby-debug-ide", "0.4.17"
|
35
|
+
end
|
36
|
+
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (3.2.14)
|
5
|
+
i18n (~> 0.6, >= 0.6.4)
|
6
|
+
multi_json (~> 1.0)
|
7
|
+
capybara (2.1.0)
|
8
|
+
mime-types (>= 1.16)
|
9
|
+
nokogiri (>= 1.3.3)
|
10
|
+
rack (>= 1.0.0)
|
11
|
+
rack-test (>= 0.5.4)
|
12
|
+
xpath (~> 2.0)
|
13
|
+
capybara-firebug (1.3.0)
|
14
|
+
capybara (>= 1.0, < 3.0)
|
15
|
+
capybara-webkit (1.0.0)
|
16
|
+
capybara (~> 2.0, >= 2.0.2)
|
17
|
+
json
|
18
|
+
childprocess (0.3.9)
|
19
|
+
ffi (~> 1.0, >= 1.0.11)
|
20
|
+
cliver (0.2.1)
|
21
|
+
debugger-ruby_core_source (1.2.3)
|
22
|
+
diff-lcs (1.2.4)
|
23
|
+
ffi (1.9.0)
|
24
|
+
file_utils (1.0.7)
|
25
|
+
gemcutter (0.7.1)
|
26
|
+
gemspec_deps_gen (1.1.2)
|
27
|
+
bundler
|
28
|
+
file_utils
|
29
|
+
i18n (0.6.5)
|
30
|
+
json (1.8.0)
|
31
|
+
metaclass (0.0.1)
|
32
|
+
mime-types (1.25)
|
33
|
+
mini_portile (0.5.1)
|
34
|
+
mocha (0.14.0)
|
35
|
+
metaclass (~> 0.0.1)
|
36
|
+
multi_json (1.8.0)
|
37
|
+
nokogiri (1.6.0)
|
38
|
+
mini_portile (~> 0.5.0)
|
39
|
+
poltergeist (1.4.1)
|
40
|
+
capybara (~> 2.1.0)
|
41
|
+
cliver (~> 0.2.1)
|
42
|
+
multi_json (~> 1.0)
|
43
|
+
websocket-driver (>= 0.2.0)
|
44
|
+
rack (1.5.2)
|
45
|
+
rack-test (0.6.2)
|
46
|
+
rack (>= 1.0)
|
47
|
+
rake (10.1.0)
|
48
|
+
rspec (2.14.1)
|
49
|
+
rspec-core (~> 2.14.0)
|
50
|
+
rspec-expectations (~> 2.14.0)
|
51
|
+
rspec-mocks (~> 2.14.0)
|
52
|
+
rspec-core (2.14.5)
|
53
|
+
rspec-expectations (2.14.2)
|
54
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
55
|
+
rspec-mocks (2.14.3)
|
56
|
+
ruby-debug-base19x (0.11.30.pre12)
|
57
|
+
debugger-ruby_core_source (>= 1.1.4)
|
58
|
+
rake (>= 0.8.1)
|
59
|
+
ruby-debug-ide (0.4.17)
|
60
|
+
rake (>= 0.8.1)
|
61
|
+
rubyzip (0.9.9)
|
62
|
+
selenium-webdriver (2.35.1)
|
63
|
+
childprocess (>= 0.2.5)
|
64
|
+
multi_json (~> 1.0)
|
65
|
+
rubyzip (< 1.0.0)
|
66
|
+
websocket (~> 1.0.4)
|
67
|
+
websocket (1.0.7)
|
68
|
+
websocket-driver (0.3.0)
|
69
|
+
xpath (2.0.0)
|
70
|
+
nokogiri (~> 1.3)
|
71
|
+
|
72
|
+
PLATFORMS
|
73
|
+
ruby
|
74
|
+
|
75
|
+
DEPENDENCIES
|
76
|
+
activesupport (~> 3.2.14)
|
77
|
+
capybara (= 2.1.0)
|
78
|
+
capybara-firebug
|
79
|
+
capybara-webkit (= 1.0.0)
|
80
|
+
debugger-ruby_core_source
|
81
|
+
gemcutter
|
82
|
+
gemspec_deps_gen
|
83
|
+
mocha
|
84
|
+
poltergeist
|
85
|
+
rspec
|
86
|
+
ruby-debug-base19x (= 0.11.30.pre12)
|
87
|
+
ruby-debug-ide (= 0.4.17)
|
88
|
+
selenium-webdriver
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Alexander Shvets
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# AcceptanceTest - This gem simplifies configuration and run of acceptance tests
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to to your Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem "acceptance_test"
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
```bash
|
14
|
+
$ bundle
|
15
|
+
```
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
# Without selenium configuration
|
20
|
+
|
21
|
+
Your spec class:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'acceptance_test'
|
25
|
+
|
26
|
+
describe 'Google Search' do
|
27
|
+
|
28
|
+
include_context "AcceptanceTest"
|
29
|
+
|
30
|
+
before :all do
|
31
|
+
acceptance_test.app_host = "http://www.google.com"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "uses selenium driver", driver: :selenium, exclude: false do
|
35
|
+
visit('/')
|
36
|
+
|
37
|
+
fill_in "q", :with => "Capybara"
|
38
|
+
|
39
|
+
#save_and_open_page
|
40
|
+
|
41
|
+
find("#gbqfbw button").click
|
42
|
+
|
43
|
+
all(:xpath, "//li[@class='g']/h3/a").each { |a| puts a[:href] }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
# With selenium configuration
|
49
|
+
|
50
|
+
Your spec class:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
require 'acceptance_test'
|
54
|
+
|
55
|
+
describe 'Google Search' do
|
56
|
+
|
57
|
+
include_context "AcceptanceTest"
|
58
|
+
|
59
|
+
before :all do
|
60
|
+
selenium_config_file = "spec/features/selenium.yml"
|
61
|
+
selenium_config_name = "test"
|
62
|
+
|
63
|
+
acceptance_test.load_selenium_config selenium_config_file, selenium_config_name
|
64
|
+
end
|
65
|
+
|
66
|
+
it "do something" do
|
67
|
+
# ...
|
68
|
+
end
|
69
|
+
end
|
70
|
+
```
|
71
|
+
|
72
|
+
## Contributing
|
73
|
+
|
74
|
+
1. Fork it
|
75
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
76
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
77
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
78
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.expand_path("lib", File.dirname(__FILE__))
|
4
|
+
|
5
|
+
require "rspec/core/rake_task"
|
6
|
+
require "acceptance_test/version"
|
7
|
+
require "gemspec_deps_gen/gemspec_deps_gen"
|
8
|
+
|
9
|
+
version = AcceptanceTest::VERSION
|
10
|
+
project_name = File.basename(Dir.pwd)
|
11
|
+
|
12
|
+
task :gen do
|
13
|
+
generator = GemspecDepsGen.new
|
14
|
+
|
15
|
+
generator.generate_dependencies "spec", "#{project_name}.gemspec.erb", "#{project_name}.gemspec"
|
16
|
+
end
|
17
|
+
|
18
|
+
task :build => :gen do
|
19
|
+
system "gem build #{project_name}.gemspec"
|
20
|
+
end
|
21
|
+
|
22
|
+
task :install do
|
23
|
+
system "gem install #{project_name}-#{version}.gem"
|
24
|
+
end
|
25
|
+
|
26
|
+
task :uninstall do
|
27
|
+
system "gem uninstall #{project_name}"
|
28
|
+
end
|
29
|
+
|
30
|
+
task :release => :build do
|
31
|
+
system "gem push #{project_name}-#{version}.gem"
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new do |task|
|
35
|
+
task.pattern = 'spec/**/*_spec.rb'
|
36
|
+
task.verbose = false
|
37
|
+
end
|
38
|
+
|
39
|
+
task :fix_debug do
|
40
|
+
system "mkdir -p $GEM_HOME/gems/debugger-ruby_core_source-1.2.3/lib"
|
41
|
+
system "cp -R ~/debugger-ruby_core_source/lib $GEM_HOME/gems/debugger-ruby_core_source-1.2.3"
|
42
|
+
end
|
43
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/lib/acceptance_test/version')
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "acceptance_test"
|
7
|
+
spec.summary = %q{Simplifies congiguration and run of acceptance tests.}
|
8
|
+
spec.description = %q{Description: simplifies congiguration and run of acceptance tests.}
|
9
|
+
spec.email = "alexander.shvets@gmail.com"
|
10
|
+
spec.authors = ["Alexander Shvets"]
|
11
|
+
spec.homepage = "http://github.com/shvets/acceptance_test"
|
12
|
+
|
13
|
+
spec.files = `git ls-files`.split($\)
|
14
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
spec.version = AcceptanceTest::VERSION
|
17
|
+
|
18
|
+
|
19
|
+
spec.add_development_dependency "gemspec_deps_gen", [">= 0"]
|
20
|
+
spec.add_development_dependency "gemcutter", [">= 0"]
|
21
|
+
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/lib/acceptance_test/version')
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "acceptance_test"
|
7
|
+
spec.summary = %q{Simplifies congiguration and run of acceptance tests.}
|
8
|
+
spec.description = %q{Description: simplifies congiguration and run of acceptance tests.}
|
9
|
+
spec.email = "alexander.shvets@gmail.com"
|
10
|
+
spec.authors = ["Alexander Shvets"]
|
11
|
+
spec.homepage = "http://github.com/shvets/acceptance_test"
|
12
|
+
|
13
|
+
spec.files = `git ls-files`.split($\)
|
14
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
spec.version = AcceptanceTest::VERSION
|
17
|
+
|
18
|
+
<%= project_dependencies %>
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
shared_context "AcceptanceTest" do
|
2
|
+
|
3
|
+
attr_reader :acceptance_test
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
@acceptance_test = AcceptanceTest.new
|
7
|
+
end
|
8
|
+
|
9
|
+
before do
|
10
|
+
@acceptance_test.before self
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
@acceptance_test.after self
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,245 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'capybara'
|
3
|
+
|
4
|
+
require 'yaml'
|
5
|
+
require 'active_support/hash_with_indifferent_access'
|
6
|
+
|
7
|
+
class AcceptanceTest
|
8
|
+
attr_accessor :app_host
|
9
|
+
|
10
|
+
def initialize project_root="."
|
11
|
+
@project_root = project_root
|
12
|
+
#@selenium_config = selenium_config
|
13
|
+
|
14
|
+
@app_host = default_app_host
|
15
|
+
|
16
|
+
set_defaults
|
17
|
+
|
18
|
+
configure
|
19
|
+
end
|
20
|
+
|
21
|
+
def before context
|
22
|
+
driver = driver(context)
|
23
|
+
|
24
|
+
if driver
|
25
|
+
register_driver driver
|
26
|
+
|
27
|
+
select_driver driver
|
28
|
+
|
29
|
+
if driver.to_s =~ /selenium/
|
30
|
+
puts "\nSelenium Configuration: #{@selenium_config[:name]}"
|
31
|
+
puts "Environment: #{@selenium_config[:env]}"
|
32
|
+
puts "Application: #{@selenium_config[:webapp_url]}"
|
33
|
+
puts "Selenium: #{@selenium_config[:selenium_host]}:#{@selenium_config[:selenium_port]}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
setup_app_host app_host
|
38
|
+
end
|
39
|
+
|
40
|
+
def after context
|
41
|
+
context.reset_session!
|
42
|
+
|
43
|
+
if context.example.exception
|
44
|
+
driver = driver(context)
|
45
|
+
|
46
|
+
if driver and not [:webkit].include? driver
|
47
|
+
save_screenshot context.example, context.page
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
Capybara.current_driver = Capybara.default_driver
|
52
|
+
end
|
53
|
+
|
54
|
+
def load_selenium_config file_name, config_name
|
55
|
+
@selenium_config = HashWithIndifferentAccess.new YAML.load_file(file_name)[config_name]
|
56
|
+
|
57
|
+
@selenium_config[:name] = config_name
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def default_app_host
|
63
|
+
"http://#{self.class.get_localhost}:3000"
|
64
|
+
end
|
65
|
+
|
66
|
+
def set_defaults
|
67
|
+
ENV['APP_HOST'] ||= app_host
|
68
|
+
#ENV['DRIVER'] ||= "webkit"
|
69
|
+
ENV['WAIT_TIME'] ||= "60"
|
70
|
+
end
|
71
|
+
|
72
|
+
def configure
|
73
|
+
#require 'rspec/rails'
|
74
|
+
#require "capybara/rails"
|
75
|
+
|
76
|
+
#require 'rspec/autorun'
|
77
|
+
|
78
|
+
require "capybara"
|
79
|
+
require "capybara/dsl"
|
80
|
+
require 'capybara/rspec'
|
81
|
+
|
82
|
+
RSpec.configure do |config|
|
83
|
+
config.filter_run_excluding :exclude => true
|
84
|
+
end
|
85
|
+
|
86
|
+
RSpec.configure do |config|
|
87
|
+
config.include Capybara::DSL
|
88
|
+
end
|
89
|
+
|
90
|
+
RSpec::Core::ExampleGroup.send :include, Capybara::DSL
|
91
|
+
|
92
|
+
Capybara.configure do |config|
|
93
|
+
config.default_wait_time = ENV['WAIT_TIME'].to_i
|
94
|
+
config.run_server = (ENV['RUN_SERVER'] == "true")
|
95
|
+
|
96
|
+
#config.always_include_port = false
|
97
|
+
#config.server {|app, port| Capybara.run_default_server(app, port)}
|
98
|
+
#config.default_selector = :css
|
99
|
+
#config.ignore_hidden_elements = false
|
100
|
+
#config.default_host = "http://www.example.com"
|
101
|
+
#config.automatic_reload = true
|
102
|
+
end
|
103
|
+
|
104
|
+
#Capybara.configure do |config|
|
105
|
+
# config.match = :one
|
106
|
+
# config.exact_options = true
|
107
|
+
# config.ignore_hidden_elements = true
|
108
|
+
# config.visible_text_only = true
|
109
|
+
#end
|
110
|
+
#
|
111
|
+
end
|
112
|
+
|
113
|
+
def register_driver driver
|
114
|
+
case driver
|
115
|
+
when :webkit
|
116
|
+
require "capybara-webkit"
|
117
|
+
|
118
|
+
when :selenium
|
119
|
+
# nothing
|
120
|
+
|
121
|
+
when :selenium_with_firebug
|
122
|
+
require 'capybara/firebug'
|
123
|
+
|
124
|
+
#Capybara.register_driver :selenium_with_firebug do |app|
|
125
|
+
# profile = Selenium::WebDriver::Firefox::Profile.new
|
126
|
+
# profile.enable_firebug
|
127
|
+
# Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile)
|
128
|
+
#end
|
129
|
+
|
130
|
+
#Selenium::WebDriver::Firefox::Profile.firebug_version = '1.11.2'
|
131
|
+
when :selenium_chrome
|
132
|
+
unless Capybara.drivers[:selenium_chrome]
|
133
|
+
Capybara.register_driver :selenium_chrome do |app|
|
134
|
+
Capybara::Selenium::Driver.new(app, :browser => :chrome)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
when :poltergeist
|
139
|
+
require 'capybara/poltergeist'
|
140
|
+
|
141
|
+
unless Capybara.drivers[:poltergeist]
|
142
|
+
Capybara.register_driver :poltergeist do |app|
|
143
|
+
Capybara::Poltergeist::Driver.new(app, { debug: false })
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
when :selenium_remote
|
148
|
+
unless Capybara.drivers[:selenium_remote]
|
149
|
+
selenium_url = "http://#{@selenium_config[:selenium_host]}:#{@selenium_config[:selenium_port]}/wd/hub"
|
150
|
+
|
151
|
+
Capybara.register_driver :selenium_remote do |app|
|
152
|
+
Capybara::Selenium::Driver.new(app, {:browser => :remote, :url => selenium_url})
|
153
|
+
|
154
|
+
#profile = Selenium::WebDriver::Firefox::Profile.new
|
155
|
+
#profile.enable_firebug
|
156
|
+
#
|
157
|
+
#Capybara::Driver::Selenium.new(app, {
|
158
|
+
# :browser => :remote,
|
159
|
+
# :url => selenium_url,
|
160
|
+
# :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile => profile)
|
161
|
+
#})
|
162
|
+
end
|
163
|
+
end
|
164
|
+
when :selenium_safari
|
165
|
+
unless Capybara.drivers[:selenium_safari]
|
166
|
+
Capybara.register_driver :selenium_safari do |app|
|
167
|
+
Capybara::Selenium::Driver.new(app, :browser => :safari)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
else
|
171
|
+
# nothing
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
def select_driver driver
|
176
|
+
if [:js, :javascript].include? driver
|
177
|
+
Capybara.current_driver = Capybara.javascript_driver
|
178
|
+
elsif [:webkit, :selenium, :selenium_with_firebug, :selenium_chrome, :poltergeist].include? driver
|
179
|
+
Capybara.current_driver = driver
|
180
|
+
Capybara.javascript_driver = driver
|
181
|
+
elsif [:selenium_remote].include? driver
|
182
|
+
selenium_app_host = app_host_from_url(@selenium_config[:webapp_url])
|
183
|
+
setup_app_host selenium_app_host
|
184
|
+
|
185
|
+
Rails.env = @selenium_config[:env]
|
186
|
+
|
187
|
+
Capybara.current_driver = driver
|
188
|
+
else
|
189
|
+
Capybara.current_driver = Capybara.default_driver
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def driver context
|
194
|
+
driver = ENV['DRIVER'].nil? ? nil : ENV['DRIVER'].to_sym
|
195
|
+
|
196
|
+
driver = context.example.metadata[:driver] if driver.nil?
|
197
|
+
|
198
|
+
driver = :webkit if driver.nil?
|
199
|
+
|
200
|
+
driver
|
201
|
+
end
|
202
|
+
|
203
|
+
def setup_app_host app_host
|
204
|
+
Capybara.app_host = app_host
|
205
|
+
Capybara.server_port = URI.parse(app_host).port
|
206
|
+
end
|
207
|
+
|
208
|
+
def app_host_from_url url
|
209
|
+
uri = URI(url)
|
210
|
+
|
211
|
+
"#{uri.scheme}://#{uri.host}:#{uri.port}"
|
212
|
+
end
|
213
|
+
|
214
|
+
def save_screenshot example, page
|
215
|
+
file_path = example.metadata[:file_path]
|
216
|
+
line_number = example.metadata[:line_number]
|
217
|
+
full_description = example.metadata[:full_description]
|
218
|
+
|
219
|
+
filename = File.basename(file_path)
|
220
|
+
|
221
|
+
screenshot_name = "screenshot-#{filename}-#{line_number}.png"
|
222
|
+
screenshot_path = "#{@project_root.join("tmp")}/#{screenshot_name}"
|
223
|
+
|
224
|
+
page.save_screenshot(screenshot_path)
|
225
|
+
|
226
|
+
project_url = ENV['BUILD_URL'].nil? ? "file:///#{@project_root}" : "#{ENV['BUILD_URL']}../ws"
|
227
|
+
|
228
|
+
screenshot_url = "#{project_url}/tmp/#{screenshot_name}"
|
229
|
+
|
230
|
+
puts full_description + "\n Screenshot: #{screenshot_url}"
|
231
|
+
end
|
232
|
+
|
233
|
+
def self.get_localhost
|
234
|
+
orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily
|
235
|
+
|
236
|
+
UDPSocket.open do |s|
|
237
|
+
s.connect '192.168.1.1', 1
|
238
|
+
s.addr.last
|
239
|
+
end
|
240
|
+
ensure
|
241
|
+
Socket.do_not_reverse_lookup = orig
|
242
|
+
end
|
243
|
+
|
244
|
+
end
|
245
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/features_spec_helper')
|
2
|
+
|
3
|
+
describe 'Google Search' do
|
4
|
+
include_context "AcceptanceTest"
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
acceptance_test.app_host = "http://www.google.com"
|
8
|
+
end
|
9
|
+
|
10
|
+
before do
|
11
|
+
puts "Using driver: #{Capybara.current_driver}."
|
12
|
+
end
|
13
|
+
|
14
|
+
it "uses selenium driver", driver: :selenium, exclude: false do
|
15
|
+
visit('/')
|
16
|
+
|
17
|
+
fill_in "q", :with => "Capybara"
|
18
|
+
|
19
|
+
find("#gbqfbw button").click
|
20
|
+
|
21
|
+
all(:xpath, "//li[@class='g']/h3/a").each { |a| puts a[:href] }
|
22
|
+
end
|
23
|
+
|
24
|
+
it "uses webkit driver", driver: :webkit do
|
25
|
+
visit('/')
|
26
|
+
|
27
|
+
fill_in "q", :with => "Capybara"
|
28
|
+
|
29
|
+
has_selector? ".gsfs .gssb_g span.ds input.lsb", :visible => true # wait for ajax to be finished
|
30
|
+
|
31
|
+
button = first(".gsfs .gssb_g span.ds input.lsb")
|
32
|
+
|
33
|
+
button.click
|
34
|
+
|
35
|
+
all(:xpath, "//li[@class='g']/h3/a").each { |a| puts a[:href] }
|
36
|
+
end
|
37
|
+
|
38
|
+
it "uses poltergeist driver", driver: :poltergeist do
|
39
|
+
pending
|
40
|
+
visit('/')
|
41
|
+
|
42
|
+
fill_in "q", :with => "Capybara"
|
43
|
+
|
44
|
+
has_selector? ".gsfs .gssb_g span.ds input.lsb", :visible => true # wait for ajax to be finished
|
45
|
+
|
46
|
+
button = first(".gsfs .gssb_g span.ds input.lsb")
|
47
|
+
|
48
|
+
button.click
|
49
|
+
|
50
|
+
all(:xpath, "//li[@class='g']/h3/a").each { |a| puts a[:href] }
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
development:
|
2
|
+
env: 'development'
|
3
|
+
webapp_url: 'http://localhost:3000'
|
4
|
+
selenium_host: 'localhost'
|
5
|
+
selenium_port: 4444
|
6
|
+
browser: 'firefox'
|
7
|
+
timeout_in_seconds: 40
|
8
|
+
|
9
|
+
test:
|
10
|
+
env: 'test'
|
11
|
+
webapp_url: 'http://localhost:3000'
|
12
|
+
selenium_host: 'localhost'
|
13
|
+
selenium_port: 4444
|
14
|
+
browser: 'firefox'
|
15
|
+
timeout_in_seconds: 40
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/features_spec_helper')
|
2
|
+
|
3
|
+
describe 'Google Search' do
|
4
|
+
include_context "AcceptanceTest"
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
selenium_config_file = "spec/features/selenium.yml"
|
8
|
+
selenium_config_name = "test"
|
9
|
+
|
10
|
+
acceptance_test.load_selenium_config selenium_config_file, selenium_config_name
|
11
|
+
end
|
12
|
+
|
13
|
+
before do
|
14
|
+
puts "Using driver: #{Capybara.current_driver}."
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: acceptance_test
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: !binary |-
|
5
|
+
MS4wLjA=
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alexander Shvets
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-09-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: gemspec_deps_gen
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ! '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ! '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: gemcutter
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
description: ! 'Description: simplifies congiguration and run of acceptance tests.'
|
43
|
+
email: alexander.shvets@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- .idea/misc.xml
|
50
|
+
- .idea/scopes/scope_settings.xml
|
51
|
+
- .idea/vcs.xml
|
52
|
+
- .ruby-gemset
|
53
|
+
- .ruby-version
|
54
|
+
- CHANGES
|
55
|
+
- Gemfile
|
56
|
+
- Gemfile.lock
|
57
|
+
- LICENSE
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- acceptance_test.gemspec
|
61
|
+
- acceptance_test.gemspec.erb
|
62
|
+
- lib/acceptance_test.rb
|
63
|
+
- lib/acceptance_test/acceptance_shared_context.rb
|
64
|
+
- lib/acceptance_test/acceptance_test.rb
|
65
|
+
- lib/acceptance_test/version.rb
|
66
|
+
- spec/features/features_spec_helper.rb
|
67
|
+
- spec/features/google_search_spec.rb
|
68
|
+
- spec/features/selenium.yml
|
69
|
+
- spec/features/with_selenium_conf_spec.rb
|
70
|
+
homepage: http://github.com/shvets/acceptance_test
|
71
|
+
licenses: []
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 2.1.2
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: Simplifies congiguration and run of acceptance tests.
|
93
|
+
test_files:
|
94
|
+
- spec/features/features_spec_helper.rb
|
95
|
+
- spec/features/google_search_spec.rb
|
96
|
+
- spec/features/selenium.yml
|
97
|
+
- spec/features/with_selenium_conf_spec.rb
|