acceptance_test 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGES +4 -1
- data/lib/acceptance_test.rb +1 -3
- data/lib/acceptance_test/acceptance_shared_context.rb +16 -14
- data/lib/acceptance_test/acceptance_test.rb +48 -41
- data/lib/acceptance_test/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTRhYWVlMWRiOGQ1YjBmODMwZWVjZjliNDk2OWZmZDcxNTBmMDdkNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzYxZjQxNjQ5ZjUxZjA5NGI5ZjE0NWU1OTE4MDY3OTQzY2NjYmEzMA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjY1MTU4N2Y2YTExODI1YzEwZDI0YWQyM2VhMGQ2YTU0Y2JmOThhYTlkZGVk
|
10
|
+
NzY5MmEwYmVlNGZjMzY5Nzc1YWE2MjM0ZDgxMjA5MGM5N2Y2OWE3MGVlMmQ3
|
11
|
+
NDZkM2ZlYjhlMDQ2YzdiOGVhNjFlMTM0YzcyMDZiNjQ2OTQyNTY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MTc0ZjZiOWYzNTRkNjBhNWU3Y2NiNDFlMDY3MThiMjA4MDQ5ZDBiMDk0NzEw
|
14
|
+
OWZlNjdhN2Y3MDI0MmNiNjg5YjFjYzA2NzQzMThkNTExYWJjYmE2MWYyZGQy
|
15
|
+
YjYwOGY1YzdkNmM5N2QyZTkxMjljZjU3ZTgwMTM3YmY5MWIxN2E=
|
data/CHANGES
CHANGED
data/lib/acceptance_test.rb
CHANGED
@@ -1,23 +1,25 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
if defined? RSpec
|
2
|
+
acceptance_test_lambda = lambda do
|
3
|
+
attr_reader :acceptance_test
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
before :all do
|
6
|
+
@acceptance_test = AcceptanceTest.new
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
before do
|
10
|
+
acceptance_test.before self
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
13
|
+
after do
|
14
|
+
acceptance_test.after self
|
15
|
+
end
|
14
16
|
end
|
15
|
-
end
|
16
17
|
|
17
|
-
RSpec.shared_context "AcceptanceTest" do
|
18
|
-
|
18
|
+
RSpec.shared_context "AcceptanceTest" do
|
19
|
+
self.define_singleton_method(:include_context, acceptance_test_lambda)
|
19
20
|
|
20
|
-
|
21
|
+
include_context
|
22
|
+
end
|
21
23
|
end
|
22
24
|
|
23
25
|
|
@@ -4,6 +4,8 @@ require 'capybara'
|
|
4
4
|
require 'yaml'
|
5
5
|
require 'active_support/hash_with_indifferent_access'
|
6
6
|
|
7
|
+
require 'acceptance_test/acceptance_test_helper'
|
8
|
+
|
7
9
|
class AcceptanceTest
|
8
10
|
attr_accessor :app_host
|
9
11
|
|
@@ -17,45 +19,43 @@ class AcceptanceTest
|
|
17
19
|
configure
|
18
20
|
end
|
19
21
|
|
20
|
-
def before
|
21
|
-
driver = driver(
|
22
|
+
def before metadata={}
|
23
|
+
driver = driver(metadata)
|
22
24
|
|
23
25
|
if driver
|
24
26
|
register_driver driver
|
25
27
|
|
26
28
|
select_driver driver
|
27
29
|
|
28
|
-
if
|
29
|
-
|
30
|
-
puts "
|
31
|
-
puts "
|
32
|
-
puts "
|
30
|
+
if acceptance_config_exist?
|
31
|
+
put "\n"
|
32
|
+
puts "Acceptance Configuration: #{@acceptance_config[:name]}"
|
33
|
+
puts "Environment: #{@acceptance_config[:env]}"
|
34
|
+
puts "Application: #{@acceptance_config[:webapp_url]}"
|
35
|
+
puts "Selenium: #{@acceptance_config[:selenium_host]}:#{@acceptance_config[:selenium_port]}" if
|
36
|
+
selenium_driver?(driver)
|
33
37
|
end
|
34
38
|
end
|
35
39
|
|
36
40
|
setup_app_host app_host
|
37
41
|
end
|
38
42
|
|
39
|
-
def after
|
40
|
-
|
41
|
-
|
42
|
-
if example.exception
|
43
|
-
driver = driver(context)
|
43
|
+
def after page, example_exception=nil, metadata={}
|
44
|
+
if example_exception
|
45
|
+
driver = driver(metadata)
|
44
46
|
|
45
47
|
if driver and not [:webkit].include? driver
|
46
|
-
save_screenshot example,
|
48
|
+
save_screenshot example, page
|
47
49
|
end
|
48
50
|
end
|
49
51
|
|
50
52
|
Capybara.current_driver = Capybara.default_driver
|
51
|
-
|
52
|
-
context.reset_session!
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
56
|
-
@
|
55
|
+
def load_acceptance_config file_name, config_name
|
56
|
+
@acceptance_config = HashWithIndifferentAccess.new YAML.load_file(file_name)[config_name]
|
57
57
|
|
58
|
-
@
|
58
|
+
@acceptance_config[:name] = config_name
|
59
59
|
end
|
60
60
|
|
61
61
|
private
|
@@ -79,17 +79,25 @@ class AcceptanceTest
|
|
79
79
|
|
80
80
|
require "capybara"
|
81
81
|
require "capybara/dsl"
|
82
|
-
require 'capybara/rspec'
|
83
82
|
|
84
|
-
|
85
|
-
|
83
|
+
# try to load capybara related rspec library
|
84
|
+
begin
|
85
|
+
require 'capybara/rspec'
|
86
|
+
rescue
|
87
|
+
;
|
86
88
|
end
|
87
89
|
|
88
|
-
|
89
|
-
|
90
|
-
|
90
|
+
if defined? RSpec
|
91
|
+
RSpec.configure do |config|
|
92
|
+
config.filter_run_excluding :exclude => true
|
93
|
+
end
|
94
|
+
|
95
|
+
RSpec.configure do |config|
|
96
|
+
config.include Capybara::DSL
|
97
|
+
end
|
91
98
|
|
92
|
-
|
99
|
+
RSpec::Core::ExampleGroup.send :include, Capybara::DSL
|
100
|
+
end
|
93
101
|
|
94
102
|
Capybara.configure do |config|
|
95
103
|
config.default_wait_time = ENV['WAIT_TIME'].to_i
|
@@ -108,13 +116,13 @@ class AcceptanceTest
|
|
108
116
|
when :selenium_with_firebug
|
109
117
|
require 'capybara/firebug'
|
110
118
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
119
|
+
#Capybara.register_driver :selenium_with_firebug do |app|
|
120
|
+
# profile = Selenium::WebDriver::Firefox::Profile.new
|
121
|
+
# profile.enable_firebug
|
122
|
+
# Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile)
|
123
|
+
#end
|
116
124
|
|
117
|
-
|
125
|
+
#Selenium::WebDriver::Firefox::Profile.firebug_version = '1.11.2'
|
118
126
|
when :selenium_chrome
|
119
127
|
unless Capybara.drivers[:selenium_chrome]
|
120
128
|
Capybara.register_driver :selenium_chrome do |app|
|
@@ -133,10 +141,10 @@ class AcceptanceTest
|
|
133
141
|
|
134
142
|
when :selenium_remote
|
135
143
|
unless Capybara.drivers[:selenium_remote]
|
136
|
-
|
144
|
+
url = "http://#{@acceptance_config[:selenium_host]}:#{@acceptance_config[:selenium_port]}/wd/hub"
|
137
145
|
|
138
146
|
Capybara.register_driver :selenium_remote do |app|
|
139
|
-
Capybara::Selenium::Driver.new(app, {:browser => :remote, :url =>
|
147
|
+
Capybara::Selenium::Driver.new(app, {:browser => :remote, :url => url})
|
140
148
|
|
141
149
|
#profile = Selenium::WebDriver::Firefox::Profile.new
|
142
150
|
#profile.enable_firebug
|
@@ -164,7 +172,7 @@ class AcceptanceTest
|
|
164
172
|
if driver == :selenium_remote
|
165
173
|
setup_driver_from_config driver
|
166
174
|
else
|
167
|
-
if
|
175
|
+
if acceptance_config_exist?
|
168
176
|
setup_driver_from_config driver
|
169
177
|
else
|
170
178
|
if Capybara.drivers[driver]
|
@@ -181,10 +189,10 @@ class AcceptanceTest
|
|
181
189
|
end
|
182
190
|
end
|
183
191
|
|
184
|
-
def driver
|
192
|
+
def driver metadata
|
185
193
|
driver = ENV['DRIVER'].nil? ? nil : ENV['DRIVER'].to_sym
|
186
194
|
|
187
|
-
driver =
|
195
|
+
driver = metadata[:driver] if driver.nil?
|
188
196
|
|
189
197
|
driver = :webkit if driver.nil?
|
190
198
|
|
@@ -221,15 +229,14 @@ class AcceptanceTest
|
|
221
229
|
puts full_description + "\n Screenshot: #{screenshot_url}"
|
222
230
|
end
|
223
231
|
|
224
|
-
def
|
225
|
-
not @
|
232
|
+
def acceptance_config_exist?
|
233
|
+
not @acceptance_config.nil? and @acceptance_config.size > 0
|
226
234
|
end
|
227
235
|
|
228
236
|
def setup_driver_from_config driver
|
229
|
-
|
230
|
-
@app_host = selenium_app_host
|
237
|
+
@app_host = app_host_from_url(@acceptance_config[:webapp_url])
|
231
238
|
|
232
|
-
Rails.env = @
|
239
|
+
Rails.env = @acceptance_config[:env] if defined? Rails.env
|
233
240
|
|
234
241
|
Capybara.current_driver = driver
|
235
242
|
Capybara.javascript_driver = driver
|
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.1.
|
4
|
+
version: 1.1.2
|
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-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gemspec_deps_gen
|