acceptance_test 1.6.2 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NzgxZjE5NWZhZGM2NjRhYTA5MmNhZGI5ZmVmMDBjNWExMTRiYWIxOA==
5
- data.tar.gz: !binary |-
6
- NjUyNTg4YjcxNTAwMjY3YzY0OWFkOGU3ZWQ3OWMyNjZlMTNkOTVlYQ==
2
+ SHA1:
3
+ metadata.gz: c5a6f1452bd6f0adc7050128629b5b67a5abe04e
4
+ data.tar.gz: dd7caafa384ec0312421cfbdd35e07ee9f458f1c
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- Y2M0ZDQ3MGRjMzA3MWQ0ZTg0NmU5MzA5ZDUwMjljMjQzYmNjYjI1YmYzZjBh
10
- NjBjOTJlYzI3N2U1ZTIzYmIxMGZkODc2NmU4Zjc3NmE3Yzg3NTI0MDA0YmUz
11
- ZmU2MmIzZmVjMTJiMTA5MTRlYmI1NWZlM2Y3YzcwY2I5YWFjOGY=
12
- data.tar.gz: !binary |-
13
- NTRlYTk4ZWRmYmQ2ZjQwNmZhNzMwOTI3ZjczNmIyYjdkZjZlODFjZWI3OTNl
14
- NTBhNGE3ZTE5YzgxMzE2NjU2NTkyZjMyMTgwNjE1MDkwZmY5ZmM2MmVjNWNh
15
- NzQ4ZDI4NzIxNjFiOWRlMzZhOGU3ODBlOWVlNTU3NTAxM2NhMGQ=
6
+ metadata.gz: f393d462ed43fff25f4a7c82c6fc113a92ddcbebb8de0a6c90a22d930c84f2e8973f698d47954f74fc4890be313488b32f50203df97e561c43cf31c193bcc370
7
+ data.tar.gz: 5296f06d5e1c2fc379ee70aff80ba6ab3b200b3017d32842b1a41fd102736c673e48cd0ce30e7bc5dd5ba9df7fbe31e7f96b8a65efe312775e7d011f644795f1
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 1.9.3
1
+ 2.1.3
data/CHANGES CHANGED
@@ -147,4 +147,8 @@
147
147
 
148
148
  == Version 1.7.0
149
149
 
150
- * Refactor the code
150
+ * Refactor the code
151
+
152
+ == Version 1.7.1
153
+
154
+ * Bug fixes
data/Gemfile CHANGED
@@ -36,9 +36,9 @@ group :acceptance_test do
36
36
  gem "poltergeist", "~> 1.5.1"
37
37
  end
38
38
 
39
- group :debug do
40
- gem "debugger-ruby_core_source"
41
- gem "ruby-debug-base19x", "0.11.30.pre12"
42
- gem "ruby-debug-ide", "0.4.17"
43
- end
39
+ # group :debug do
40
+ # gem "debugger-ruby_core_source"
41
+ # gem "ruby-debug-base19x", "0.11.30.pre12"
42
+ # gem "ruby-debug-ide", "0.4.17"
43
+ # end
44
44
 
data/Gemfile.lock CHANGED
@@ -30,7 +30,6 @@ GEM
30
30
  gherkin (~> 2.12)
31
31
  multi_json (>= 1.7.5, < 2.0)
32
32
  multi_test (>= 0.1.1)
33
- debugger-ruby_core_source (1.3.5)
34
33
  diff-lcs (1.2.5)
35
34
  ffi (1.9.6)
36
35
  file_utils (1.0.7)
@@ -66,7 +65,6 @@ GEM
66
65
  rack (1.5.2)
67
66
  rack-test (0.6.2)
68
67
  rack (>= 1.0)
69
- rake (10.3.2)
70
68
  rspec (3.1.0)
71
69
  rspec-core (~> 3.1.0)
72
70
  rspec-expectations (~> 3.1.0)
@@ -81,11 +79,6 @@ GEM
81
79
  rspec-mocks (3.1.3)
82
80
  rspec-support (~> 3.1.0)
83
81
  rspec-support (3.1.2)
84
- ruby-debug-base19x (0.11.30.pre12)
85
- debugger-ruby_core_source (>= 1.1.4)
86
- rake (>= 0.8.1)
87
- ruby-debug-ide (0.4.17)
88
- rake (>= 0.8.1)
89
82
  rubyzip (1.1.6)
90
83
  selenium-webdriver (2.43.0)
91
84
  childprocess (~> 0.5)
@@ -121,7 +114,6 @@ DEPENDENCIES
121
114
  capybara-firebug (~> 2.1.0)
122
115
  capybara-webkit (~> 1.3.0)
123
116
  cucumber (~> 1.3.17)
124
- debugger-ruby_core_source
125
117
  gemcutter
126
118
  gemspec_deps_gen
127
119
  gnawrnip
@@ -129,8 +121,6 @@ DEPENDENCIES
129
121
  poltergeist (~> 1.5.1)
130
122
  rspec
131
123
  rspec-example_steps (~> 3.0.2)
132
- ruby-debug-base19x (= 0.11.30.pre12)
133
- ruby-debug-ide (= 0.4.17)
134
124
  selenium-webdriver (~> 2.43.0)
135
125
  turnip (~> 1.2.4)
136
126
  turnip_formatter
@@ -1,16 +1,18 @@
1
1
  require 'singleton'
2
+ require 'capybara'
2
3
  require 'active_support/core_ext/hash'
3
4
 
5
+ require 'acceptance_test/shared_context_builder'
6
+ require 'acceptance_test/driver_manager'
4
7
  require 'acceptance_test/gherkin_ext'
8
+ require 'acceptance_test/turnip_ext'
5
9
 
6
10
  class AcceptanceTest
7
11
  include Singleton
8
12
 
9
- attr_reader :config
13
+ attr_reader :config, :driver_manager
10
14
 
11
15
  def initialize
12
- require 'capybara'
13
-
14
16
  Capybara.default_driver = :selenium
15
17
 
16
18
  @config = HashWithIndifferentAccess.new
@@ -19,23 +21,20 @@ class AcceptanceTest
19
21
  @config[:screenshot_dir] = File.expand_path('tmp')
20
22
  @config[:timeout_in_seconds] = 20
21
23
 
22
- init
24
+ @driver_manager = DriverManager.new
23
25
  end
24
26
 
25
27
  def configure hash={}
26
28
  config.merge!(HashWithIndifferentAccess.new(hash))
27
29
  end
28
30
 
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)
31
+ def setup page=nil, metadata={}
32
+ driver = driver(metadata)
33
+ browser = browser(metadata)
35
34
 
36
- driver_name = build_driver_name(driver, browser, remote)
35
+ driver_name = driver_manager.register_driver(driver, browser, config[:selenium_url])
37
36
 
38
- use_driver(driver_name, page)
37
+ driver_manager.use_driver(driver_name, page)
39
38
 
40
39
  Capybara.app_host = config[:webapp_url]
41
40
 
@@ -48,71 +47,42 @@ class AcceptanceTest
48
47
  end
49
48
  end
50
49
 
51
- def teardown
52
- Capybara.app_host = nil
53
-
54
- Capybara.configure do |conf|
55
- conf.default_wait_time = 2
56
- end
57
-
58
- Capybara.default_driver = :rack_test
59
- end
50
+ def teardown page=nil, metadata={}, exception=nil
51
+ driver = driver(metadata)
60
52
 
61
- def register_driver(driver, browser=:firefox, remote=false)
62
- driver_name = build_driver_name(driver, browser, remote)
53
+ if driver and exception and page and not [:webkit].include? driver
54
+ screenshot_dir = File.expand_path(config[:screenshot_dir])
63
55
 
64
- case driver
65
- when :poltergeist
66
- require 'capybara/poltergeist'
56
+ FileUtils.mkdir_p screenshot_dir
67
57
 
68
- when :webkit
69
- require "capybara-webkit"
58
+ screenshot_maker = ScreenshotMaker.new screenshot_dir
70
59
 
71
- when :firefox_with_firebug
72
- require 'capybara/firebug'
60
+ screenshot_maker.make page, metadata
73
61
 
74
- else
75
- ;
62
+ puts metadata[:full_description]
63
+ puts "Screenshot: #{screenshot_maker.screenshot_url(metadata)}"
76
64
  end
77
65
 
78
- if driver == :poltergeist
79
- properties = {}
80
- properties[:debug] = false
81
-
82
- Capybara.register_driver :poltergeist do |app|
83
- Capybara::Poltergeist::Driver.new(app, properties)
84
- end
85
- else
86
- properties = {}
87
- properties[:browser] = browser
66
+ Capybara.app_host = nil
88
67
 
89
- Capybara.register_driver driver_name do |app|
90
- Capybara::Selenium::Driver.new(app, properties)
91
- end
68
+ Capybara.configure do |conf|
69
+ conf.default_wait_time = 2
92
70
  end
93
71
 
94
- driver_name
72
+ Capybara.current_driver = Capybara.default_driver
73
+ Capybara.javascript_driver = Capybara.default_driver
95
74
  end
96
75
 
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
102
-
103
- def use_driver driver, page=nil
104
- if driver and Capybara.drivers[driver]
105
- Capybara.current_driver = driver
106
- Capybara.javascript_driver = driver
107
-
108
- page.instance_variable_set(:@mode, driver) if page
109
- end
76
+ def create_shared_context name
77
+ SharedContextBuilder.instance.build name, self
110
78
  end
111
79
 
112
- def add_expectations context
113
- require 'rspec/expectations'
80
+ def extend_turnip
81
+ shared_context_name = "#{random_name}AcceptanceTest"
114
82
 
115
- context.send :include, Capybara::DSL
83
+ SharedContextBuilder.instance.build shared_context_name, self
84
+
85
+ TurnipExt.shared_context_with_turnip shared_context_name
116
86
  end
117
87
 
118
88
  def enable_external_source data_reader
@@ -124,6 +94,8 @@ class AcceptanceTest
124
94
  require 'turnip/capybara'
125
95
 
126
96
  configure_turnip_formatter report_name
97
+
98
+ extend_turnip
127
99
  end
128
100
 
129
101
  def configure_turnip_formatter report_name
@@ -142,57 +114,44 @@ class AcceptanceTest
142
114
  Gnawrnip.ready!
143
115
  end
144
116
 
145
- def metadata_from_scenario scenario
146
- tags = scenario.source_tag_names.collect { |a| a.gsub("@", '') }
147
-
148
- metadata = {}
149
-
150
- if tags.size > 0
151
- tag = tags.first.to_sym
152
-
153
- if driver_manager.supported_drivers.include? tag
154
- metadata[:driver] = tag
155
- end
156
- end
117
+ private
157
118
 
158
- metadata
159
- end
119
+ def driver metadata
120
+ driver = ENV['DRIVER'].nil? ? nil : ENV['DRIVER'].to_sym
160
121
 
161
- private
122
+ driver = config[:driver].to_sym if driver.nil? and config[:driver]
162
123
 
163
- def init
164
- # try to load capybara-related rspec library
165
- begin
166
- require 'capybara/rspec'
124
+ driver = metadata[:driver] if driver.nil?
167
125
 
168
- RSpec.configure do |conf|
169
- conf.filter_run_excluding :exclude => true
170
- end
126
+ driver_manager.supported_drivers.each do |supported_driver|
127
+ driver = supported_driver if metadata[supported_driver]
128
+ break if driver
129
+ end if driver.nil?
171
130
 
172
- RSpec.configure do |conf|
173
- conf.include Capybara::DSL
174
- end
131
+ driver = :webkit if driver.nil?
175
132
 
176
- RSpec::Core::ExampleGroup.send :include, Capybara::DSL
177
- rescue
178
- ;
179
- end
133
+ driver
180
134
  end
181
135
 
182
- def build_driver_name driver, browser, remote=false
183
- name = ""
136
+ def browser metadata
137
+ browser = ENV['BROWSER'].nil? ? nil : ENV['BROWSER'].to_sym
184
138
 
185
- name += driver ? "#{driver}_" : "#{Capybara.default_driver}_"
139
+ browser = config[:browser].to_sym if browser.nil?
186
140
 
187
- name += "#{browser}_" if browser
141
+ browser = metadata[:browser] if browser.nil?
188
142
 
189
- name += "remote" if remote
143
+ driver_manager.supported_browsers.each do |supported_browser|
144
+ browser = supported_browser if metadata[supported_browser]
145
+ break if browser
146
+ end if browser.nil?
190
147
 
191
- name = name[0..name.size-2] if name[name.size-1] == "_"
148
+ browser = :firefox if browser.nil?
192
149
 
193
- name = "unsupported" if name.size == 0
150
+ browser
151
+ end
194
152
 
195
- name.to_sym
153
+ def random_name
154
+ ('a'..'z').to_a.shuffle[0, 12].join
196
155
  end
197
156
 
198
157
  end
@@ -0,0 +1,17 @@
1
+ class CucumberExt
2
+ def self.metadata_from_scenario scenario
3
+ tags = scenario.source_tag_names.collect { |a| a.gsub("@", '') }
4
+
5
+ metadata = {}
6
+
7
+ if tags.size > 0
8
+ tag = tags.first.to_sym
9
+
10
+ if AcceptanceTest.instance.driver_manager.supported_drivers.include? tag
11
+ metadata[:driver] = tag
12
+ end
13
+ end
14
+
15
+ metadata
16
+ end
17
+ end
@@ -3,13 +3,6 @@ require 'capybara'
3
3
  class DriverManager
4
4
 
5
5
  def initialize
6
- Capybara.configure do |conf|
7
- #conf.default_wait_time = timeout_in_seconds
8
- conf.match = :first
9
-
10
- conf.ignore_hidden_elements = false
11
- end
12
-
13
6
  # try to load capybara-related rspec library
14
7
  begin
15
8
  require 'capybara/rspec'
@@ -29,109 +22,94 @@ class DriverManager
29
22
  end
30
23
 
31
24
  def supported_drivers
32
- [:selenium, :selenium_remote, :webkit, :poltergeist]
25
+ [:selenium, :webkit, :poltergeist]
33
26
  end
34
27
 
35
- def register_driver driver, browser, selenium_url=nil
36
- driver_name = assign_driver_name(driver, browser)
37
-
38
- if driver_name
39
- unless Capybara.drivers[driver_name]
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)
51
- end
52
- else
53
- case driver_name
54
- when :poltergeist
55
- require 'capybara/poltergeist'
56
-
57
- Capybara.register_driver :poltergeist do |app|
58
- Capybara::Poltergeist::Driver.new(app, { debug: false })
59
- end
60
-
61
- when :webkit
62
- require "capybara-webkit"
63
-
64
- when :firefox_with_firebug
65
- require 'capybara/firebug'
66
-
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
80
- end
81
- end
82
- end
83
- end
84
-
85
- driver_name
28
+ def supported_browsers
29
+ [:firefox, :chrome]
86
30
  end
87
31
 
88
- def assign_driver_name driver, browser
32
+ def register_driver(driver, browser=:firefox, selenium_url=nil)
33
+ driver_name = build_driver_name(driver, browser, selenium_url)
34
+
89
35
  case driver
36
+ when :poltergeist
37
+ require 'capybara/poltergeist'
38
+
90
39
  when :webkit
91
- :webkit
40
+ require "capybara-webkit"
92
41
 
93
- when :selenium
42
+ when :firefox_with_firebug
43
+ require 'capybara/firebug'
94
44
 
95
- case browser
96
- when :firefox
97
- :selenium_firefox
45
+ else
46
+ ;
47
+ end
98
48
 
99
- when :firefox_with_firebug
100
- :selenium_firefox_with_firebug
49
+ if driver == :poltergeist
50
+ properties = {}
51
+ properties[:debug] = false
101
52
 
102
- when :chrome
103
- :selenium_chrome
53
+ Capybara.register_driver :poltergeist do |app|
54
+ Capybara::Poltergeist::Driver.new(app, properties)
55
+ end
56
+ elsif driver == :webkit
57
+ ;
58
+ else
59
+ properties = {}
104
60
 
105
- when :safari
106
- :selenium_safari
61
+ if selenium_url
62
+ properties[:browser] = :remote
63
+ properties[:url] = selenium_url
64
+ #properties[:desired_capabilities] = capabilities if capabilities
107
65
 
108
- when :ie, :internet_explorer
109
- :selenium_ie
66
+ # profile = Selenium::WebDriver::Firefox::Profile.new
67
+ # profile.enable_firebug
68
+ #
69
+ # properties[:desired_capabilities] = Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile => profile)
70
+ #properties[:desired_capabilities] = Selenium::WebDriver::Remote::Capabilities.internet_explorer
110
71
 
111
- else
112
- :unsupported
113
- end
72
+ else
73
+ properties[:browser] = browser
74
+ end
114
75
 
115
- when :poltergeist
116
- :poltergeist
76
+ Capybara.register_driver driver_name do |app|
77
+ Capybara::Selenium::Driver.new(app, properties)
78
+ end
79
+ end
80
+
81
+ driver_name
82
+ end
83
+
84
+ def use_driver driver, page=nil
85
+ if driver and Capybara.drivers[driver]
86
+ Capybara.current_driver = driver
87
+ Capybara.javascript_driver = driver
88
+
89
+ page.instance_variable_set(:@mode, driver) if page
90
+ end
91
+ end
117
92
 
118
- when :selenium_remote
119
- case browser
120
- when :firefox
121
- :selenium_remote_firefox
93
+ private
122
94
 
123
- when :firefox_with_firebug
124
- :selenium_remote_firefox_with_firebug
95
+ def build_driver_name driver, browser, selenium_url=nil
96
+ case driver
97
+ when :webkit
98
+ :webkit
99
+ when :poltergeist
100
+ :poltergeist
101
+ when :selenium
102
+ name = ""
103
+ name += driver ? "#{driver}_" : "#{Capybara.default_driver}_"
125
104
 
126
- when :ie
127
- :selenium_remote_ie
105
+ name += "#{browser}_" if browser
106
+ name += "remote" if selenium_url
107
+ name = name[0..name.size-2] if name[name.size-1] == "_"
128
108
 
129
- else
130
- :unsupported
131
- end
109
+ name.to_sym
132
110
  else
133
111
  :unsupported
134
- end
112
+ end
135
113
  end
136
114
 
137
- end
115
+ end
@@ -0,0 +1,55 @@
1
+ require 'singleton'
2
+
3
+ class SharedContextBuilder
4
+ include Singleton
5
+
6
+ def build name, acceptance_test
7
+ throw "rspec library is not available" unless defined? RSpec
8
+
9
+ parent = self
10
+
11
+ acceptance_test_lambda = lambda do
12
+ parent.configure_rspec acceptance_test, self
13
+ end
14
+
15
+ RSpec.shared_context name do
16
+ self.define_singleton_method(:include_context, acceptance_test_lambda)
17
+
18
+ include_context
19
+ end
20
+ end
21
+
22
+ def configure_rspec acceptance_test, object=nil
23
+ # acceptance_test = self
24
+
25
+ # if object
26
+ # if object.kind_of? RSpec::Core::Example
27
+ # rspec_conf = object.example_group.parent_groups.last
28
+ # else
29
+ # rspec_conf = object
30
+ # end
31
+ # else
32
+ # rspec_conf = RSpec.configuration
33
+ # end
34
+
35
+ rspec_conf = object
36
+
37
+ rspec_conf.around(:each) do |example|
38
+ old_driver = Capybara.current_driver
39
+
40
+ acceptance_test.setup(page, example.metadata)
41
+
42
+ new_driver = Capybara.current_driver
43
+
44
+ if old_driver != new_driver
45
+ example.metadata.delete(old_driver)
46
+ example.metadata[new_driver] = true
47
+ end
48
+
49
+ example.run
50
+
51
+ acceptance_test.teardown(page, example.metadata, example.exception)
52
+ end
53
+ end
54
+
55
+ end
@@ -1,3 +1,3 @@
1
1
  class AcceptanceTest
2
- VERSION = "1.6.2"
2
+ VERSION = "1.7.1"
3
3
  end
@@ -7,6 +7,6 @@ screenshot_dir: 'tmp'
7
7
 
8
8
  browser: 'chrome'
9
9
 
10
- #driver: 'selenium'
10
+ driver: 'selenium'
11
11
 
12
12
  timeout_in_seconds: 40
@@ -4,8 +4,6 @@ steps_for :search_with_drivers do
4
4
  include CommonSteps
5
5
 
6
6
  step "I am within wikipedia.com" do
7
- AcceptanceTest.instance.setup page
8
-
9
7
  puts Capybara.current_driver
10
8
  end
11
9
 
@@ -7,7 +7,6 @@ AcceptanceTest.instance.enable_external_source data_reader
7
7
  steps_for :search_with_examples_from_csv do
8
8
 
9
9
  step "I am within wikipedia.com" do
10
- AcceptanceTest.instance.setup
11
10
  end
12
11
 
13
12
  step "I am on wikipedia.com" do
@@ -7,8 +7,6 @@ steps_for :search_with_pages do
7
7
  attr_reader :page_set
8
8
 
9
9
  step "I am within wikipedia.com" do
10
- AcceptanceTest.instance.setup
11
-
12
10
  puts Capybara.current_driver
13
11
 
14
12
  @page_set = WikipediaPages.new(page)
@@ -1,6 +1,5 @@
1
1
  steps_for :search_with_table do
2
2
  step "I am within wikipedia.com" do
3
- AcceptanceTest.instance.setup
4
3
  end
5
4
 
6
5
  step "I am on wikipedia.com" do
@@ -6,7 +6,12 @@ require 'test_helper'
6
6
 
7
7
  require 'acceptance_test'
8
8
 
9
- AcceptanceTest.instance.configure(webapp_url: 'http://www.wikipedia.org')
9
+ config_name = File.expand_path("spec/acceptance_config.yml")
10
+ config = config_name ? HashWithIndifferentAccess.new(YAML.load_file(config_name)) : {}
11
+
12
+ AcceptanceTest.instance.configure(config)
13
+
14
+ # AcceptanceTest.instance.configure(webapp_url: 'http://www.wikipedia.org')
10
15
  # AcceptanceTest.instance.register_driver(:webkit)
11
16
  # AcceptanceTest.instance.register_driver(:poltergeist)
12
17
 
@@ -1,17 +1,18 @@
1
+ require 'rspec/expectations'
1
2
  require 'acceptance_test'
2
3
 
3
4
  AcceptanceTest.instance.configure({webapp_url: 'http://www.wikipedia.org', timeout_in_seconds: 10})
4
5
 
5
- AcceptanceTest.instance.register_driver(:selenium, :chrome)
6
- AcceptanceTest.instance.register_driver(:webkit)
7
- AcceptanceTest.instance.register_driver(:poltergeist)
6
+ AcceptanceTest.instance.driver_manager.register_driver(:selenium, :chrome)
7
+ AcceptanceTest.instance.driver_manager.register_driver(:webkit)
8
+ AcceptanceTest.instance.driver_manager.register_driver(:poltergeist)
8
9
 
9
10
  RSpec.describe 'Wikipedia Search' do
10
- AcceptanceTest.instance.add_expectations(self)
11
+ include Capybara::DSL
11
12
 
12
13
  before do
13
14
  AcceptanceTest.instance.setup
14
- AcceptanceTest.instance.use_driver(:selenium_chrome, page)
15
+ AcceptanceTest.instance.driver_manager.use_driver(:selenium_chrome)
15
16
 
16
17
  puts "Using driver: #{Capybara.current_driver}."
17
18
  puts "Default wait time: #{Capybara.default_wait_time}."
@@ -1,22 +1,25 @@
1
1
  require 'yaml'
2
2
  require 'active_support/core_ext/hash'
3
3
  require 'acceptance_test'
4
+ require 'rspec/expectations'
4
5
 
5
6
  config_name = File.expand_path("spec/acceptance_config.yml")
6
7
  config = config_name ? HashWithIndifferentAccess.new(YAML.load_file(config_name)) : {}
7
8
 
8
9
  AcceptanceTest.instance.configure(config)
9
10
 
11
+ AcceptanceTest.instance.create_shared_context "WikipediaAcceptanceTest"
12
+
10
13
  puts "Application URL : #{config[:webapp_url]}" if config[:webapp_url]
11
14
  puts "Selenium URL : #{config[:selenium_url]}" if config[:selenium_url]
12
15
  puts "Default Wait Time : #{Capybara.default_wait_time}"
13
16
  puts "Browser : #{config[:browser]}" if config[:browser]
14
17
 
15
18
  RSpec.describe 'Wikipedia Search' do
16
- AcceptanceTest.instance.add_expectations(self)
19
+ include Capybara::DSL
20
+ include_context "WikipediaAcceptanceTest"
17
21
 
18
22
  before do
19
- AcceptanceTest.instance.setup
20
23
  puts "Capybara current driver: #{Capybara.current_driver}"
21
24
  end
22
25
 
@@ -1,15 +1,6 @@
1
- # require 'acceptance_test'
2
-
3
- # acceptance_test = AcceptanceTest.instance
4
- # acceptance_test.configure({webapp_url: "http://www.wikipedia.org", timeout_in_seconds: 10})
5
- # acceptance_test.configure_rspec
1
+ require 'acceptance_test'
2
+ require 'rspec/expectations'
6
3
 
7
- # require "capybara"
8
- # require 'selenium/webdriver'
9
- #
10
- # RSpec.configure do |config|
11
- # config.include Capybara::DSL
12
- # end
13
4
 
14
5
  # profile = Selenium::WebDriver::Chrome::Profile.new
15
6
  # # profile['download.prompt_for_download'] = false
@@ -25,31 +16,15 @@
25
16
  #
26
17
  # # ENV['webdriver.chrome.driver'] = "c:\work\selenium-server\chromedriver.exe"
27
18
  # #properties[:desired_capabilities]['webdriver.chrome.driver'] = "c:\work\selenium-server\chromedriver.exe"
28
- #
29
- # Capybara.register_driver :selenium_remote do |app|
30
- # Capybara::Selenium::Driver.new(app, properties)
31
- # end
32
- #
33
- # Capybara.app_host = "http://www.wikipedia.org"
34
- # Capybara.default_driver = :selenium_remote
35
-
36
-
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'
45
19
 
46
- AcceptanceTest.instance.configure({webapp_url: 'http://www.wikipedia.org', timeout_in_seconds: 10})
20
+ AcceptanceTest.instance.configure({webapp_url: 'http://www.wikipedia.org', timeout_in_seconds: 10,
21
+ driver: :selenium, browser: :chrome})
47
22
 
48
23
  require 'test_helper'
49
24
  require 'pages/wikipedia_pages'
50
25
 
51
26
  RSpec.describe 'Wikipedia Search' do
52
- AcceptanceTest.instance.add_expectations(self)
27
+ include Capybara::DSL
53
28
 
54
29
  let(:page_set) { WikipediaPages.new(page) }
55
30
 
metadata CHANGED
@@ -1,62 +1,62 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acceptance_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.2
4
+ version: 1.7.1
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-17 00:00:00.000000000 Z
11
+ date: 2014-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gemspec_deps_gen
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: gemcutter
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description: ! 'Description: simplifies congiguration and run of acceptance tests.'
41
+ description: 'Description: simplifies congiguration and run of acceptance tests.'
42
42
  email: alexander.shvets@gmail.com
43
43
  executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
- - .gitignore
48
- - .idea/.rakeTasks
49
- - .idea/acceptance_test.iml
50
- - .idea/encodings.xml
51
- - .idea/jenkinsSettings.xml
52
- - .idea/misc.xml
53
- - .idea/modules.xml
54
- - .idea/runConfigurations/wikipedia_search__acceptance_test.xml
55
- - .idea/scopes/scope_settings.xml
56
- - .idea/vcs.xml
57
- - .rspec
58
- - .ruby-gemset
59
- - .ruby-version
47
+ - ".gitignore"
48
+ - ".idea/.rakeTasks"
49
+ - ".idea/acceptance_test.iml"
50
+ - ".idea/encodings.xml"
51
+ - ".idea/jenkinsSettings.xml"
52
+ - ".idea/misc.xml"
53
+ - ".idea/modules.xml"
54
+ - ".idea/runConfigurations/wikipedia_search__acceptance_test.xml"
55
+ - ".idea/scopes/scope_settings.xml"
56
+ - ".idea/vcs.xml"
57
+ - ".rspec"
58
+ - ".ruby-gemset"
59
+ - ".ruby-version"
60
60
  - CHANGES
61
61
  - Gemfile
62
62
  - Gemfile.lock
@@ -72,11 +72,13 @@ files:
72
72
  - lib/acceptance_test.rb
73
73
  - lib/acceptance_test/acceptance_test.rb
74
74
  - lib/acceptance_test/acceptance_test_old.rb
75
+ - lib/acceptance_test/cucumber_ext.rb
75
76
  - lib/acceptance_test/driver_manager.rb
76
77
  - lib/acceptance_test/gherkin_ext.rb
77
78
  - lib/acceptance_test/page.rb
78
79
  - lib/acceptance_test/page_set.rb
79
80
  - lib/acceptance_test/screenshot_maker.rb
81
+ - lib/acceptance_test/shared_context_builder.rb
80
82
  - lib/acceptance_test/turnip_ext.rb
81
83
  - lib/acceptance_test/version.rb
82
84
  - lib/tasks/rspec.rake
@@ -109,12 +111,12 @@ require_paths:
109
111
  - lib
110
112
  required_ruby_version: !ruby/object:Gem::Requirement
111
113
  requirements:
112
- - - ! '>='
114
+ - - ">="
113
115
  - !ruby/object:Gem::Version
114
116
  version: '0'
115
117
  required_rubygems_version: !ruby/object:Gem::Requirement
116
118
  requirements:
117
- - - ! '>='
119
+ - - ">="
118
120
  - !ruby/object:Gem::Version
119
121
  version: '0'
120
122
  requirements: []