acceptance_tests_support 1.0.0
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/.gitignore +18 -0
- data/.idea/.name +1 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/acceptance_tests_support.iml +34 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/misc.xml +23 -0
- data/.idea/modules.xml +9 -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 +44 -0
- data/Gemfile.lock +66 -0
- data/LICENSE +22 -0
- data/README.md +71 -0
- data/Rakefile +37 -0
- data/acceptance_tests_support.gemspec +22 -0
- data/acceptance_tests_support.gemspec.erb +20 -0
- data/gemfile_helper.rb +13 -0
- data/lib/acceptance_tests_support.rb +3 -0
- data/lib/acceptance_tests_support/acceptance_shared_context.rb +11 -0
- data/lib/acceptance_tests_support/acceptance_tests_support.rb +205 -0
- data/lib/acceptance_tests_support/version.rb +3 -0
- metadata +100 -0
data/.gitignore
ADDED
data/.idea/.name
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
acceptance_tests_support
|
data/.idea/.rakeTasks
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
|
3
|
+
You are allowed to:
|
|
4
|
+
1. Remove rake task
|
|
5
|
+
2. Add existing rake tasks
|
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
|
3
|
+
<component name="FacetManager">
|
|
4
|
+
<facet type="gem" name="Gem">
|
|
5
|
+
<configuration>
|
|
6
|
+
<option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
|
|
7
|
+
<option name="GEM_APP_TEST_PATH" value="" />
|
|
8
|
+
<option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
|
|
9
|
+
</configuration>
|
|
10
|
+
</facet>
|
|
11
|
+
</component>
|
|
12
|
+
<component name="NewModuleRootManager">
|
|
13
|
+
<content url="file://$MODULE_DIR$" />
|
|
14
|
+
<orderEntry type="inheritedJdk" />
|
|
15
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
16
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.3.1, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
|
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="capybara (v2.1.0, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
|
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="capybara-firebug (v1.3.0, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
|
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="capybara-webkit (v1.0.0, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
|
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="cucumber (v1.3.2, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
|
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.4, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
|
|
22
|
+
<orderEntry type="library" scope="PROVIDED" name="file_utils (v1.0.6, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
|
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="gherkin (v2.12.0, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
|
|
24
|
+
<orderEntry type="library" scope="PROVIDED" name="metaclass (v0.0.1, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
|
|
25
|
+
<orderEntry type="library" scope="PROVIDED" name="mime-types (v1.23, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
|
|
26
|
+
<orderEntry type="library" scope="PROVIDED" name="mocha (v0.14.0, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
|
|
27
|
+
<orderEntry type="library" scope="PROVIDED" name="multi_json (v1.7.6, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
|
|
28
|
+
<orderEntry type="library" scope="PROVIDED" name="rack-test (v0.6.2, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
|
|
29
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v2.13.1, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
|
|
30
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v2.13.0, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
|
|
31
|
+
<orderEntry type="library" scope="PROVIDED" name="xpath (v2.0.0, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
|
|
32
|
+
</component>
|
|
33
|
+
</module>
|
|
34
|
+
|
data/.idea/encodings.xml
ADDED
data/.idea/misc.xml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-1.9.3-p429 [r23]" project-jdk-type="RUBY_SDK" />
|
|
4
|
+
<component name="SvnConfiguration" maxAnnotateRevisions="500" myUseAcceleration="nothing" myAutoUpdateAfterCommit="false" cleanupOnStartRun="false">
|
|
5
|
+
<option name="USER" value="" />
|
|
6
|
+
<option name="PASSWORD" value="" />
|
|
7
|
+
<option name="mySSHConnectionTimeout" value="30000" />
|
|
8
|
+
<option name="mySSHReadTimeout" value="30000" />
|
|
9
|
+
<option name="LAST_MERGED_REVISION" />
|
|
10
|
+
<option name="MERGE_DRY_RUN" value="false" />
|
|
11
|
+
<option name="MERGE_DIFF_USE_ANCESTRY" value="true" />
|
|
12
|
+
<option name="UPDATE_LOCK_ON_DEMAND" value="false" />
|
|
13
|
+
<option name="IGNORE_SPACES_IN_MERGE" value="false" />
|
|
14
|
+
<option name="DETECT_NESTED_COPIES" value="true" />
|
|
15
|
+
<option name="CHECK_NESTED_FOR_QUICK_MERGE" value="false" />
|
|
16
|
+
<option name="IGNORE_SPACES_IN_ANNOTATE" value="true" />
|
|
17
|
+
<option name="SHOW_MERGE_SOURCES_IN_ANNOTATE" value="true" />
|
|
18
|
+
<option name="FORCE_UPDATE" value="false" />
|
|
19
|
+
<option name="IGNORE_EXTERNALS" value="false" />
|
|
20
|
+
<myIsUseDefaultProxy>false</myIsUseDefaultProxy>
|
|
21
|
+
</component>
|
|
22
|
+
</project>
|
|
23
|
+
|
data/.idea/modules.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/acceptance_tests_support.iml" filepath="$PROJECT_DIR$/.idea/acceptance_tests_support.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
9
|
+
|
data/.idea/vcs.xml
ADDED
data/.ruby-gemset
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
acceptance_tests_support
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby-1.9.3
|
data/CHANGES
ADDED
data/Gemfile
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
source "https://rubygems.org"
|
|
2
|
+
|
|
3
|
+
require './gemfile_helper'
|
|
4
|
+
|
|
5
|
+
Bundler::Dsl.send :include, GemfileHelper
|
|
6
|
+
|
|
7
|
+
group :development do
|
|
8
|
+
gem "gemspec_deps_gen"
|
|
9
|
+
gem "gemcutter"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
group :test do
|
|
13
|
+
gem "rspec"
|
|
14
|
+
gem "rspec-core"
|
|
15
|
+
gem "rspec-expectations"
|
|
16
|
+
|
|
17
|
+
gem "rspec-rails"
|
|
18
|
+
gem 'cucumber-rails', :require => false
|
|
19
|
+
|
|
20
|
+
gem "mocha", :require => false
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
group :acceptance_test do
|
|
24
|
+
gem "capybara", "2.1.0"
|
|
25
|
+
gem "capybara-firebug"
|
|
26
|
+
#gem "chromedriver-helper"
|
|
27
|
+
|
|
28
|
+
if linux?
|
|
29
|
+
if File.exist? "/usr/local/Trolltech/Qt-4.8.4"
|
|
30
|
+
#gem "capybara-webkit", "0.14.2"
|
|
31
|
+
end
|
|
32
|
+
else
|
|
33
|
+
gem "capybara-webkit", "1.0.0"
|
|
34
|
+
# Note: You need to install qt:
|
|
35
|
+
# Mac: brew install qt
|
|
36
|
+
# Ubuntu: sudo apt-get install libqt4-dev libqtwebkit-dev
|
|
37
|
+
# Debian: sudo apt-get install libqt4-dev
|
|
38
|
+
# Fedora: yum install qt-webkit-devell
|
|
39
|
+
|
|
40
|
+
unless File.exist? "/usr/local/Cellar/qt"
|
|
41
|
+
system "brew install qt"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
GEM
|
|
2
|
+
remote: https://rubygems.org/
|
|
3
|
+
specs:
|
|
4
|
+
builder (3.2.2)
|
|
5
|
+
capybara (2.1.0)
|
|
6
|
+
mime-types (>= 1.16)
|
|
7
|
+
nokogiri (>= 1.3.3)
|
|
8
|
+
rack (>= 1.0.0)
|
|
9
|
+
rack-test (>= 0.5.4)
|
|
10
|
+
xpath (~> 2.0)
|
|
11
|
+
capybara-firebug (1.3.0)
|
|
12
|
+
capybara (>= 1.0, < 3.0)
|
|
13
|
+
capybara-webkit (1.0.0)
|
|
14
|
+
capybara (~> 2.0, >= 2.0.2)
|
|
15
|
+
json
|
|
16
|
+
cucumber (1.3.2)
|
|
17
|
+
builder (>= 2.1.2)
|
|
18
|
+
diff-lcs (>= 1.1.3)
|
|
19
|
+
gherkin (~> 2.12.0)
|
|
20
|
+
multi_json (~> 1.3)
|
|
21
|
+
cucumber-rails (1.3.0)
|
|
22
|
+
capybara (>= 1.1.2)
|
|
23
|
+
cucumber (>= 1.1.8)
|
|
24
|
+
nokogiri (>= 1.5.0)
|
|
25
|
+
diff-lcs (1.2.4)
|
|
26
|
+
file_utils (1.0.6)
|
|
27
|
+
gemcutter (0.7.1)
|
|
28
|
+
gemspec_deps_gen (1.0.5)
|
|
29
|
+
file_utils
|
|
30
|
+
gherkin (2.12.0)
|
|
31
|
+
multi_json (~> 1.3)
|
|
32
|
+
json (1.8.0)
|
|
33
|
+
metaclass (0.0.1)
|
|
34
|
+
mime-types (1.23)
|
|
35
|
+
mocha (0.14.0)
|
|
36
|
+
metaclass (~> 0.0.1)
|
|
37
|
+
multi_json (1.7.6)
|
|
38
|
+
nokogiri (1.5.10)
|
|
39
|
+
rack (1.5.2)
|
|
40
|
+
rack-test (0.6.2)
|
|
41
|
+
rack (>= 1.0)
|
|
42
|
+
rspec (1.3.2)
|
|
43
|
+
rspec-core (2.13.1)
|
|
44
|
+
rspec-expectations (2.13.0)
|
|
45
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
46
|
+
rspec-rails (1.3.4)
|
|
47
|
+
rack (>= 1.0.0)
|
|
48
|
+
rspec (~> 1.3.1)
|
|
49
|
+
xpath (2.0.0)
|
|
50
|
+
nokogiri (~> 1.3)
|
|
51
|
+
|
|
52
|
+
PLATFORMS
|
|
53
|
+
ruby
|
|
54
|
+
|
|
55
|
+
DEPENDENCIES
|
|
56
|
+
capybara (= 2.1.0)
|
|
57
|
+
capybara-firebug
|
|
58
|
+
capybara-webkit (= 1.0.0)
|
|
59
|
+
cucumber-rails
|
|
60
|
+
gemcutter
|
|
61
|
+
gemspec_deps_gen
|
|
62
|
+
mocha
|
|
63
|
+
rspec
|
|
64
|
+
rspec-core
|
|
65
|
+
rspec-expectations
|
|
66
|
+
rspec-rails
|
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,71 @@
|
|
|
1
|
+
# AcceptanceTestsSupport - This gem simplifies congiguration and run of acceptance tests
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
Add this line to to your Gemfile:
|
|
6
|
+
|
|
7
|
+
gem "acceptance_tests_support"
|
|
8
|
+
|
|
9
|
+
And then execute:
|
|
10
|
+
|
|
11
|
+
$ bundle
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
require 'acceptance_tests_support'
|
|
17
|
+
|
|
18
|
+
shared_context "AcceptanceTest" do |support|
|
|
19
|
+
|
|
20
|
+
before do
|
|
21
|
+
support.before self
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
after do
|
|
25
|
+
support.after self
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
selenium_config_file = "#{File.expand_path(Rails.root)}/spec/features/support/selenium.yml"
|
|
31
|
+
selenium_config_name = 'test'
|
|
32
|
+
|
|
33
|
+
selenium_config = AcceptanceTestsSupport.load_selenium_config selenium_config_file, selenium_config_name
|
|
34
|
+
|
|
35
|
+
support = AcceptanceTestsSupport.new Rails.root, selenium_config
|
|
36
|
+
|
|
37
|
+
feature 'Google Search', %q{
|
|
38
|
+
As a user of this service
|
|
39
|
+
I want to enter a search text and get the relevant search results
|
|
40
|
+
so that I can find the right answer
|
|
41
|
+
} do
|
|
42
|
+
|
|
43
|
+
include_context "AcceptanceTest", support
|
|
44
|
+
|
|
45
|
+
before :all do
|
|
46
|
+
@support.app_host = "http://www.google.com"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
scenario "uses selenium driver", driver: :selenium, exclude: false do
|
|
50
|
+
visit('/')
|
|
51
|
+
|
|
52
|
+
fill_in "q", :with => "Capybara"
|
|
53
|
+
|
|
54
|
+
#save_and_open_page
|
|
55
|
+
|
|
56
|
+
find("#gbqfbw button").click
|
|
57
|
+
|
|
58
|
+
all(:xpath, "//li[@class='g']/h3/a").each { |a| puts a[:href] }
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Contributing
|
|
66
|
+
|
|
67
|
+
1. Fork it
|
|
68
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
69
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
|
70
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
71
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
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_tests_support/version"
|
|
7
|
+
require "gemspec_deps_gen/gemspec_deps_gen"
|
|
8
|
+
|
|
9
|
+
def version
|
|
10
|
+
AcceptanceTestsSupport::VERSION
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def project_name
|
|
14
|
+
File.basename(Dir.pwd)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
task :build do
|
|
18
|
+
system "rm #{project_name}.gemspec"
|
|
19
|
+
generator = GemspecDepsGen.new
|
|
20
|
+
|
|
21
|
+
generator.generate_dependencies "#{project_name}.gemspec.erb", "#{project_name}.gemspec"
|
|
22
|
+
|
|
23
|
+
system "gem build #{project_name}.gemspec"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
task :install do
|
|
27
|
+
system "gem install #{project_name}-#{version}.gem"
|
|
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
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/lib/acceptance_tests_support/version')
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "acceptance_tests_support"
|
|
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_tests_support"
|
|
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 = AcceptanceTestsSupport::VERSION
|
|
17
|
+
|
|
18
|
+
spec.add_development_dependency "gemspec_deps_gen", [">= 0"]
|
|
19
|
+
spec.add_development_dependency "gemcutter", [">= 0"]
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/lib/acceptance_tests_support/version')
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "acceptance_tests_support"
|
|
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_tests_support"
|
|
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 = AcceptanceTestsSupport::VERSION
|
|
17
|
+
|
|
18
|
+
<%= include_dependencies %>
|
|
19
|
+
end
|
|
20
|
+
|
data/gemfile_helper.rb
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
require 'uri'
|
|
2
|
+
require 'capybara'
|
|
3
|
+
|
|
4
|
+
class AcceptanceTestsSupport
|
|
5
|
+
attr_accessor :app_host
|
|
6
|
+
|
|
7
|
+
def self.get_localhost
|
|
8
|
+
orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily
|
|
9
|
+
|
|
10
|
+
UDPSocket.open do |s|
|
|
11
|
+
s.connect '192.168.1.1', 1
|
|
12
|
+
s.addr.last
|
|
13
|
+
end
|
|
14
|
+
ensure
|
|
15
|
+
Socket.do_not_reverse_lookup = orig
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.load_selenium_config file_name, config_name
|
|
19
|
+
selenium_config = HashWithIndifferentAccess.new YAML.load_file(file_name)[config_name]
|
|
20
|
+
|
|
21
|
+
selenium_config[:name] = config_name
|
|
22
|
+
|
|
23
|
+
selenium_config
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def initialize project_root, selenium_config
|
|
27
|
+
@project_root = project_root
|
|
28
|
+
@selenium_config = selenium_config
|
|
29
|
+
|
|
30
|
+
@app_host = default_app_host
|
|
31
|
+
|
|
32
|
+
set_defaults
|
|
33
|
+
|
|
34
|
+
configure
|
|
35
|
+
|
|
36
|
+
register_drivers
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def before context
|
|
40
|
+
driver = context.example.metadata[:driver]
|
|
41
|
+
|
|
42
|
+
if driver
|
|
43
|
+
if [:js, :javascript].include? driver
|
|
44
|
+
Capybara.current_driver = Capybara.javascript_driver
|
|
45
|
+
elsif [:webkit, :selenium, :selenium_chrome, :poltergeist].include? driver
|
|
46
|
+
Capybara.current_driver = driver
|
|
47
|
+
Capybara.javascript_driver = driver
|
|
48
|
+
elsif [:selenium_remote].include? driver
|
|
49
|
+
puts "\nSelenium Configuration: #{@selenium_config[:name]}"
|
|
50
|
+
puts "Environment: #{@selenium_config[:env]}"
|
|
51
|
+
puts "Application: #{@selenium_config[:webapp_url]}"
|
|
52
|
+
puts "Selenium: #{@selenium_config[:selenium_host]}:#{@selenium_config[:selenium_port]}"
|
|
53
|
+
|
|
54
|
+
selenium_app_host = app_host_from_url(@selenium_config[:webapp_url])
|
|
55
|
+
setup_app_host selenium_app_host
|
|
56
|
+
|
|
57
|
+
Rails.env = @selenium_config[:env]
|
|
58
|
+
|
|
59
|
+
Capybara.current_driver = driver
|
|
60
|
+
else
|
|
61
|
+
Capybara.current_driver = Capybara.default_driver
|
|
62
|
+
end
|
|
63
|
+
else
|
|
64
|
+
driver = ENV['DRIVER']
|
|
65
|
+
|
|
66
|
+
if driver
|
|
67
|
+
Capybara.current_driver = driver.to_sym
|
|
68
|
+
else
|
|
69
|
+
Capybara.current_driver = :webkit
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
setup_app_host @app_host
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def after context
|
|
77
|
+
context.reset_session!
|
|
78
|
+
|
|
79
|
+
if context.example.exception
|
|
80
|
+
driver = context.example.metadata[:driver]
|
|
81
|
+
|
|
82
|
+
if driver
|
|
83
|
+
if [:js, :javascript, :selenium, :selenium_remote].include? driver
|
|
84
|
+
save_screenshot context.example, context.page
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
Capybara.current_driver = Capybara.default_driver
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
private
|
|
93
|
+
|
|
94
|
+
def default_app_host
|
|
95
|
+
"http://#{AcceptanceTestsSupport.get_localhost}:3000"
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def set_defaults
|
|
99
|
+
ENV['APP_HOST'] ||= app_host
|
|
100
|
+
ENV['DRIVER'] ||= "webkit"
|
|
101
|
+
ENV['WAIT_TIME'] ||= "60"
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def configure
|
|
105
|
+
require 'rspec/rails'
|
|
106
|
+
require 'rspec/autorun'
|
|
107
|
+
|
|
108
|
+
require "capybara/rails"
|
|
109
|
+
|
|
110
|
+
require 'capybara/rspec'
|
|
111
|
+
require "capybara-webkit"
|
|
112
|
+
require 'capybara/poltergeist'
|
|
113
|
+
|
|
114
|
+
require "capybara"
|
|
115
|
+
require "capybara/dsl"
|
|
116
|
+
require 'capybara/firebug'
|
|
117
|
+
|
|
118
|
+
#Selenium::WebDriver::Firefox::Profile.firebug_version = '1.11.2'
|
|
119
|
+
|
|
120
|
+
#Selenium::WebDriver::Firefox::Profile.enable_firebug
|
|
121
|
+
|
|
122
|
+
RSpec.configure do |config|
|
|
123
|
+
config.filter_run_excluding :exclude => true
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
RSpec.configure do |config|
|
|
127
|
+
config.include Capybara::DSL
|
|
128
|
+
#config.include Rails.application.routes.url_helpers, :type => :acceptance
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
RSpec::Core::ExampleGroup.send :include, Capybara::DSL
|
|
132
|
+
|
|
133
|
+
Capybara.configure do |config|
|
|
134
|
+
config.default_wait_time = ENV['WAIT_TIME'].to_i
|
|
135
|
+
config.run_server = (ENV['RUN_SERVER'] == "true")
|
|
136
|
+
|
|
137
|
+
#config.always_include_port = false
|
|
138
|
+
#config.server {|app, port| Capybara.run_default_server(app, port)}
|
|
139
|
+
#config.default_selector = :css
|
|
140
|
+
#config.ignore_hidden_elements = false
|
|
141
|
+
#config.default_host = "http://www.example.com"
|
|
142
|
+
#config.automatic_reload = true
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
#Capybara.configure do |config|
|
|
146
|
+
# config.match = :one
|
|
147
|
+
# config.exact_options = true
|
|
148
|
+
# config.ignore_hidden_elements = true
|
|
149
|
+
# config.visible_text_only = true
|
|
150
|
+
#end
|
|
151
|
+
#
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def register_drivers
|
|
155
|
+
Capybara.register_driver :selenium_chrome do |app|
|
|
156
|
+
Capybara::Selenium::Driver.new(app, :browser => :chrome)
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
Capybara.register_driver :poltergeist do |app|
|
|
160
|
+
Capybara::Poltergeist::Driver.new(app, { debug: false })
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
selenium_url = "http://#{@selenium_config[:selenium_host]}:#{@selenium_config[:selenium_port]}/wd/hub"
|
|
164
|
+
|
|
165
|
+
Capybara.register_driver :selenium_remote do |app|
|
|
166
|
+
Capybara::Selenium::Driver.new(app, {:url => selenium_url, :browser => :remote})
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
#Capybara.register_driver :safari_selenium do |app|
|
|
170
|
+
# Capybara::Selenium::Driver.new(app, :browser => :safari)
|
|
171
|
+
#end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def setup_app_host app_host
|
|
175
|
+
Capybara.app_host = app_host
|
|
176
|
+
Capybara.server_port = URI.parse(app_host).port
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def app_host_from_url url
|
|
180
|
+
uri = URI(url)
|
|
181
|
+
|
|
182
|
+
"#{uri.scheme}://#{uri.host}:#{uri.port}"
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def save_screenshot example, page
|
|
186
|
+
file_path = example.metadata[:file_path]
|
|
187
|
+
line_number = example.metadata[:line_number]
|
|
188
|
+
full_description = example.metadata[:full_description]
|
|
189
|
+
|
|
190
|
+
filename = File.basename(file_path)
|
|
191
|
+
|
|
192
|
+
screenshot_name = "screenshot-#{filename}-#{line_number}.png"
|
|
193
|
+
screenshot_path = "#{@project_root.join("tmp")}/#{screenshot_name}"
|
|
194
|
+
|
|
195
|
+
page.save_screenshot(screenshot_path)
|
|
196
|
+
|
|
197
|
+
project_url = ENV['BUILD_URL'].nil? ? "file:///#{@project_root}" : "#{ENV['BUILD_URL']}../ws"
|
|
198
|
+
|
|
199
|
+
screenshot_url = "#{project_url}/tmp/#{screenshot_name}"
|
|
200
|
+
|
|
201
|
+
puts full_description + "\n Screenshot: #{screenshot_url}"
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
end
|
|
205
|
+
|
metadata
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: acceptance_tests_support
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Alexander Shvets
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2013-06-11 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: gemspec_deps_gen
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
22
|
+
type: :development
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ! '>='
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '0'
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: gemcutter
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
34
|
+
requirements:
|
|
35
|
+
- - ! '>='
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
type: :development
|
|
39
|
+
prerelease: false
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ! '>='
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '0'
|
|
46
|
+
description: ! 'Description: simplifies congiguration and run of acceptance tests.'
|
|
47
|
+
email: alexander.shvets@gmail.com
|
|
48
|
+
executables: []
|
|
49
|
+
extensions: []
|
|
50
|
+
extra_rdoc_files: []
|
|
51
|
+
files:
|
|
52
|
+
- .gitignore
|
|
53
|
+
- .idea/.name
|
|
54
|
+
- .idea/.rakeTasks
|
|
55
|
+
- .idea/acceptance_tests_support.iml
|
|
56
|
+
- .idea/encodings.xml
|
|
57
|
+
- .idea/misc.xml
|
|
58
|
+
- .idea/modules.xml
|
|
59
|
+
- .idea/scopes/scope_settings.xml
|
|
60
|
+
- .idea/vcs.xml
|
|
61
|
+
- .ruby-gemset
|
|
62
|
+
- .ruby-version
|
|
63
|
+
- CHANGES
|
|
64
|
+
- Gemfile
|
|
65
|
+
- Gemfile.lock
|
|
66
|
+
- LICENSE
|
|
67
|
+
- README.md
|
|
68
|
+
- Rakefile
|
|
69
|
+
- acceptance_tests_support.gemspec
|
|
70
|
+
- acceptance_tests_support.gemspec.erb
|
|
71
|
+
- gemfile_helper.rb
|
|
72
|
+
- lib/acceptance_tests_support.rb
|
|
73
|
+
- lib/acceptance_tests_support/acceptance_shared_context.rb
|
|
74
|
+
- lib/acceptance_tests_support/acceptance_tests_support.rb
|
|
75
|
+
- lib/acceptance_tests_support/version.rb
|
|
76
|
+
homepage: http://github.com/shvets/acceptance_tests_support
|
|
77
|
+
licenses: []
|
|
78
|
+
post_install_message:
|
|
79
|
+
rdoc_options: []
|
|
80
|
+
require_paths:
|
|
81
|
+
- lib
|
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
|
+
none: false
|
|
84
|
+
requirements:
|
|
85
|
+
- - ! '>='
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: '0'
|
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
|
+
none: false
|
|
90
|
+
requirements:
|
|
91
|
+
- - ! '>='
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: '0'
|
|
94
|
+
requirements: []
|
|
95
|
+
rubyforge_project:
|
|
96
|
+
rubygems_version: 1.8.25
|
|
97
|
+
signing_key:
|
|
98
|
+
specification_version: 3
|
|
99
|
+
summary: Simplifies congiguration and run of acceptance tests.
|
|
100
|
+
test_files: []
|