acceptance_test 1.6.1 → 1.6.2
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.
- checksums.yaml +8 -8
- data/.idea/acceptance_test.iml +77 -3
- data/CHANGES +5 -1
- data/lib/acceptance_test/acceptance_test.rb +106 -129
- data/lib/acceptance_test/acceptance_test_old.rb +221 -0
- data/lib/acceptance_test/driver_manager.rb +69 -72
- data/lib/acceptance_test/version.rb +1 -1
- data/spec/acceptance_config.yml +4 -2
- data/spec/features/search_with_drivers.feature +0 -1
- data/spec/support/steps/search_with_drivers_steps.rb +2 -2
- data/spec/support/steps/search_with_examples_from_csv_steps.rb +6 -0
- data/spec/turnip_helper.rb +7 -12
- data/spec/wikipedia_search_spec.rb +11 -6
- data/spec/wikipedia_search_with_config_spec.rb +15 -7
- data/spec/wikipedia_search_with_pages_spec.rb +25 -15
- data/spec/wikipedia_search_with_steps_spec.rb +4 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzgxZjE5NWZhZGM2NjRhYTA5MmNhZGI5ZmVmMDBjNWExMTRiYWIxOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjUyNTg4YjcxNTAwMjY3YzY0OWFkOGU3ZWQ3OWMyNjZlMTNkOTVlYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2M0ZDQ3MGRjMzA3MWQ0ZTg0NmU5MzA5ZDUwMjljMjQzYmNjYjI1YmYzZjBh
|
10
|
+
NjBjOTJlYzI3N2U1ZTIzYmIxMGZkODc2NmU4Zjc3NmE3Yzg3NTI0MDA0YmUz
|
11
|
+
ZmU2MmIzZmVjMTJiMTA5MTRlYmI1NWZlM2Y3YzcwY2I5YWFjOGY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTRlYTk4ZWRmYmQ2ZjQwNmZhNzMwOTI3ZjczNmIyYjdkZjZlODFjZWI3OTNl
|
14
|
+
NTBhNGE3ZTE5YzgxMzE2NjU2NTkyZjMyMTgwNjE1MDkwZmY5ZmM2MmVjNWNh
|
15
|
+
NzQ4ZDI4NzIxNjFiOWRlMzZhOGU3ODBlOWVlNTU3NTAxM2NhMGQ=
|
data/.idea/acceptance_test.iml
CHANGED
@@ -168,6 +168,42 @@
|
|
168
168
|
<ConfigurationWrapper RunnerId="RubyRunner" />
|
169
169
|
<method />
|
170
170
|
</configuration>
|
171
|
+
<configuration default="false" name="rspec group" type="RSpecRunConfigurationType" factoryName="RSpec">
|
172
|
+
<predefined_log_file id="RUBY_RSPEC" enabled="true" />
|
173
|
+
<module name="acceptance_test" />
|
174
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
175
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="" />
|
176
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
|
177
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
|
178
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
|
179
|
+
<envs />
|
180
|
+
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
|
181
|
+
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
182
|
+
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
|
183
|
+
<COVERAGE_PATTERN ENABLED="true">
|
184
|
+
<PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
|
185
|
+
</COVERAGE_PATTERN>
|
186
|
+
</EXTENSION>
|
187
|
+
<EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
|
188
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="." />
|
189
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="" />
|
190
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
|
191
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
|
192
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
|
193
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="ALL_IN_FOLDER" />
|
194
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
|
195
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
|
196
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
|
197
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
|
198
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
|
199
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
|
200
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
|
201
|
+
<RunnerSettings RunnerId="RubyDebugRunner" />
|
202
|
+
<RunnerSettings RunnerId="RubyRunner" />
|
203
|
+
<ConfigurationWrapper RunnerId="RubyDebugRunner" />
|
204
|
+
<ConfigurationWrapper RunnerId="RubyRunner" />
|
205
|
+
<method />
|
206
|
+
</configuration>
|
171
207
|
<configuration default="false" name="search_with_drivers" type="RSpecRunConfigurationType" factoryName="RSpec">
|
172
208
|
<predefined_log_file id="RUBY_RSPEC" enabled="true" />
|
173
209
|
<module name="acceptance_test" />
|
@@ -312,7 +348,7 @@
|
|
312
348
|
<ConfigurationWrapper RunnerId="RubyRunner" />
|
313
349
|
<method />
|
314
350
|
</configuration>
|
315
|
-
<configuration default="false" name="
|
351
|
+
<configuration default="false" name=" uses selenium driver: acceptance_test" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
|
316
352
|
<predefined_log_file id="RUBY_RSPEC" enabled="true" />
|
317
353
|
<module name="acceptance_test" />
|
318
354
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
@@ -335,6 +371,42 @@
|
|
335
371
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/wikipedia_search_spec.rb" />
|
336
372
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
|
337
373
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
|
374
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE=" uses selenium driver" />
|
375
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
|
376
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
|
377
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
|
378
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
|
379
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
|
380
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
|
381
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
|
382
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
|
383
|
+
<RunnerSettings RunnerId="RubyRunner" />
|
384
|
+
<ConfigurationWrapper RunnerId="RubyRunner" />
|
385
|
+
<method />
|
386
|
+
</configuration>
|
387
|
+
<configuration default="false" name="Run spec 'wikipedia_search_with_steps_spec': acceptance_test" type="RSpecRunConfigurationType" factoryName="RSpec">
|
388
|
+
<predefined_log_file id="RUBY_RSPEC" enabled="true" />
|
389
|
+
<module name="acceptance_test" />
|
390
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
391
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
|
392
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
|
393
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
|
394
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
|
395
|
+
<envs>
|
396
|
+
<env name="JRUBY_OPTS" value="-X+O" />
|
397
|
+
</envs>
|
398
|
+
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
|
399
|
+
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
400
|
+
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
|
401
|
+
<COVERAGE_PATTERN ENABLED="true">
|
402
|
+
<PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
|
403
|
+
</COVERAGE_PATTERN>
|
404
|
+
</EXTENSION>
|
405
|
+
<EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
|
406
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
|
407
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/wikipedia_search_with_steps_spec.rb" />
|
408
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
|
409
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
|
338
410
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
|
339
411
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
|
340
412
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
|
@@ -418,11 +490,13 @@
|
|
418
490
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
|
419
491
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
|
420
492
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
|
493
|
+
<RunnerSettings RunnerId="RubyDebugRunner" />
|
421
494
|
<RunnerSettings RunnerId="RubyRunner" />
|
495
|
+
<ConfigurationWrapper RunnerId="RubyDebugRunner" />
|
422
496
|
<ConfigurationWrapper RunnerId="RubyRunner" />
|
423
497
|
<method />
|
424
498
|
</configuration>
|
425
|
-
<configuration default="false" name="Run spec '
|
499
|
+
<configuration default="false" name="Run spec 'wikipedia_search_spec': acceptance_test" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
|
426
500
|
<predefined_log_file id="RUBY_RSPEC" enabled="true" />
|
427
501
|
<module name="acceptance_test" />
|
428
502
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
@@ -442,7 +516,7 @@
|
|
442
516
|
</EXTENSION>
|
443
517
|
<EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
|
444
518
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
|
445
|
-
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/
|
519
|
+
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/wikipedia_search_spec.rb" />
|
446
520
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
|
447
521
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
|
448
522
|
<RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
|
data/CHANGES
CHANGED
@@ -1,221 +1,198 @@
|
|
1
|
-
require 'uri'
|
2
1
|
require 'singleton'
|
3
|
-
|
4
2
|
require 'active_support/core_ext/hash'
|
5
3
|
|
6
|
-
require 'acceptance_test/driver_manager'
|
7
4
|
require 'acceptance_test/gherkin_ext'
|
8
|
-
require 'acceptance_test/turnip_ext'
|
9
5
|
|
10
6
|
class AcceptanceTest
|
11
7
|
include Singleton
|
12
8
|
|
13
|
-
attr_reader :config
|
9
|
+
attr_reader :config
|
14
10
|
|
15
11
|
def initialize
|
16
|
-
|
12
|
+
require 'capybara'
|
13
|
+
|
14
|
+
Capybara.default_driver = :selenium
|
17
15
|
|
18
16
|
@config = HashWithIndifferentAccess.new
|
19
17
|
|
20
18
|
@config[:browser] = 'firefox'
|
21
19
|
@config[:screenshot_dir] = File.expand_path('tmp')
|
22
|
-
|
20
|
+
@config[:timeout_in_seconds] = 20
|
21
|
+
|
22
|
+
init
|
23
|
+
end
|
23
24
|
|
24
25
|
def configure hash={}
|
25
26
|
config.merge!(HashWithIndifferentAccess.new(hash))
|
26
27
|
end
|
27
28
|
|
28
|
-
def setup
|
29
|
-
|
29
|
+
def setup page=nil
|
30
|
+
driver = config[:driver] ? config[:driver].to_sym : :selenium
|
31
|
+
browser = config[:browser] ? config[:browser].to_sym : :firefox
|
32
|
+
remote = !config[:selenium_url].nil?
|
33
|
+
|
34
|
+
register_driver(driver, browser, remote)
|
35
|
+
|
36
|
+
driver_name = build_driver_name(driver, browser, remote)
|
37
|
+
|
38
|
+
use_driver(driver_name, page)
|
39
|
+
|
40
|
+
Capybara.app_host = config[:webapp_url]
|
30
41
|
|
31
42
|
Capybara.configure do |conf|
|
32
|
-
conf.default_wait_time = timeout_in_seconds
|
33
|
-
end
|
43
|
+
conf.default_wait_time = config[:timeout_in_seconds]
|
34
44
|
|
35
|
-
|
45
|
+
conf.match = :first
|
36
46
|
|
37
|
-
|
47
|
+
conf.ignore_hidden_elements = false
|
48
|
+
end
|
38
49
|
end
|
39
50
|
|
40
51
|
def teardown
|
41
52
|
Capybara.app_host = nil
|
42
53
|
|
43
54
|
Capybara.configure do |conf|
|
44
|
-
conf.default_wait_time =
|
55
|
+
conf.default_wait_time = 2
|
45
56
|
end
|
46
57
|
|
47
58
|
Capybara.default_driver = :rack_test
|
48
59
|
end
|
49
60
|
|
50
|
-
def
|
51
|
-
|
61
|
+
def register_driver(driver, browser=:firefox, remote=false)
|
62
|
+
driver_name = build_driver_name(driver, browser, remote)
|
52
63
|
|
53
|
-
|
64
|
+
case driver
|
65
|
+
when :poltergeist
|
66
|
+
require 'capybara/poltergeist'
|
54
67
|
|
55
|
-
|
56
|
-
|
68
|
+
when :webkit
|
69
|
+
require "capybara-webkit"
|
57
70
|
|
58
|
-
|
59
|
-
|
60
|
-
Capybara.javascript_driver = driver_name
|
71
|
+
when :firefox_with_firebug
|
72
|
+
require 'capybara/firebug'
|
61
73
|
|
62
|
-
|
63
|
-
|
74
|
+
else
|
75
|
+
;
|
64
76
|
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def after_test metadata={}, exception=nil, page=nil
|
68
|
-
driver = driver(metadata)
|
69
|
-
|
70
|
-
if driver and exception and page and not [:webkit].include? driver
|
71
|
-
screenshot_dir = File.expand_path(config[:screenshot_dir])
|
72
77
|
|
73
|
-
|
78
|
+
if driver == :poltergeist
|
79
|
+
properties = {}
|
80
|
+
properties[:debug] = false
|
74
81
|
|
75
|
-
|
76
|
-
|
77
|
-
|
82
|
+
Capybara.register_driver :poltergeist do |app|
|
83
|
+
Capybara::Poltergeist::Driver.new(app, properties)
|
84
|
+
end
|
85
|
+
else
|
86
|
+
properties = {}
|
87
|
+
properties[:browser] = browser
|
78
88
|
|
79
|
-
|
80
|
-
|
89
|
+
Capybara.register_driver driver_name do |app|
|
90
|
+
Capybara::Selenium::Driver.new(app, properties)
|
91
|
+
end
|
81
92
|
end
|
82
93
|
|
83
|
-
|
84
|
-
Capybara.javascript_driver = Capybara.default_driver
|
94
|
+
driver_name
|
85
95
|
end
|
86
96
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
acceptance_test_lambda = lambda do
|
93
|
-
acceptance_test.configure_rspec self
|
94
|
-
end
|
97
|
+
# profile = Selenium::WebDriver::Firefox::Profile.new
|
98
|
+
# profile.enable_firebug
|
99
|
+
#
|
100
|
+
# properties[:desired_capabilities] = Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile => profile)
|
101
|
+
#properties[:desired_capabilities] = Selenium::WebDriver::Remote::Capabilities.internet_explorer
|
95
102
|
|
96
|
-
|
97
|
-
|
103
|
+
def use_driver driver, page=nil
|
104
|
+
if driver and Capybara.drivers[driver]
|
105
|
+
Capybara.current_driver = driver
|
106
|
+
Capybara.javascript_driver = driver
|
98
107
|
|
99
|
-
|
108
|
+
page.instance_variable_set(:@mode, driver) if page
|
100
109
|
end
|
101
110
|
end
|
102
111
|
|
103
|
-
def
|
104
|
-
|
105
|
-
|
106
|
-
metadata = {}
|
107
|
-
|
108
|
-
if tags.size > 0
|
109
|
-
tag = tags.first.to_sym
|
110
|
-
|
111
|
-
if driver_manager.supported_drivers.include? tag
|
112
|
-
metadata[:driver] = tag
|
113
|
-
end
|
114
|
-
end
|
112
|
+
def add_expectations context
|
113
|
+
require 'rspec/expectations'
|
115
114
|
|
116
|
-
|
117
|
-
end
|
118
|
-
|
119
|
-
def extend_turnip
|
120
|
-
shared_context_name = "#{random_name}AcceptanceTest"
|
121
|
-
|
122
|
-
create_shared_context shared_context_name
|
123
|
-
|
124
|
-
TurnipExt.shared_context_with_turnip shared_context_name
|
115
|
+
context.send :include, Capybara::DSL
|
125
116
|
end
|
126
117
|
|
127
118
|
def enable_external_source data_reader
|
128
119
|
GherkinExt.enable_external_source data_reader
|
129
120
|
end
|
130
121
|
|
131
|
-
def
|
122
|
+
def configure_turnip report_name
|
132
123
|
require 'turnip/rspec'
|
133
|
-
require 'turnip_formatter'
|
134
124
|
require 'turnip/capybara'
|
125
|
+
|
126
|
+
configure_turnip_formatter report_name
|
127
|
+
end
|
128
|
+
|
129
|
+
def configure_turnip_formatter report_name
|
130
|
+
require 'turnip_formatter'
|
135
131
|
require 'gnawrnip'
|
136
132
|
|
137
133
|
RSpec.configure do |config|
|
138
134
|
config.add_formatter RSpecTurnipFormatter, report_name
|
139
|
-
# config.add_formatter 'progress'
|
140
|
-
# config.add_formatter 'documentation'
|
141
135
|
end
|
142
136
|
|
143
137
|
Gnawrnip.configure do |c|
|
144
138
|
c.make_animation = true
|
145
139
|
c.max_frame_size = 1024 # pixel
|
146
140
|
end
|
141
|
+
|
142
|
+
Gnawrnip.ready!
|
147
143
|
end
|
148
144
|
|
149
|
-
def
|
150
|
-
|
145
|
+
def metadata_from_scenario scenario
|
146
|
+
tags = scenario.source_tag_names.collect { |a| a.gsub("@", '') }
|
151
147
|
|
152
|
-
|
148
|
+
metadata = {}
|
153
149
|
|
154
|
-
|
155
|
-
|
156
|
-
break if driver
|
157
|
-
end
|
150
|
+
if tags.size > 0
|
151
|
+
tag = tags.first.to_sym
|
158
152
|
|
159
|
-
|
153
|
+
if driver_manager.supported_drivers.include? tag
|
154
|
+
metadata[:driver] = tag
|
155
|
+
end
|
156
|
+
end
|
160
157
|
|
161
|
-
|
158
|
+
metadata
|
162
159
|
end
|
163
160
|
|
164
|
-
|
165
|
-
# driver.to_s =~ /selenium/
|
166
|
-
# end
|
161
|
+
private
|
167
162
|
|
168
|
-
def
|
169
|
-
|
163
|
+
def init
|
164
|
+
# try to load capybara-related rspec library
|
165
|
+
begin
|
166
|
+
require 'capybara/rspec'
|
170
167
|
|
171
|
-
|
172
|
-
|
173
|
-
rspec_conf = object.example_group.parent_groups.last
|
174
|
-
else
|
175
|
-
rspec_conf = object
|
168
|
+
RSpec.configure do |conf|
|
169
|
+
conf.filter_run_excluding :exclude => true
|
176
170
|
end
|
177
|
-
else
|
178
|
-
rspec_conf = RSpec.configuration
|
179
|
-
end
|
180
|
-
|
181
|
-
rspec_conf.around(:each) do |example|
|
182
|
-
acceptance_test.before_test(example.metadata, page)
|
183
171
|
|
184
|
-
|
172
|
+
RSpec.configure do |conf|
|
173
|
+
conf.include Capybara::DSL
|
174
|
+
end
|
185
175
|
|
186
|
-
|
176
|
+
RSpec::Core::ExampleGroup.send :include, Capybara::DSL
|
177
|
+
rescue
|
178
|
+
;
|
187
179
|
end
|
188
180
|
end
|
189
181
|
|
190
|
-
|
182
|
+
def build_driver_name driver, browser, remote=false
|
183
|
+
name = ""
|
191
184
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
else
|
196
|
-
if config[:timeout_in_seconds]
|
197
|
-
config[:timeout_in_seconds]
|
198
|
-
else
|
199
|
-
Capybara.default_wait_time.to_s
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
185
|
+
name += driver ? "#{driver}_" : "#{Capybara.default_driver}_"
|
186
|
+
|
187
|
+
name += "#{browser}_" if browser
|
203
188
|
|
204
|
-
|
205
|
-
|
189
|
+
name += "remote" if remote
|
190
|
+
|
191
|
+
name = name[0..name.size-2] if name[name.size-1] == "_"
|
192
|
+
|
193
|
+
name = "unsupported" if name.size == 0
|
194
|
+
|
195
|
+
name.to_sym
|
206
196
|
end
|
207
197
|
|
208
|
-
# def self.get_localhost
|
209
|
-
# orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily
|
210
|
-
#
|
211
|
-
# UDPSocket.open do |s|
|
212
|
-
# s.connect '192.168.1.1', 1
|
213
|
-
# s.addr.last
|
214
|
-
# end
|
215
|
-
# ensure
|
216
|
-
# Socket.do_not_reverse_lookup = orig
|
217
|
-
# end
|
218
|
-
|
219
|
-
# ip = `ifconfig | grep 'inet ' | grep -v 127.0.0.1 | cut -d ' ' -f2`.strip
|
220
|
-
# Capybara.app_host = http://#{ip}:#{Capybara.server_port}
|
221
198
|
end
|
@@ -0,0 +1,221 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'singleton'
|
3
|
+
|
4
|
+
require 'active_support/core_ext/hash'
|
5
|
+
|
6
|
+
require 'acceptance_test/driver_manager'
|
7
|
+
require 'acceptance_test/gherkin_ext'
|
8
|
+
require 'acceptance_test/turnip_ext'
|
9
|
+
|
10
|
+
class AcceptanceTestOld
|
11
|
+
include Singleton
|
12
|
+
|
13
|
+
attr_reader :config, :driver_manager
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@driver_manager = DriverManager.new
|
17
|
+
|
18
|
+
@config = HashWithIndifferentAccess.new
|
19
|
+
|
20
|
+
@config[:browser] = 'firefox'
|
21
|
+
@config[:screenshot_dir] = File.expand_path('tmp')
|
22
|
+
end
|
23
|
+
|
24
|
+
def configure hash={}
|
25
|
+
config.merge!(HashWithIndifferentAccess.new(hash))
|
26
|
+
end
|
27
|
+
|
28
|
+
def setup
|
29
|
+
Capybara.app_host = AcceptanceTest.instance.config[:webapp_url]
|
30
|
+
|
31
|
+
Capybara.configure do |conf|
|
32
|
+
conf.default_wait_time = timeout_in_seconds
|
33
|
+
end
|
34
|
+
|
35
|
+
ENV['WAIT_TIME'] ||= Capybara.default_wait_time.to_s
|
36
|
+
|
37
|
+
Capybara.default_driver = :selenium
|
38
|
+
end
|
39
|
+
|
40
|
+
def teardown
|
41
|
+
Capybara.app_host = nil
|
42
|
+
|
43
|
+
Capybara.configure do |conf|
|
44
|
+
conf.default_wait_time = 5
|
45
|
+
end
|
46
|
+
|
47
|
+
Capybara.default_driver = :rack_test
|
48
|
+
end
|
49
|
+
|
50
|
+
def before_test metadata={}, page=nil
|
51
|
+
setup unless Capybara.app_host
|
52
|
+
|
53
|
+
driver = driver(metadata)
|
54
|
+
|
55
|
+
if driver
|
56
|
+
driver_name = driver_manager.register_driver driver, config[:browser].to_sym, config[:selenium_url]
|
57
|
+
|
58
|
+
if driver_name and Capybara.drivers[driver_name]
|
59
|
+
Capybara.current_driver = driver_name
|
60
|
+
Capybara.javascript_driver = driver_name
|
61
|
+
|
62
|
+
page.instance_variable_set(:@mode, driver_name) if page
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def after_test metadata={}, exception=nil, page=nil
|
68
|
+
driver = driver(metadata)
|
69
|
+
|
70
|
+
if driver and exception and page and not [:webkit].include? driver
|
71
|
+
screenshot_dir = File.expand_path(config[:screenshot_dir])
|
72
|
+
|
73
|
+
FileUtils.mkdir_p screenshot_dir
|
74
|
+
|
75
|
+
screenshot_maker = ScreenshotMaker.new screenshot_dir
|
76
|
+
|
77
|
+
screenshot_maker.make page, metadata
|
78
|
+
|
79
|
+
puts metadata[:full_description]
|
80
|
+
puts "Screenshot: #{screenshot_maker.screenshot_url(metadata)}"
|
81
|
+
end
|
82
|
+
|
83
|
+
Capybara.current_driver = Capybara.default_driver
|
84
|
+
Capybara.javascript_driver = Capybara.default_driver
|
85
|
+
end
|
86
|
+
|
87
|
+
def create_shared_context name
|
88
|
+
throw "rspec library is not available" unless defined? RSpec
|
89
|
+
|
90
|
+
acceptance_test = self
|
91
|
+
|
92
|
+
acceptance_test_lambda = lambda do
|
93
|
+
acceptance_test.configure_rspec self
|
94
|
+
end
|
95
|
+
|
96
|
+
RSpec.shared_context name do
|
97
|
+
self.define_singleton_method(:include_context, acceptance_test_lambda)
|
98
|
+
|
99
|
+
include_context
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def metadata_from_scenario scenario
|
104
|
+
tags = scenario.source_tag_names.collect { |a| a.gsub("@", '') }
|
105
|
+
|
106
|
+
metadata = {}
|
107
|
+
|
108
|
+
if tags.size > 0
|
109
|
+
tag = tags.first.to_sym
|
110
|
+
|
111
|
+
if driver_manager.supported_drivers.include? tag
|
112
|
+
metadata[:driver] = tag
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
metadata
|
117
|
+
end
|
118
|
+
|
119
|
+
def extend_turnip
|
120
|
+
shared_context_name = "#{random_name}AcceptanceTest"
|
121
|
+
|
122
|
+
create_shared_context shared_context_name
|
123
|
+
|
124
|
+
TurnipExt.shared_context_with_turnip shared_context_name
|
125
|
+
end
|
126
|
+
|
127
|
+
def enable_external_source data_reader
|
128
|
+
GherkinExt.enable_external_source data_reader
|
129
|
+
end
|
130
|
+
|
131
|
+
def configure_turnip_formatter report_name
|
132
|
+
require 'turnip/rspec'
|
133
|
+
require 'turnip_formatter'
|
134
|
+
require 'turnip/capybara'
|
135
|
+
require 'gnawrnip'
|
136
|
+
|
137
|
+
RSpec.configure do |config|
|
138
|
+
config.add_formatter RSpecTurnipFormatter, report_name
|
139
|
+
end
|
140
|
+
|
141
|
+
Gnawrnip.configure do |c|
|
142
|
+
c.make_animation = true
|
143
|
+
c.max_frame_size = 1024 # pixel
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def driver metadata
|
148
|
+
driver = ENV['DRIVER'].nil? ? nil : ENV['DRIVER'].to_sym
|
149
|
+
|
150
|
+
driver = config[:driver].to_sym if driver.nil? and config[:driver]
|
151
|
+
|
152
|
+
driver = metadata[:driver] if driver.nil?
|
153
|
+
|
154
|
+
driver_manager.supported_drivers.each do |supported_driver|
|
155
|
+
driver = supported_driver if metadata[supported_driver]
|
156
|
+
break if driver
|
157
|
+
end
|
158
|
+
|
159
|
+
driver = :webkit if driver.nil?
|
160
|
+
|
161
|
+
driver
|
162
|
+
end
|
163
|
+
|
164
|
+
# def selenium_driver? driver
|
165
|
+
# driver.to_s =~ /selenium/
|
166
|
+
# end
|
167
|
+
|
168
|
+
def configure_rspec object=nil
|
169
|
+
acceptance_test = self
|
170
|
+
|
171
|
+
if object
|
172
|
+
if object.kind_of? RSpec::Core::Example
|
173
|
+
rspec_conf = object.example_group.parent_groups.last
|
174
|
+
else
|
175
|
+
rspec_conf = object
|
176
|
+
end
|
177
|
+
else
|
178
|
+
rspec_conf = RSpec.configuration
|
179
|
+
end
|
180
|
+
|
181
|
+
rspec_conf.around(:each) do |example|
|
182
|
+
acceptance_test.before_test(example.metadata, page)
|
183
|
+
|
184
|
+
example.run
|
185
|
+
|
186
|
+
acceptance_test.after_test(example.metadata, example.exception, page)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
private
|
191
|
+
|
192
|
+
def timeout_in_seconds
|
193
|
+
if ENV['WAIT_TIME']
|
194
|
+
ENV['WAIT_TIME'].to_i
|
195
|
+
else
|
196
|
+
if config[:timeout_in_seconds]
|
197
|
+
config[:timeout_in_seconds]
|
198
|
+
else
|
199
|
+
Capybara.default_wait_time.to_s
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
def random_name
|
205
|
+
('a'..'z').to_a.shuffle[0, 12].join
|
206
|
+
end
|
207
|
+
|
208
|
+
# def self.get_localhost
|
209
|
+
# orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily
|
210
|
+
#
|
211
|
+
# UDPSocket.open do |s|
|
212
|
+
# s.connect '192.168.1.1', 1
|
213
|
+
# s.addr.last
|
214
|
+
# end
|
215
|
+
# ensure
|
216
|
+
# Socket.do_not_reverse_lookup = orig
|
217
|
+
# end
|
218
|
+
|
219
|
+
# ip = `ifconfig | grep 'inet ' | grep -v 127.0.0.1 | cut -d ' ' -f2`.strip
|
220
|
+
# Capybara.app_host = http://#{ip}:#{Capybara.server_port}
|
221
|
+
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'capybara'
|
2
|
-
#require "capybara/dsl"
|
3
2
|
|
4
3
|
class DriverManager
|
5
4
|
|
@@ -33,32 +32,51 @@ class DriverManager
|
|
33
32
|
[:selenium, :selenium_remote, :webkit, :poltergeist]
|
34
33
|
end
|
35
34
|
|
36
|
-
def register_driver
|
37
|
-
driver_name
|
35
|
+
def register_driver driver, browser, selenium_url=nil
|
36
|
+
driver_name = assign_driver_name(driver, browser)
|
38
37
|
|
39
38
|
if driver_name
|
40
39
|
unless Capybara.drivers[driver_name]
|
41
|
-
if
|
42
|
-
|
43
|
-
|
40
|
+
if selenium_url # remote
|
41
|
+
properties = {}
|
42
|
+
|
43
|
+
properties[:browser] = :remote
|
44
|
+
properties[:url] = selenium_url
|
45
|
+
#properties[:desired_capabilities] = capabilities if capabilities
|
46
|
+
|
47
|
+
driver_name = "#{driver_name}_remote".to_sym
|
48
|
+
|
49
|
+
Capybara.register_driver driver_name do |app|
|
50
|
+
Capybara::Selenium::Driver.new(app, properties)
|
44
51
|
end
|
45
52
|
else
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
#properties[:desired_capabilities] = capabilities if capabilities
|
53
|
+
case driver_name
|
54
|
+
when :poltergeist
|
55
|
+
require 'capybara/poltergeist'
|
50
56
|
|
51
|
-
|
57
|
+
Capybara.register_driver :poltergeist do |app|
|
58
|
+
Capybara::Poltergeist::Driver.new(app, { debug: false })
|
59
|
+
end
|
52
60
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
61
|
+
when :webkit
|
62
|
+
require "capybara-webkit"
|
63
|
+
|
64
|
+
when :firefox_with_firebug
|
65
|
+
require 'capybara/firebug'
|
58
66
|
|
59
|
-
|
60
|
-
|
61
|
-
|
67
|
+
# profile = Selenium::WebDriver::Firefox::Profile.new
|
68
|
+
# profile.enable_firebug
|
69
|
+
#
|
70
|
+
# properties[:desired_capabilities] = Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile => profile)
|
71
|
+
#properties[:desired_capabilities] = Selenium::WebDriver::Remote::Capabilities.internet_explorer
|
72
|
+
|
73
|
+
else
|
74
|
+
properties = {}
|
75
|
+
properties[:browser] = browser
|
76
|
+
|
77
|
+
Capybara.register_driver driver_name do |app|
|
78
|
+
Capybara::Selenium::Driver.new(app, properties)
|
79
|
+
end
|
62
80
|
end
|
63
81
|
end
|
64
82
|
end
|
@@ -67,74 +85,53 @@ class DriverManager
|
|
67
85
|
driver_name
|
68
86
|
end
|
69
87
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
driver_name =
|
76
|
-
case tag
|
77
|
-
when :webkit
|
78
|
-
require "capybara-webkit"
|
79
|
-
|
80
|
-
:webkit
|
88
|
+
def assign_driver_name driver, browser
|
89
|
+
case driver
|
90
|
+
when :webkit
|
91
|
+
:webkit
|
81
92
|
|
82
|
-
|
93
|
+
when :selenium
|
83
94
|
|
84
|
-
|
85
|
-
|
86
|
-
|
95
|
+
case browser
|
96
|
+
when :firefox
|
97
|
+
:selenium_firefox
|
87
98
|
|
88
|
-
|
89
|
-
|
99
|
+
when :firefox_with_firebug
|
100
|
+
:selenium_firefox_with_firebug
|
90
101
|
|
91
|
-
|
102
|
+
when :chrome
|
103
|
+
:selenium_chrome
|
92
104
|
|
93
|
-
|
94
|
-
|
105
|
+
when :safari
|
106
|
+
:selenium_safari
|
95
107
|
|
96
|
-
|
97
|
-
|
108
|
+
when :ie, :internet_explorer
|
109
|
+
:selenium_ie
|
98
110
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
else
|
103
|
-
:unsupported
|
104
|
-
end
|
105
|
-
|
106
|
-
when :poltergeist
|
107
|
-
require 'capybara/poltergeist'
|
108
|
-
|
109
|
-
:poltergeist
|
110
|
-
|
111
|
-
when :selenium_remote
|
112
|
-
case browser
|
113
|
-
when :firefox
|
114
|
-
:selenium_remote_firefox
|
115
|
-
|
116
|
-
when :firefox_with_firebug
|
117
|
-
require 'capybara/firebug'
|
111
|
+
else
|
112
|
+
:unsupported
|
113
|
+
end
|
118
114
|
|
119
|
-
|
120
|
-
|
115
|
+
when :poltergeist
|
116
|
+
:poltergeist
|
121
117
|
|
122
|
-
|
118
|
+
when :selenium_remote
|
119
|
+
case browser
|
120
|
+
when :firefox
|
121
|
+
:selenium_remote_firefox
|
123
122
|
|
124
|
-
|
123
|
+
when :firefox_with_firebug
|
124
|
+
:selenium_remote_firefox_with_firebug
|
125
125
|
|
126
|
-
|
127
|
-
|
126
|
+
when :ie
|
127
|
+
:selenium_remote_ie
|
128
128
|
|
129
|
-
:selenium_remote_ie
|
130
|
-
else
|
131
|
-
:unsupported
|
132
|
-
end
|
133
129
|
else
|
134
130
|
:unsupported
|
135
131
|
end
|
136
|
-
|
137
|
-
|
132
|
+
else
|
133
|
+
:unsupported
|
134
|
+
end
|
138
135
|
end
|
139
136
|
|
140
137
|
end
|
data/spec/acceptance_config.yml
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
webapp_url: 'http://www.wikipedia.org'
|
2
2
|
|
3
3
|
#selenium_url: 'http://localhost:4444/wd/hub'
|
4
|
-
selenium_url: 'http://10.111.74.226:4444/wd/hub'
|
4
|
+
#selenium_url: 'http://10.111.74.226:4444/wd/hub'
|
5
5
|
|
6
6
|
screenshot_dir: 'tmp'
|
7
7
|
|
8
|
-
browser: '
|
8
|
+
browser: 'chrome'
|
9
|
+
|
10
|
+
#driver: 'selenium'
|
9
11
|
|
10
12
|
timeout_in_seconds: 40
|
@@ -4,9 +4,9 @@ steps_for :search_with_drivers do
|
|
4
4
|
include CommonSteps
|
5
5
|
|
6
6
|
step "I am within wikipedia.com" do
|
7
|
-
|
7
|
+
AcceptanceTest.instance.setup page
|
8
8
|
|
9
|
-
|
9
|
+
puts Capybara.current_driver
|
10
10
|
end
|
11
11
|
|
12
12
|
step "I am on wikipedia.com" do
|
@@ -1,3 +1,9 @@
|
|
1
|
+
# enable external source for gherkin
|
2
|
+
|
3
|
+
data_reader = lambda {|source_path| CSV.read(File.expand_path(source_path)) }
|
4
|
+
|
5
|
+
AcceptanceTest.instance.enable_external_source data_reader
|
6
|
+
|
1
7
|
steps_for :search_with_examples_from_csv do
|
2
8
|
|
3
9
|
step "I am within wikipedia.com" do
|
data/spec/turnip_helper.rb
CHANGED
@@ -2,27 +2,22 @@ require 'yaml'
|
|
2
2
|
require 'csv'
|
3
3
|
require 'active_support/core_ext/hash'
|
4
4
|
|
5
|
+
require 'test_helper'
|
6
|
+
|
5
7
|
require 'acceptance_test'
|
6
8
|
|
7
|
-
|
9
|
+
AcceptanceTest.instance.configure(webapp_url: 'http://www.wikipedia.org')
|
10
|
+
# AcceptanceTest.instance.register_driver(:webkit)
|
11
|
+
# AcceptanceTest.instance.register_driver(:poltergeist)
|
12
|
+
|
13
|
+
AcceptanceTest.instance.configure_turnip 'tmp/report.html'
|
8
14
|
|
9
15
|
require 'steps/search_with_drivers_steps'
|
10
16
|
require 'steps/search_with_pages_steps'
|
11
17
|
require 'steps/search_with_examples_from_csv_steps'
|
12
18
|
require 'steps/search_with_table_steps'
|
13
19
|
|
14
|
-
acceptance_test = AcceptanceTest.instance
|
15
|
-
|
16
|
-
# enable external source for gherkin
|
17
|
-
|
18
|
-
data_reader = lambda {|source_path| CSV.read(File.expand_path(source_path)) }
|
19
20
|
|
20
|
-
acceptance_test.enable_external_source data_reader
|
21
21
|
|
22
|
-
acceptance_test.extend_turnip
|
23
|
-
acceptance_test.configure_turnip_formatter 'tmp/report.html'
|
24
22
|
|
25
|
-
config_name = File.expand_path("spec/acceptance_config.yml")
|
26
|
-
config = HashWithIndifferentAccess.new(YAML.load_file(config_name))
|
27
23
|
|
28
|
-
acceptance_test.configure config
|
@@ -1,22 +1,27 @@
|
|
1
1
|
require 'acceptance_test'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
AcceptanceTest.instance.configure({webapp_url: 'http://www.wikipedia.org', timeout_in_seconds: 10})
|
4
|
+
|
5
|
+
AcceptanceTest.instance.register_driver(:selenium, :chrome)
|
6
|
+
AcceptanceTest.instance.register_driver(:webkit)
|
7
|
+
AcceptanceTest.instance.register_driver(:poltergeist)
|
6
8
|
|
7
9
|
RSpec.describe 'Wikipedia Search' do
|
10
|
+
AcceptanceTest.instance.add_expectations(self)
|
8
11
|
|
9
12
|
before do
|
10
|
-
|
13
|
+
AcceptanceTest.instance.setup
|
14
|
+
AcceptanceTest.instance.use_driver(:selenium_chrome, page)
|
15
|
+
|
11
16
|
puts "Using driver: #{Capybara.current_driver}."
|
12
17
|
puts "Default wait time: #{Capybara.default_wait_time}."
|
13
18
|
end
|
14
19
|
|
15
20
|
after do
|
16
|
-
|
21
|
+
AcceptanceTest.instance.teardown
|
17
22
|
end
|
18
23
|
|
19
|
-
it "uses selenium driver"
|
24
|
+
it "uses selenium driver" do
|
20
25
|
visit('/')
|
21
26
|
|
22
27
|
fill_in "searchInput", :with => "Capybara"
|
@@ -1,22 +1,30 @@
|
|
1
|
-
require 'acceptance_test'
|
2
1
|
require 'yaml'
|
2
|
+
require 'active_support/core_ext/hash'
|
3
|
+
require 'acceptance_test'
|
3
4
|
|
4
5
|
config_name = File.expand_path("spec/acceptance_config.yml")
|
5
6
|
config = config_name ? HashWithIndifferentAccess.new(YAML.load_file(config_name)) : {}
|
6
7
|
|
7
|
-
|
8
|
-
acceptance_test.configure config
|
9
|
-
|
10
|
-
acceptance_test.create_shared_context "WikipediaAcceptanceTest"
|
8
|
+
AcceptanceTest.instance.configure(config)
|
11
9
|
|
12
10
|
puts "Application URL : #{config[:webapp_url]}" if config[:webapp_url]
|
13
11
|
puts "Selenium URL : #{config[:selenium_url]}" if config[:selenium_url]
|
14
12
|
puts "Default Wait Time : #{Capybara.default_wait_time}"
|
13
|
+
puts "Browser : #{config[:browser]}" if config[:browser]
|
15
14
|
|
16
15
|
RSpec.describe 'Wikipedia Search' do
|
17
|
-
|
16
|
+
AcceptanceTest.instance.add_expectations(self)
|
17
|
+
|
18
|
+
before do
|
19
|
+
AcceptanceTest.instance.setup
|
20
|
+
puts "Capybara current driver: #{Capybara.current_driver}"
|
21
|
+
end
|
22
|
+
|
23
|
+
after do
|
24
|
+
AcceptanceTest.instance.teardown
|
25
|
+
end
|
18
26
|
|
19
|
-
it "uses selenium driver"
|
27
|
+
it "uses selenium driver" do
|
20
28
|
visit('/')
|
21
29
|
|
22
30
|
fill_in "searchInput", :with => "Capybara"
|
@@ -1,17 +1,15 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
require 'acceptance_test'
|
1
|
+
# require 'acceptance_test'
|
4
2
|
|
5
3
|
# acceptance_test = AcceptanceTest.instance
|
6
4
|
# acceptance_test.configure({webapp_url: "http://www.wikipedia.org", timeout_in_seconds: 10})
|
7
5
|
# acceptance_test.configure_rspec
|
8
6
|
|
9
|
-
require "capybara"
|
10
|
-
require 'selenium/webdriver'
|
11
|
-
|
12
|
-
RSpec.configure do |config|
|
13
|
-
|
14
|
-
end
|
7
|
+
# require "capybara"
|
8
|
+
# require 'selenium/webdriver'
|
9
|
+
#
|
10
|
+
# RSpec.configure do |config|
|
11
|
+
# config.include Capybara::DSL
|
12
|
+
# end
|
15
13
|
|
16
14
|
# profile = Selenium::WebDriver::Chrome::Profile.new
|
17
15
|
# # profile['download.prompt_for_download'] = false
|
@@ -36,25 +34,37 @@ end
|
|
36
34
|
# Capybara.default_driver = :selenium_remote
|
37
35
|
|
38
36
|
|
39
|
-
Capybara.register_driver :selenium_chrome do |app|
|
40
|
-
|
41
|
-
end
|
37
|
+
# Capybara.register_driver :selenium_chrome do |app|
|
38
|
+
# Capybara::Selenium::Driver.new(app, browser: :chrome)
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# Capybara.app_host = "http://www.wikipedia.org"
|
42
|
+
# Capybara.default_driver = :selenium_chrome
|
43
|
+
|
44
|
+
require 'acceptance_test'
|
42
45
|
|
43
|
-
|
44
|
-
Capybara.default_driver = :selenium_chrome
|
46
|
+
AcceptanceTest.instance.configure({webapp_url: 'http://www.wikipedia.org', timeout_in_seconds: 10})
|
45
47
|
|
48
|
+
require 'test_helper'
|
46
49
|
require 'pages/wikipedia_pages'
|
47
50
|
|
48
51
|
RSpec.describe 'Wikipedia Search' do
|
52
|
+
AcceptanceTest.instance.add_expectations(self)
|
49
53
|
|
50
54
|
let(:page_set) { WikipediaPages.new(page) }
|
51
55
|
|
52
56
|
before do
|
57
|
+
AcceptanceTest.instance.setup
|
58
|
+
|
53
59
|
puts "Using driver: #{Capybara.current_driver}."
|
54
60
|
puts "Default wait time: #{Capybara.default_wait_time}."
|
55
61
|
end
|
56
62
|
|
57
|
-
|
63
|
+
after do
|
64
|
+
AcceptanceTest.instance.teardown
|
65
|
+
end
|
66
|
+
|
67
|
+
it "searches on wikipedia web site" do
|
58
68
|
page_set.execute do
|
59
69
|
visit_home_page
|
60
70
|
|
@@ -6,10 +6,11 @@ RSpec.configure do |config|
|
|
6
6
|
config.include Capybara::DSL
|
7
7
|
end
|
8
8
|
|
9
|
-
Capybara.app_host = "http://www.wikipedia.org"
|
10
|
-
Capybara.default_driver = :selenium
|
11
|
-
|
12
9
|
RSpec.describe "Searching" do
|
10
|
+
before do
|
11
|
+
Capybara.app_host = "http://www.wikipedia.org"
|
12
|
+
Capybara.default_driver = :selenium
|
13
|
+
end
|
13
14
|
|
14
15
|
Steps "Result found" do
|
15
16
|
Given "I am on wikipedia.com" do
|
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.6.
|
4
|
+
version: 1.6.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-10-
|
11
|
+
date: 2014-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gemspec_deps_gen
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- features/wikipedia/wikipedia_search_from_csv.feature
|
72
72
|
- lib/acceptance_test.rb
|
73
73
|
- lib/acceptance_test/acceptance_test.rb
|
74
|
+
- lib/acceptance_test/acceptance_test_old.rb
|
74
75
|
- lib/acceptance_test/driver_manager.rb
|
75
76
|
- lib/acceptance_test/gherkin_ext.rb
|
76
77
|
- lib/acceptance_test/page.rb
|