acceptance_test 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGES +4 -0
- data/lib/acceptance_test.rb +0 -1
- data/lib/acceptance_test/acceptance_test.rb +13 -9
- data/lib/acceptance_test/acceptance_test_helper.rb +78 -1
- data/lib/acceptance_test/version.rb +1 -1
- data/spec/features/google_search_spec.rb +4 -4
- data/spec/features/spec_helper.rb +9 -0
- data/spec/features/with_selenium_conf_spec.rb +2 -30
- metadata +4 -4
- data/lib/acceptance_test/acceptance_shared_context.rb +0 -36
- data/lib/acceptance_test/acceptance_test_builder.rb +0 -37
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjA5NTU3MjYwOTRiYzE2ZTI5ZGZmYjljZWFlZjgyYzBlY2Y3OGE3ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTBkZDU4N2M0OGIyMzFiMGQxYzA4OTFhMTBlOWZkNDEwNjk2MWY5ZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWE4ZTRlNzQwODUyNTIyNDc3N2UzMWI5NTkyOGU5NTg2YzhiZDFlNzVjMmVi
|
10
|
+
YzhhZTM5NTNhZWQ4YzI4MWJkNWNkYjViZGZmNThlMWFmY2U3MjYyMDBiZDY4
|
11
|
+
ODZjYTUyYzc1M2YzZTFhOWJhNDNlZWY3MDkyOTNhZTVhOTQxOGE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTk1YjM3Y2YxNjI5OTU0NTc4MDE0ODVhNzZkYjQ3NTA4MDQyNmJlYTVhYmEx
|
14
|
+
NWRiY2EzZTlkZjIzMzNhMjk1NDI1MTViZWI0MTNlYTI0ODhjY2FkMWU1ZWI3
|
15
|
+
NWFmYTdhNTJiNzNmOTZkNzUyNGM5MDhmZTZjNzI2ZmRmMmNmZDQ=
|
data/CHANGES
CHANGED
data/lib/acceptance_test.rb
CHANGED
@@ -29,21 +29,21 @@ class AcceptanceTest
|
|
29
29
|
select_driver driver
|
30
30
|
end
|
31
31
|
|
32
|
+
puts "Current Driver : #{Capybara.current_driver}"
|
33
|
+
|
32
34
|
setup_app_host app_host
|
33
35
|
end
|
34
36
|
|
35
|
-
def after
|
36
|
-
if exception
|
37
|
+
def after metadata={}, exception=nil, page=nil
|
37
38
|
driver = driver(metadata)
|
38
39
|
|
39
|
-
|
40
|
-
|
40
|
+
if driver and exception and page and not [:webkit].include? driver
|
41
|
+
screenshot_maker = ScreenshotMaker.new screenshot_dir
|
41
42
|
|
42
|
-
|
43
|
+
screenshot_maker.make page, metadata
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
end
|
45
|
+
puts metadata[:full_description]
|
46
|
+
puts "Screenshot: #{screenshot_maker.screenshot_url(metadata)}"
|
47
47
|
end
|
48
48
|
|
49
49
|
Capybara.current_driver = Capybara.default_driver
|
@@ -63,10 +63,14 @@ class AcceptanceTest
|
|
63
63
|
driver.to_s =~ /selenium/
|
64
64
|
end
|
65
65
|
|
66
|
+
def self.supported_drivers
|
67
|
+
[:webkit, :selenium, :poltergeist, :selenium_remote]
|
68
|
+
end
|
69
|
+
|
66
70
|
private
|
67
71
|
|
68
72
|
def default_app_host
|
69
|
-
"http://#{AcceptanceTestHelper.get_localhost}:3000"
|
73
|
+
"http://#{AcceptanceTestHelper.instance.get_localhost}:3000"
|
70
74
|
end
|
71
75
|
|
72
76
|
def configure
|
@@ -1,6 +1,83 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'singleton'
|
3
|
+
require 'active_support/core_ext/hash'
|
4
|
+
|
1
5
|
class AcceptanceTestHelper
|
6
|
+
include Singleton
|
7
|
+
|
8
|
+
def create_acceptance_test project_root, config_name, screenshot_dir
|
9
|
+
Capybara.configure do |config|
|
10
|
+
config.match = :first
|
11
|
+
|
12
|
+
config.ignore_hidden_elements = false
|
13
|
+
end
|
14
|
+
|
15
|
+
project_root = File.expand_path(project_root.to_s)
|
16
|
+
|
17
|
+
config = HashWithIndifferentAccess.new(YAML.load_file(config_name))
|
18
|
+
|
19
|
+
system "mkdir -p #{screenshot_dir}"
|
20
|
+
|
21
|
+
acceptance_test = AcceptanceTest.new project_root, config, screenshot_dir
|
22
|
+
|
23
|
+
ENV['ASSET_HOST'] = acceptance_test.app_host
|
24
|
+
|
25
|
+
puts "Application URL : #{config[:webapp_url]}"
|
26
|
+
puts "Selenium URL : #{config[:selenium_url]}" if config[:selenium_url]
|
27
|
+
puts "Default Wait Time : #{Capybara.default_wait_time}"
|
28
|
+
|
29
|
+
acceptance_test
|
30
|
+
end
|
31
|
+
|
32
|
+
def create_shared_context acceptance_test, name
|
33
|
+
throw "rspec library is not available" unless defined? RSpec
|
34
|
+
|
35
|
+
acceptance_test_lambda = lambda do
|
36
|
+
attr_reader :acceptance_test
|
37
|
+
|
38
|
+
before :all do
|
39
|
+
@acceptance_test = acceptance_test
|
40
|
+
end
|
41
|
+
|
42
|
+
before do
|
43
|
+
metadata = RSpec.current_example.metadata
|
44
|
+
|
45
|
+
acceptance_test.before metadata
|
46
|
+
end
|
47
|
+
|
48
|
+
after do
|
49
|
+
metadata = RSpec.current_example.metadata
|
50
|
+
|
51
|
+
acceptance_test.after metadata, RSpec.current_example.exception, page
|
52
|
+
|
53
|
+
self.reset_session!
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
RSpec.shared_context name do
|
58
|
+
self.define_singleton_method(:include_context, acceptance_test_lambda)
|
59
|
+
|
60
|
+
include_context
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def metadata_from_scenario scenario
|
65
|
+
tags = scenario.source_tag_names.collect { |a| a.gsub("@", '') }
|
66
|
+
|
67
|
+
metadata = {}
|
68
|
+
|
69
|
+
if tags.size > 0
|
70
|
+
tag = tags.first.to_sym
|
71
|
+
|
72
|
+
if AcceptanceTest.supported_drivers.include? tag
|
73
|
+
metadata[:driver] = tag
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
metadata
|
78
|
+
end
|
2
79
|
|
3
|
-
def
|
80
|
+
def get_localhost
|
4
81
|
orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily
|
5
82
|
|
6
83
|
UDPSocket.open do |s|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require File.expand_path("spec/features/spec_helper")
|
2
2
|
|
3
3
|
RSpec.describe 'Google Search' do
|
4
|
-
include_context "
|
4
|
+
include_context "GoogleAcceptanceTest"
|
5
5
|
|
6
6
|
before :all do
|
7
7
|
acceptance_test.app_host = "http://www.google.com"
|
@@ -19,7 +19,7 @@ RSpec.describe 'Google Search' do
|
|
19
19
|
|
20
20
|
find("#gbqfbw button").click
|
21
21
|
|
22
|
-
all(:xpath, "//li[@class='g']/h3/a").each { |a| puts a[:href] }
|
22
|
+
# all(:xpath, "//li[@class='g']/h3/a").each { |a| puts a[:href] }
|
23
23
|
end
|
24
24
|
|
25
25
|
it "uses webkit driver", driver: :webkit do
|
@@ -34,7 +34,7 @@ RSpec.describe 'Google Search' do
|
|
34
34
|
|
35
35
|
button.click
|
36
36
|
|
37
|
-
all(:xpath, "//li[@class='g']/h3/a").each { |a| puts a[:href] }
|
37
|
+
#all(:xpath, "//li[@class='g']/h3/a").each { |a| puts a[:href] }
|
38
38
|
end
|
39
39
|
|
40
40
|
it "uses poltergeist driver", driver: :poltergeist do
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'acceptance_test'
|
2
|
+
|
3
|
+
config_name = File.expand_path("spec/features/acceptance_config.yml")
|
4
|
+
|
5
|
+
helper = AcceptanceTestHelper.instance
|
6
|
+
|
7
|
+
acceptance_test = helper.create_acceptance_test ".", config_name, "tmp"
|
8
|
+
|
9
|
+
helper.create_shared_context acceptance_test, "GoogleAcceptanceTest"
|
@@ -1,35 +1,7 @@
|
|
1
|
-
|
2
|
-
require 'yaml'
|
1
|
+
File.expand_path("spec/features/spec_helper")
|
3
2
|
|
4
3
|
RSpec.describe 'Google Search' do
|
5
|
-
include_context "
|
6
|
-
|
7
|
-
before :all do
|
8
|
-
#acceptance_config_file = "spec/features/acceptance_config.yml"
|
9
|
-
|
10
|
-
# acceptance_test.acceptance_config = YAML.load_file(acceptance_config_file)
|
11
|
-
#
|
12
|
-
# acceptance_config = acceptance_test.acceptance_config
|
13
|
-
|
14
|
-
# env = acceptance_config[:env]
|
15
|
-
#
|
16
|
-
# puts "\nEnvironment: #{@acceptance_config[:env]}" if env
|
17
|
-
# puts "Application: #{@acceptance_config[:webapp_url]}"
|
18
|
-
#
|
19
|
-
# driver = acceptance_test.driver(metadata)
|
20
|
-
#
|
21
|
-
# if acceptance_test.selenium_driver?(driver)
|
22
|
-
# selenium_host = acceptance_config[:selenium_host]
|
23
|
-
# selenium_port = acceptance_config[:selenium_port]
|
24
|
-
#
|
25
|
-
# puts "Selenium: #{selenium_host}:#{selenium_port}"
|
26
|
-
# end
|
27
|
-
end
|
28
|
-
|
29
|
-
before do
|
30
|
-
# puts "Using driver: #{Capybara.current_driver}."
|
31
|
-
# puts "Default wait time: #{Capybara.default_wait_time}."
|
32
|
-
end
|
4
|
+
include_context "GoogleAcceptanceTest"
|
33
5
|
|
34
6
|
it "uses selenium driver", driver: :selenium_remote do
|
35
7
|
visit('/')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acceptance_test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Shvets
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gemspec_deps_gen
|
@@ -64,14 +64,13 @@ files:
|
|
64
64
|
- acceptance_test.gemspec
|
65
65
|
- acceptance_test.gemspec.erb
|
66
66
|
- lib/acceptance_test.rb
|
67
|
-
- lib/acceptance_test/acceptance_shared_context.rb
|
68
67
|
- lib/acceptance_test/acceptance_test.rb
|
69
|
-
- lib/acceptance_test/acceptance_test_builder.rb
|
70
68
|
- lib/acceptance_test/acceptance_test_helper.rb
|
71
69
|
- lib/acceptance_test/screenshot_maker.rb
|
72
70
|
- lib/acceptance_test/version.rb
|
73
71
|
- spec/features/acceptance_config.yml
|
74
72
|
- spec/features/google_search_spec.rb
|
73
|
+
- spec/features/spec_helper.rb
|
75
74
|
- spec/features/with_selenium_conf_spec.rb
|
76
75
|
homepage: http://github.com/shvets/acceptance_test
|
77
76
|
licenses:
|
@@ -100,4 +99,5 @@ summary: Simplifies congiguration and run of acceptance tests.
|
|
100
99
|
test_files:
|
101
100
|
- spec/features/acceptance_config.yml
|
102
101
|
- spec/features/google_search_spec.rb
|
102
|
+
- spec/features/spec_helper.rb
|
103
103
|
- spec/features/with_selenium_conf_spec.rb
|
@@ -1,36 +0,0 @@
|
|
1
|
-
if defined? RSpec
|
2
|
-
require 'acceptance_test/acceptance_test_builder'
|
3
|
-
|
4
|
-
acceptance_test_lambda = lambda do
|
5
|
-
attr_reader :acceptance_test
|
6
|
-
|
7
|
-
before :all do
|
8
|
-
config_name = File.expand_path("spec/features/acceptance_config.yml")
|
9
|
-
|
10
|
-
@acceptance_test = AcceptanceTestBuilder.instance.create ".", config_name, "tmp"
|
11
|
-
end
|
12
|
-
|
13
|
-
before do
|
14
|
-
metadata = RSpec.current_example.metadata
|
15
|
-
|
16
|
-
acceptance_test.before metadata
|
17
|
-
end
|
18
|
-
|
19
|
-
after do
|
20
|
-
metadata = RSpec.current_example.metadata
|
21
|
-
|
22
|
-
acceptance_test.after page, RSpec.current_example.exception, metadata
|
23
|
-
|
24
|
-
self.reset_session!
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
RSpec.shared_context "AcceptanceTest" do
|
29
|
-
self.define_singleton_method(:include_context, acceptance_test_lambda)
|
30
|
-
|
31
|
-
include_context
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
require 'singleton'
|
3
|
-
require 'active_support/core_ext/hash'
|
4
|
-
|
5
|
-
class AcceptanceTestBuilder
|
6
|
-
include Singleton
|
7
|
-
|
8
|
-
def create project_root, config_name, screenshot_dir
|
9
|
-
Capybara.default_driver = :selenium
|
10
|
-
|
11
|
-
ENV['DRIVER'] = 'selenium'
|
12
|
-
|
13
|
-
Capybara.configure do |config|
|
14
|
-
config.match = :first
|
15
|
-
|
16
|
-
config.ignore_hidden_elements = false
|
17
|
-
end
|
18
|
-
|
19
|
-
project_root = File.expand_path(project_root.to_s)
|
20
|
-
|
21
|
-
config = HashWithIndifferentAccess.new(YAML.load_file(config_name))
|
22
|
-
|
23
|
-
system "mkdir -p #{screenshot_dir}"
|
24
|
-
|
25
|
-
acceptance_test = AcceptanceTest.new project_root, config, screenshot_dir
|
26
|
-
|
27
|
-
ENV['ASSET_HOST'] = acceptance_test.app_host
|
28
|
-
|
29
|
-
puts "Application URL : #{config[:webapp_url]}"
|
30
|
-
puts "Selenium URL : #{config[:selenium_url]}" if config[:selenium_url]
|
31
|
-
puts "ENV['DRIVER'] : #{ENV['DRIVER']}" if ENV['DRIVER']
|
32
|
-
puts "Default Wait Time : #{Capybara.default_wait_time}"
|
33
|
-
|
34
|
-
acceptance_test
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|