acceptance_test2 0.9.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/Dockerfile +42 -0
- data/Gemfile +43 -13
- data/README.md +0 -62
- data/Rakefile +5 -2
- data/Thorfile +19 -0
- data/Vagrantfile +83 -0
- data/acceptance_test2.gemspec +35 -0
- data/lib/acceptance_test/capybara/capybara_helper.rb +71 -71
- data/lib/acceptance_test/rspec/rspec_helper.rb +68 -31
- data/lib/acceptance_test/version.rb +1 -1
- data/package.json +20 -0
- data/protractor.conf.js +47 -0
- data/spec/js/angularSiteSpec.js +20 -0
- data/spec/js/support/env.js +13 -0
- data/spec/js/support/extend.js +48 -0
- data/spec/minitest_helper.rb +2 -0
- data/spec/unit/google_search_test.rb +1 -1
- data/spec/unit/wikipedia_search_spec.rb +48 -2
- data/spec/unit/wikipedia_search_test.rb +1 -3
- data/thor/extra_provision.sh +89 -0
- data/thor/project.conf.json +16 -0
- data/thor/project.thor +61 -0
- data/thor/project_provision.sh +55 -0
- data/thor/ssh.thor +54 -0
- data/thor/system_provision.sh +77 -0
- metadata +53 -49
@@ -5,14 +5,16 @@ require 'capybara/rspec'
|
|
5
5
|
require 'capybara/dsl'
|
6
6
|
|
7
7
|
require 'singleton'
|
8
|
+
require 'file_utils'
|
8
9
|
|
9
10
|
require 'acceptance_test/capybara/capybara_helper'
|
10
11
|
|
11
12
|
class RspecHelper
|
12
13
|
include Singleton
|
13
14
|
|
14
|
-
def configure(app_host:, driver: CapybaraHelper::DEFAULT_DRIVER,
|
15
|
-
|
15
|
+
def configure(app_host:, driver: CapybaraHelper::DEFAULT_DRIVER,
|
16
|
+
browser: CapybaraHelper::DEFAULT_BROWSER,
|
17
|
+
wait_time: CapybaraHelper::DEFAULT_WAIT_TIME)
|
16
18
|
register_extensions
|
17
19
|
|
18
20
|
RSpec.configure do |rspec_config|
|
@@ -25,8 +27,9 @@ class RspecHelper
|
|
25
27
|
def create_shared_context(name)
|
26
28
|
register_extensions
|
27
29
|
|
28
|
-
RSpec.shared_context name do |app_host:, driver: CapybaraHelper::DEFAULT_DRIVER,
|
29
|
-
|
30
|
+
RSpec.shared_context name do |app_host:, driver: CapybaraHelper::DEFAULT_DRIVER,
|
31
|
+
browser: CapybaraHelper::DEFAULT_BROWSER,
|
32
|
+
wait_time: CapybaraHelper::DEFAULT_WAIT_TIME|
|
30
33
|
self.define_singleton_method(:include_context, lambda do
|
31
34
|
params = {app_host: app_host, driver: driver, browser: browser, wait_time: wait_time}
|
32
35
|
|
@@ -37,8 +40,9 @@ class RspecHelper
|
|
37
40
|
end
|
38
41
|
end
|
39
42
|
|
40
|
-
def configure_rspec(rspec_config, app_host:, driver: CapybaraHelper::DEFAULT_DRIVER,
|
41
|
-
|
43
|
+
def configure_rspec(rspec_config, app_host:, driver: CapybaraHelper::DEFAULT_DRIVER,
|
44
|
+
browser: CapybaraHelper::DEFAULT_BROWSER,
|
45
|
+
wait_time: CapybaraHelper::DEFAULT_WAIT_TIME)
|
42
46
|
rspec_config.around(:each) do |example|
|
43
47
|
params = {metadata: example.metadata, app_host: app_host, driver: driver, browser: browser, wait_time: wait_time}
|
44
48
|
|
@@ -46,8 +50,18 @@ class RspecHelper
|
|
46
50
|
|
47
51
|
example.run
|
48
52
|
|
49
|
-
|
53
|
+
RspecHelper.instance.after_test metadata: example.metadata, exception: example.exception
|
50
54
|
end
|
55
|
+
|
56
|
+
# rspec_config.before do |example|
|
57
|
+
# params = {metadata: example.metadata, app_host: app_host, driver: driver, browser: browser, wait_time: wait_time}
|
58
|
+
#
|
59
|
+
# RspecHelper.instance.before_test params
|
60
|
+
# end
|
61
|
+
|
62
|
+
# rspec_config.after do |example|
|
63
|
+
# RspecHelper.instance.after_test metadata: example.metadata, exception: example.exception
|
64
|
+
# end
|
51
65
|
end
|
52
66
|
|
53
67
|
def before_test metadata:, app_host:, driver:, browser:, wait_time:
|
@@ -60,9 +74,6 @@ class RspecHelper
|
|
60
74
|
|
61
75
|
CapybaraHelper.instance.before_test params
|
62
76
|
|
63
|
-
# puts "Using driver: #{Capybara.current_driver}."
|
64
|
-
# puts "Default wait time: #{Capybara.default_max_wait_time }."
|
65
|
-
|
66
77
|
new_driver = Capybara.current_driver
|
67
78
|
|
68
79
|
Capybara.current_session.instance_variable_set(:@mode, new_driver)
|
@@ -73,20 +84,47 @@ class RspecHelper
|
|
73
84
|
end
|
74
85
|
end
|
75
86
|
|
76
|
-
def after_test(metadata:
|
77
|
-
|
87
|
+
def after_test(metadata: nil, exception: nil)
|
88
|
+
selected_driver = RspecHelper.instance.get_driver(metadata, driver: nil)
|
78
89
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
+
if selected_driver and exception
|
91
|
+
path = build_screenshot_name 'screenshots', metadata[:file_path], metadata[:line_number]
|
92
|
+
|
93
|
+
Capybara.current_session.save_screenshot(path)
|
94
|
+
|
95
|
+
puts metadata[:description]
|
96
|
+
end
|
97
|
+
|
98
|
+
CapybaraHelper.instance.after_test name: File.basename(metadata[:file_path]), exception: exception
|
99
|
+
end
|
100
|
+
|
101
|
+
def build_screenshot_name basedir, file_path, line_number=nil
|
102
|
+
FileUtils.mkdir_p basedir unless File.exist? basedir
|
103
|
+
|
104
|
+
name = "#{build_name(file_path)}#{line_number ? '-'+line_number.to_s : ''}.png"
|
105
|
+
|
106
|
+
File.expand_path("#{basedir}/#{name}")
|
107
|
+
end
|
108
|
+
|
109
|
+
def build_name path
|
110
|
+
full_path = File.expand_path(path)
|
111
|
+
|
112
|
+
spec_index = full_path.index("/spec")
|
113
|
+
|
114
|
+
if spec_index
|
115
|
+
extension = File.extname(path)
|
116
|
+
ext_index = extension.size == 0 ? -1 : full_path.index(extension)-1
|
117
|
+
|
118
|
+
name = full_path[spec_index+1..ext_index].gsub("/", "_")
|
119
|
+
|
120
|
+
name = name[5..-1] if name =~ /^spec_/
|
121
|
+
name = name[9..-1] if name =~ /^features_/
|
122
|
+
name = name[11..-1] if name =~ /^acceptance_/
|
123
|
+
else
|
124
|
+
name = path
|
125
|
+
end
|
126
|
+
|
127
|
+
name
|
90
128
|
end
|
91
129
|
|
92
130
|
def register_extensions
|
@@ -99,15 +137,13 @@ class RspecHelper
|
|
99
137
|
config.include Capybara::RSpecMatchers
|
100
138
|
config.include Capybara::DSL
|
101
139
|
end
|
102
|
-
|
103
|
-
# RSpec::Core::ExampleGroup.send :include, Capybara::DSL
|
104
140
|
end
|
105
141
|
|
106
142
|
def get_driver(metadata, driver:)
|
107
|
-
#driver = ENV['DRIVER'].nil? ? nil : ENV['DRIVER'].to_sym
|
108
|
-
|
109
143
|
driver_name = driver
|
110
144
|
|
145
|
+
driver_name = ENV['DRIVER'].nil? ? nil : ENV['DRIVER'].to_sym unless driver_name
|
146
|
+
|
111
147
|
driver_name = metadata[:driver] unless driver_name
|
112
148
|
|
113
149
|
supported_drivers.each do |supported_driver|
|
@@ -121,10 +157,10 @@ class RspecHelper
|
|
121
157
|
end
|
122
158
|
|
123
159
|
def get_browser(metadata, browser:)
|
124
|
-
#browser_name = ENV['BROWSER'].nil? ? nil : ENV['BROWSER'].to_sym
|
125
|
-
|
126
160
|
browser_name = browser
|
127
161
|
|
162
|
+
browser_name = ENV['BROWSER'].nil? ? nil : ENV['BROWSER'].to_sym unless browser_name
|
163
|
+
|
128
164
|
browser_name = metadata[:browser] unless browser_name
|
129
165
|
|
130
166
|
supported_browsers.each do |supported_browser|
|
@@ -138,7 +174,7 @@ class RspecHelper
|
|
138
174
|
end
|
139
175
|
|
140
176
|
def supported_drivers
|
141
|
-
[:selenium
|
177
|
+
[:selenium]
|
142
178
|
end
|
143
179
|
|
144
180
|
def supported_browsers
|
@@ -174,4 +210,5 @@ class RspecHelper
|
|
174
210
|
# end
|
175
211
|
# end
|
176
212
|
end
|
177
|
-
end
|
213
|
+
end
|
214
|
+
|
data/package.json
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"name": "acceptance-demo",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "npm package for acceptance-demo",
|
5
|
+
"author": "Alexander Shvets",
|
6
|
+
"repository": {
|
7
|
+
"url": ""
|
8
|
+
},
|
9
|
+
"engines": {
|
10
|
+
"node": ">= 0.10.32"
|
11
|
+
},
|
12
|
+
"devDependencies": {
|
13
|
+
"protractor": "~2.5.1"
|
14
|
+
},
|
15
|
+
"scripts": {
|
16
|
+
"webdriver-manager-update": "node_modules/.bin/webdriver-manager update --standalone",
|
17
|
+
"webdriver-manager-start": "node_modules/.bin/webdriver-manager start",
|
18
|
+
"protractor": "node_modules/.bin/protractor protractor.conf.js --suite angularDemo"
|
19
|
+
}
|
20
|
+
}
|
data/protractor.conf.js
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
// protractor.conf.js
|
2
|
+
|
3
|
+
exports.config = {
|
4
|
+
//seleniumAddress: '', // The address of a running selenium server.
|
5
|
+
framework: 'jasmine2',
|
6
|
+
|
7
|
+
directConnect: true,
|
8
|
+
|
9
|
+
// Capabilities to be passed to the webdriver instance.
|
10
|
+
capabilities: {
|
11
|
+
browserName: 'chrome'
|
12
|
+
},
|
13
|
+
|
14
|
+
suites: {
|
15
|
+
angularDemo: 'spec/js/angularSiteSpec.js'
|
16
|
+
},
|
17
|
+
|
18
|
+
// Options to be passed to Jasmine-node.
|
19
|
+
jasmineNodeOpts: {
|
20
|
+
showColors: true, // Use colors in the command line report.
|
21
|
+
|
22
|
+
// If true, display spec names.
|
23
|
+
isVerbose: true,
|
24
|
+
|
25
|
+
// If true, include stack traces in failures.
|
26
|
+
includeStackTrace: true,
|
27
|
+
// Default time to wait in ms before a test fails.
|
28
|
+
defaultTimeoutInterval: 350000
|
29
|
+
},
|
30
|
+
|
31
|
+
allScriptsTimeout: 300000,
|
32
|
+
|
33
|
+
onPrepare: function() {
|
34
|
+
require('./spec/js/support/extend.js');
|
35
|
+
var env = require('./spec/js/support/env.js');
|
36
|
+
|
37
|
+
console.log("Environment: " + env.name());
|
38
|
+
console.log("webappUrl: " + env.webappUrl());
|
39
|
+
},
|
40
|
+
|
41
|
+
/**
|
42
|
+
* onComplete will be called just before the driver quits.
|
43
|
+
*/
|
44
|
+
onComplete: function () {
|
45
|
+
console.log("Completed");
|
46
|
+
}
|
47
|
+
};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
var env = require('./support/env.js');
|
2
|
+
|
3
|
+
describe('angularjs homepage todo list', function() {
|
4
|
+
it('should add a todo', function() {
|
5
|
+
browser.get(env.webappUrl());
|
6
|
+
|
7
|
+
element(by.model('todoList.todoText')).sendKeys('write first protractor test');
|
8
|
+
element(by.css('[value="add"]')).click();
|
9
|
+
|
10
|
+
var todoList = element.all(by.repeater('todo in todoList.todos'));
|
11
|
+
expect(todoList.count()).toEqual(2);
|
12
|
+
|
13
|
+
expect(todoList.get(1).getText()).toEqual('build an angular app');
|
14
|
+
|
15
|
+
// You wrote your first test, cross it off the list
|
16
|
+
todoList.get(1).element(by.css('input')).click();
|
17
|
+
var completedAmount = element.all(by.css('.done-true'));
|
18
|
+
expect(completedAmount.count()).toEqual(2);
|
19
|
+
});
|
20
|
+
});
|
@@ -0,0 +1,48 @@
|
|
1
|
+
// add subclass to Object with proper inheritance
|
2
|
+
// use this._super to access an overridden method.
|
3
|
+
|
4
|
+
var initializing = false;
|
5
|
+
var superPattern = /xyz/.test(function() { xyz; }) ? /\b_super\b/ : /.*/;
|
6
|
+
|
7
|
+
Object.subClass = function(properties) {
|
8
|
+
var _super = this.prototype;
|
9
|
+
|
10
|
+
initializing = true;
|
11
|
+
var proto = new this();
|
12
|
+
initializing = false;
|
13
|
+
|
14
|
+
for (var name in properties) {
|
15
|
+
proto[name] = typeof properties[name] == "function" &&
|
16
|
+
typeof _super[name] == "function" &&
|
17
|
+
superPattern.test(properties[name]) ?
|
18
|
+
(function(name, fn) {
|
19
|
+
return function() {
|
20
|
+
var tmp = this._super;
|
21
|
+
|
22
|
+
this._super = _super[name];
|
23
|
+
|
24
|
+
var ret = fn.apply(this, arguments);
|
25
|
+
this._super = tmp;
|
26
|
+
|
27
|
+
return ret;
|
28
|
+
};
|
29
|
+
})(name, properties[name]) :
|
30
|
+
properties[name];
|
31
|
+
}
|
32
|
+
|
33
|
+
function Class() {
|
34
|
+
// All construction is actually done in the init method
|
35
|
+
if (!initializing && this.init)
|
36
|
+
this.init.apply(this, arguments);
|
37
|
+
}
|
38
|
+
|
39
|
+
Class.prototype = proto;
|
40
|
+
|
41
|
+
Class.constructor = Class;
|
42
|
+
|
43
|
+
Class.subClass = arguments.callee;
|
44
|
+
|
45
|
+
return Class;
|
46
|
+
};
|
47
|
+
|
48
|
+
module.exports = Object;
|
data/spec/minitest_helper.rb
CHANGED
@@ -7,5 +7,7 @@ require 'minitest/reporters'
|
|
7
7
|
|
8
8
|
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new # spec-like progress
|
9
9
|
|
10
|
+
$LOAD_PATH.unshift File.expand_path("../lib", File.dirname(__FILE__))
|
11
|
+
|
10
12
|
require 'acceptance_test/minitest/acceptance_spec'
|
11
13
|
require 'acceptance_test/capybara/capybara_helper'
|
@@ -2,18 +2,64 @@ require_relative '../rspec_helper'
|
|
2
2
|
|
3
3
|
config = {app_host: "http://wikipedia.org", wait_time: 15}
|
4
4
|
|
5
|
+
# CapybaraHelper.instance.register_driver(:webkit)
|
6
|
+
# CapybaraHelper.instance.register_driver(:poltergeist)
|
7
|
+
|
5
8
|
RspecHelper.instance.create_shared_context "WikipediaSearch"
|
6
9
|
|
7
10
|
RSpec.describe 'Wikipedia Search' do
|
8
11
|
include_context "WikipediaSearch", config
|
9
12
|
|
10
|
-
it "searches on wikipedia web site" do
|
13
|
+
it "searches on wikipedia web site (selenium)" do
|
14
|
+
expect(Capybara.current_driver).to equal(:selenium_chrome)
|
15
|
+
|
11
16
|
visit('/')
|
12
17
|
|
13
18
|
fill_in "searchInput", :with => "Capybara"
|
14
19
|
|
15
|
-
find(".
|
20
|
+
find(".pure-button", match: :first).click
|
16
21
|
|
17
22
|
expect(page).to have_content "Hydrochoerus hydrochaeris"
|
18
23
|
end
|
24
|
+
|
25
|
+
# describe do
|
26
|
+
# before do
|
27
|
+
# Capybara::Webkit.configure do |c|
|
28
|
+
# c.allow_url("upload.wikimedia.org")
|
29
|
+
# c.allow_url("en.wikipedia.org")
|
30
|
+
# c.allow_url("wikipedia.org")
|
31
|
+
# c.allow_url("meta.wikimedia.org")
|
32
|
+
# c.allow_url("login.wikimedia.org")
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# it "searches on wikipedia web site (webkit)", driver: :webkit do
|
37
|
+
# puts "driver: #{Capybara.current_driver}"
|
38
|
+
# expect(Capybara.current_driver).to equal(:webkit)
|
39
|
+
#
|
40
|
+
# visit('/')
|
41
|
+
#
|
42
|
+
# fill_in "searchInput", :with => "Capybara"
|
43
|
+
#
|
44
|
+
# find(".formBtn", match: :first).click
|
45
|
+
#
|
46
|
+
# expect(page).to have_content "Hydrochoerus hydrochaeris"
|
47
|
+
# end
|
48
|
+
# end
|
49
|
+
|
50
|
+
# it "searches on wikipedia web site (poltergeist)", driver: :poltergeist do
|
51
|
+
# if Gem::Platform.local.os.to_sym == :darwin
|
52
|
+
# puts "This OS: #{Gem::Platform.local.os} doesn't support phantomjs."
|
53
|
+
# else
|
54
|
+
# expect(Capybara.current_driver).to equal(:poltergeist)
|
55
|
+
#
|
56
|
+
# visit('/')
|
57
|
+
#
|
58
|
+
# fill_in "searchInput", :with => "Capybara"
|
59
|
+
#
|
60
|
+
# find(".formBtn", match: :first).click
|
61
|
+
#
|
62
|
+
# expect(page).to have_content "Hydrochoerus hydrochaeris"
|
63
|
+
# end
|
64
|
+
# end
|
19
65
|
end
|
@@ -19,13 +19,11 @@ class WikipediaSearchTest < AcceptanceSpec
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it "finding the information about capybara", js: true do
|
22
|
-
skip
|
23
|
-
|
24
22
|
visit "/"
|
25
23
|
|
26
24
|
fill_in "searchInput", :with => "capybara"
|
27
25
|
|
28
|
-
find(".
|
26
|
+
find(".pure-button", match: :first).click # submit
|
29
27
|
|
30
28
|
page.must_have_content('capybara')
|
31
29
|
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
#######################################
|
4
|
+
# [chrome]
|
5
|
+
|
6
|
+
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
|
7
|
+
|
8
|
+
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
|
9
|
+
|
10
|
+
sudo apt-get update
|
11
|
+
|
12
|
+
sudo apt-get install -y google-chrome-stable
|
13
|
+
|
14
|
+
|
15
|
+
#######################################
|
16
|
+
# [chromedriver]
|
17
|
+
|
18
|
+
sudo apt-get install -y unzip
|
19
|
+
|
20
|
+
wget -N http://chromedriver.storage.googleapis.com/2.20/chromedriver_linux64.zip -P ~/Downloads
|
21
|
+
|
22
|
+
unzip ~/Downloads/chromedriver_linux64.zip -d ~/Downloads
|
23
|
+
|
24
|
+
chmod +x ~/Downloads/chromedriver
|
25
|
+
|
26
|
+
sudo mv -f ~/Downloads/chromedriver /usr/local/share/chromedriver
|
27
|
+
|
28
|
+
sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
|
29
|
+
|
30
|
+
sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver
|
31
|
+
|
32
|
+
|
33
|
+
#######################################
|
34
|
+
# [ffmpeg]
|
35
|
+
|
36
|
+
sudo apt-get install -y ffmpeg
|
37
|
+
sudo apt-get install -y libav-tools
|
38
|
+
|
39
|
+
|
40
|
+
##############################
|
41
|
+
# [firefox]
|
42
|
+
|
43
|
+
sudo apt-get install -y firefox
|
44
|
+
|
45
|
+
|
46
|
+
##############################
|
47
|
+
# [phantomjs]
|
48
|
+
|
49
|
+
#sudo apt-get install phantomjs
|
50
|
+
|
51
|
+
cd /usr/local/share
|
52
|
+
|
53
|
+
sudo wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
|
54
|
+
|
55
|
+
sudo tar xjf phantomjs-1.9.8-linux-x86_64.tar.bz2
|
56
|
+
|
57
|
+
sudo ln -s /usr/local/share/phantomjs-1.9.8-linux-x86_64/bin/phantomjs /usr/local/share/phantomjs
|
58
|
+
sudo ln -s /usr/local/share/phantomjs-1.9.8-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs
|
59
|
+
sudo ln -s /usr/local/share/phantomjs-1.9.8-linux-x86_64/bin/phantomjs /usr/bin/phantomjs
|
60
|
+
|
61
|
+
|
62
|
+
##############################
|
63
|
+
# [imagemagick]
|
64
|
+
|
65
|
+
sudo apt-get install -y imagemagick
|
66
|
+
sudo apt-get install -y X11-apps
|
67
|
+
|
68
|
+
|
69
|
+
##############################
|
70
|
+
# [apache]
|
71
|
+
|
72
|
+
sudo apt-get install -y apache2
|
73
|
+
|
74
|
+
|
75
|
+
#######################################
|
76
|
+
# [node]
|
77
|
+
# Installs node
|
78
|
+
|
79
|
+
sudo apt-get install -y node
|
80
|
+
|
81
|
+
|
82
|
+
#######################################
|
83
|
+
# [rbenv]
|
84
|
+
# Installs node
|
85
|
+
|
86
|
+
sudo apt-get install -y rbenv
|
87
|
+
git clone git://github.com/jf/rbenv-gemset.git $HOME/.rbenv/plugins/rbenv-gemset
|
88
|
+
|
89
|
+
|