acceptance_test 1.7.2 → 1.7.3

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 CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ae34aa2cd47d1bbb0ef858917ccf9e96abfb287e
4
- data.tar.gz: 74123d56a4ce80ecfb91b7c1fde908c27f26971e
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZDgwYTc1YmQxNjhlMmRlOGRlOTk4OWVjYjMxNWU3YmM3ZDJiYWFkNg==
5
+ data.tar.gz: !binary |-
6
+ ZTg0MWFkODU2MThlZGM5ZGI5ZTY1NmZjOTQyYzA2ZGRmZDYzZjUyYw==
5
7
  SHA512:
6
- metadata.gz: a5a59e5fd6d988910c8c186f72020fd57a435ff4f3214657a4ad8246f243ac12f0151642cd00eb2fd3a79d981db815c5bcc358c4304ce7a172531f42fd0cd6f9
7
- data.tar.gz: 9b4be35e79cede77d65861eee17214c846c9e931666aba0760118e265d58ade32126e43f099e8c2799f5606703da40820a56b8991ee693d4aa704764fe97fc50
8
+ metadata.gz: !binary |-
9
+ MDljZjg0YmFlZmViMzA2MDlmNmUwNTFiZDM5NGM4NWZhMDkzNjdiNjk5ZjRl
10
+ ZDIzZGZhMzA3MDUxMThlOTdmZmM5MTFmZWNhMGY5MWMzMDY0YjY4MjE0M2Ux
11
+ YTA4N2MxZDYxYTUyYmJjYzkyMjUyYzdmOWRkNzUyZjE5YWU4ZDA=
12
+ data.tar.gz: !binary |-
13
+ NGJiOTAxYWVkOTkxYWYyNzk3YzJkZWNlZmIzYzAyOWQwNDk5NmUxODFiYmRm
14
+ NzJhYWUyMzEyZjdlZWZmNWY0YjUzM2MzNDlhY2Y2MmM5ZGU0YTQyMmUzNTRj
15
+ NWQxNTQ5ZDMyZGQ0ZDU2NjcwNmY0OTNmNjViYjhlN2FlODQ1MDM=
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.3
1
+ 1.9.3
data/CHANGES CHANGED
@@ -155,4 +155,8 @@
155
155
 
156
156
  == Version 1.7.2
157
157
 
158
- * Bug fixes
158
+ * Bug fixes
159
+
160
+ == Version 1.7.3
161
+
162
+ * Extending syntax for scenario outline
@@ -154,4 +154,17 @@ class AcceptanceTest
154
154
  ('a'..'z').to_a.shuffle[0, 12].join
155
155
  end
156
156
 
157
+ # def self.get_localhost
158
+ # orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily
159
+ #
160
+ # UDPSocket.open do |s|
161
+ # s.connect '192.168.1.1', 1
162
+ # s.addr.last
163
+ # end
164
+ # ensure
165
+ # Socket.do_not_reverse_lookup = orig
166
+ # end
167
+
168
+ # ip = `ifconfig | grep 'inet ' | grep -v 127.0.0.1 | cut -d ' ' -f2`.strip
169
+ # Capybara.app_host = http://#{ip}:#{Capybara.server_port}
157
170
  end
@@ -26,19 +26,17 @@ class GherkinExt
26
26
 
27
27
  source.each_line do |line|
28
28
  if line =~ /file\s?:/
29
- source_path = line.gsub('file:', '').gsub('|', '').strip
29
+ part1, part2 = line.split(",")
30
+
31
+ source_path = part1.gsub('file:', '').gsub('|', '').strip
32
+ key = part2 ? part2.gsub('key:', '').gsub('|', '').strip : nil
30
33
 
31
34
  if source_path
32
35
  values = self.data_reader.call(source_path)
33
36
 
34
- values.each do |row|
35
- new_source += " |"
37
+ data = key.nil? ? values : values[key]
36
38
 
37
- row.each do |element|
38
- new_source += " #{element} |"
39
- end
40
- new_source += "\n"
41
- end
39
+ new_source += build_data_section data
42
40
  end
43
41
  else
44
42
  new_source += line
@@ -52,6 +50,22 @@ class GherkinExt
52
50
  source
53
51
  end
54
52
  end
53
+
54
+ def self.build_data_section values
55
+ buffer = ""
56
+
57
+ values.each do |row|
58
+ buffer += " |"
59
+
60
+ row.each do |element|
61
+ buffer += " #{element} |"
62
+ end
63
+
64
+ buffer += "\n"
65
+ end
66
+
67
+ buffer
68
+ end
55
69
  end
56
70
  end
57
71
 
@@ -1,3 +1,3 @@
1
1
  class AcceptanceTest
2
- VERSION = "1.7.2"
2
+ VERSION = "1.7.3"
3
3
  end
data/spec/data.yml ADDED
@@ -0,0 +1,6 @@
1
+ "test1":
2
+ [
3
+ ["Capybara", "Hydrochoerus hydrochaeris", "1"],
4
+ ["Wombat", "quadrupedal marsupials", "2"],
5
+ ["Echidna", "Tachyglossidae", "3"]
6
+ ]
@@ -3,7 +3,6 @@ Feature: Using Wikipedia
3
3
  Background: within wikipedia.com context
4
4
  Given I am within wikipedia.com
5
5
 
6
- @selenium
7
6
  @search_with_pages
8
7
  Scenario: Searching with selenium for a term with submit
9
8
 
@@ -3,8 +3,7 @@ Feature: Using Wikipedia
3
3
  Background: within wikipedia.com context
4
4
  Given I am within wikipedia.com
5
5
 
6
- @selenium
7
- @search_with_examples_from_csv
6
+ @search_with_scenario_outline
8
7
  Scenario Outline: Searching with selenium for a term with submit (embedded data)
9
8
 
10
9
  Given I am on wikipedia.com
@@ -17,16 +16,3 @@ Feature: Using Wikipedia
17
16
  | Capybara | Hydrochoerus hydrochaeris |
18
17
  | Wombat | quadrupedal marsupials |
19
18
  | Echidna | Tachyglossidae |
20
-
21
- @selenium
22
- @search_with_examples_from_csv
23
- Scenario Outline: Searching with selenium for a term with submit (external data)
24
-
25
- Given I am on wikipedia.com
26
- When I enter word <keyword>
27
- And I click submit button
28
- Then I should see "<result>"
29
-
30
- Examples:
31
- | keyword | result |
32
- | file:spec/data.csv ||
@@ -0,0 +1,16 @@
1
+ Feature: Using Wikipedia
2
+
3
+ Background: within wikipedia.com context
4
+ Given I am within wikipedia.com
5
+
6
+ @search_with_scenario_outline
7
+ Scenario Outline: Searching with selenium for a term with submit (external data)
8
+
9
+ Given I am on wikipedia.com
10
+ When I enter word <keyword>
11
+ And I click submit button
12
+ Then I should see "<result>"
13
+
14
+ Examples:
15
+ | keyword | result | something_else |
16
+ | file:spec/data.csv || |
@@ -0,0 +1,16 @@
1
+ Feature: Using Wikipedia
2
+
3
+ Background: within wikipedia.com context
4
+ Given I am within wikipedia.com
5
+
6
+ @search_with_scenario_outline
7
+ Scenario Outline: Searching with selenium for a term with submit (external data)
8
+
9
+ Given I am on wikipedia.com
10
+ When I enter word <keyword>
11
+ And I click submit button
12
+ Then I should see "<result>"
13
+
14
+ Examples:
15
+ | keyword | result |something_else |
16
+ | file:spec/data.yml, key:test1 || |
@@ -3,7 +3,6 @@ Feature: Using Wikipedia
3
3
  Background: within wikipedia.com context
4
4
  Given I am within wikipedia.com
5
5
 
6
- @selenium
7
6
  @search_with_table
8
7
  Scenario: Searching with selenium for a term with submit (embedded data)
9
8
 
@@ -1,10 +1,20 @@
1
+ require 'csv'
2
+
1
3
  # enable external source for gherkin
2
4
 
3
- data_reader = lambda {|source_path| CSV.read(File.expand_path(source_path)) }
5
+ data_reader = lambda do |source_path|
6
+ ext = File.extname(source_path)
7
+
8
+ if ext == '.csv'
9
+ CSV.read(File.expand_path(source_path))
10
+ elsif ext == '.yml'
11
+ YAML.load_file(File.expand_path(source_path))
12
+ end
13
+ end
4
14
 
5
15
  AcceptanceTest.instance.enable_external_source data_reader
6
16
 
7
- steps_for :search_with_examples_from_csv do
17
+ steps_for :search_with_scenario_outline do
8
18
 
9
19
  step "I am within wikipedia.com" do
10
20
  end
@@ -19,7 +19,7 @@ AcceptanceTest.instance.configure_turnip 'tmp/report.html'
19
19
 
20
20
  require 'steps/search_with_drivers_steps'
21
21
  require 'steps/search_with_pages_steps'
22
- require 'steps/search_with_examples_from_csv_steps'
22
+ require 'steps/search_with_scenario_outline_steps'
23
23
  require 'steps/search_with_table_steps'
24
24
 
25
25
 
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.7.2
4
+ version: 1.7.3
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-20 00:00:00.000000000 Z
11
+ date: 2014-10-21 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
@@ -71,7 +71,6 @@ 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
75
74
  - lib/acceptance_test/cucumber_ext.rb
76
75
  - lib/acceptance_test/driver_manager.rb
77
76
  - lib/acceptance_test/gherkin_ext.rb
@@ -84,16 +83,19 @@ files:
84
83
  - lib/tasks/rspec.rake
85
84
  - spec/acceptance_config.yml
86
85
  - spec/data.csv
86
+ - spec/data.yml
87
87
  - spec/features/search_with_drivers.feature
88
- - spec/features/search_with_examples_from_csv.feature
89
88
  - spec/features/search_with_pages.feature
89
+ - spec/features/search_with_scenario_outline1.feature
90
+ - spec/features/search_with_scenario_outline2.feature
91
+ - spec/features/search_with_scenario_outline3.feature
90
92
  - spec/features/search_with_table.feature
91
93
  - spec/support/pages/main_page.rb
92
94
  - spec/support/pages/wikipedia_pages.rb
93
95
  - spec/support/steps/common_steps.rb
94
96
  - spec/support/steps/search_with_drivers_steps.rb
95
- - spec/support/steps/search_with_examples_from_csv_steps.rb
96
97
  - spec/support/steps/search_with_pages_steps.rb
98
+ - spec/support/steps/search_with_scenario_outline_steps.rb
97
99
  - spec/support/steps/search_with_table_steps.rb
98
100
  - spec/test_helper.rb
99
101
  - spec/turnip_helper.rb
@@ -111,12 +113,12 @@ require_paths:
111
113
  - lib
112
114
  required_ruby_version: !ruby/object:Gem::Requirement
113
115
  requirements:
114
- - - ">="
116
+ - - ! '>='
115
117
  - !ruby/object:Gem::Version
116
118
  version: '0'
117
119
  required_rubygems_version: !ruby/object:Gem::Requirement
118
120
  requirements:
119
- - - ">="
121
+ - - ! '>='
120
122
  - !ruby/object:Gem::Version
121
123
  version: '0'
122
124
  requirements: []
@@ -132,16 +134,19 @@ test_files:
132
134
  - features/wikipedia/wikipedia_search_from_csv.feature
133
135
  - spec/acceptance_config.yml
134
136
  - spec/data.csv
137
+ - spec/data.yml
135
138
  - spec/features/search_with_drivers.feature
136
- - spec/features/search_with_examples_from_csv.feature
137
139
  - spec/features/search_with_pages.feature
140
+ - spec/features/search_with_scenario_outline1.feature
141
+ - spec/features/search_with_scenario_outline2.feature
142
+ - spec/features/search_with_scenario_outline3.feature
138
143
  - spec/features/search_with_table.feature
139
144
  - spec/support/pages/main_page.rb
140
145
  - spec/support/pages/wikipedia_pages.rb
141
146
  - spec/support/steps/common_steps.rb
142
147
  - spec/support/steps/search_with_drivers_steps.rb
143
- - spec/support/steps/search_with_examples_from_csv_steps.rb
144
148
  - spec/support/steps/search_with_pages_steps.rb
149
+ - spec/support/steps/search_with_scenario_outline_steps.rb
145
150
  - spec/support/steps/search_with_table_steps.rb
146
151
  - spec/test_helper.rb
147
152
  - spec/turnip_helper.rb
@@ -1,221 +0,0 @@
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