dkdeploy-cucumber 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.rubocop.yml +18 -0
  4. data/.travis.yml +15 -0
  5. data/CHANGELOG.md +12 -0
  6. data/CONTRIBUTORS.md +16 -0
  7. data/Gemfile +4 -0
  8. data/LICENSE +7 -0
  9. data/README.md +57 -0
  10. data/Rakefile +1 -0
  11. data/assets/dkdeploy-logo.png +0 -0
  12. data/config/cucumber.yml +4 -0
  13. data/dkdeploy-cucumber.gemspec +35 -0
  14. data/features/click.feature +52 -0
  15. data/features/content.feature +95 -0
  16. data/features/form.feature +136 -0
  17. data/features/htdocs/click.html +18 -0
  18. data/features/htdocs/click1.html +20 -0
  19. data/features/htdocs/click2.html +10 -0
  20. data/features/htdocs/content.html +17 -0
  21. data/features/htdocs/content.json +3 -0
  22. data/features/htdocs/form.html +26 -0
  23. data/features/htdocs/misc.html +13 -0
  24. data/features/htdocs/url.html +10 -0
  25. data/features/misc.feature +18 -0
  26. data/features/support/env.rb +35 -0
  27. data/features/url.feature +28 -0
  28. data/lib/dkdeploy/cucumber.rb +1 -0
  29. data/lib/dkdeploy/cucumber/step_definitions/click_steps.rb +39 -0
  30. data/lib/dkdeploy/cucumber/step_definitions/content_steps.rb +88 -0
  31. data/lib/dkdeploy/cucumber/step_definitions/form_steps.rb +146 -0
  32. data/lib/dkdeploy/cucumber/step_definitions/images.rb +11 -0
  33. data/lib/dkdeploy/cucumber/step_definitions/misc_steps.rb +105 -0
  34. data/lib/dkdeploy/cucumber/step_definitions/url_steps.rb +31 -0
  35. data/lib/dkdeploy/cucumber/steps.rb +2 -0
  36. data/lib/dkdeploy/cucumber/support.rb +3 -0
  37. data/lib/dkdeploy/cucumber/support/path.rb +13 -0
  38. data/lib/dkdeploy/cucumber/support/selectors.rb +15 -0
  39. data/lib/dkdeploy/cucumber/support/with.rb +9 -0
  40. data/lib/dkdeploy/cucumber/version.rb +15 -0
  41. metadata +257 -0
@@ -0,0 +1,11 @@
1
+ # Test for image
2
+ #
3
+ Then(/^(?:|I )should see the image "([^"]*)"(?: within "([^"]*)")?$/) do |image, selector|
4
+ with_scope(selector) do
5
+ if page.respond_to? :should
6
+ expect(page).to have_xpath("//img[contains(@src,'#{image}')]")
7
+ else
8
+ assert page.has_xpath?("//img[contains(@src,'#{image}')]")
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,105 @@
1
+ # Hover given element.
2
+ #
3
+ # @yieldparam element [String] Css selector for element.
4
+ When(/^I hover over "([^"]*)"$/) do |element|
5
+ element = find(selector_for(element).to_s)
6
+ element.hover
7
+ end
8
+
9
+ # Test for css attribute value
10
+ #
11
+ Then(/^the element "([^"]*)" should have a css attribute "([^"]*)" with value "([^"]*)"$/) do |element, css_key, value|
12
+ expect(page.evaluate_script("jQuery('#{selector_for(element)}').css('" + css_key + "')")).to have_content(value)
13
+ end
14
+
15
+ # Test for attribute value
16
+ #
17
+ Then(/^the element with xpath "([^"]*)" should have an attribute "([^"]*)" with (the exact )?value "([^"]*)"$/) do |element, attr, exact, value|
18
+ xpath_attribute_compare = exact ? '[@' + attr + '="' + value + '"]' : '[contains("' + value + '", ' + attr + ')]'
19
+
20
+ xpath_path = element + xpath_attribute_compare
21
+
22
+ if page.respond_to? :should
23
+ expect(page).to have_xpath(xpath_path)
24
+ else
25
+ assert page.has_xpath?(xpath_path)
26
+ end
27
+ end
28
+
29
+ # Test for class attribute value
30
+ #
31
+ Then(/^the element "([^"]*)" should have class "([^"]*)"$/) do |element, value|
32
+ expect(page.evaluate_script("jQuery('#{selector_for(element)}').hasClass('" + value + "')")).to be_truthy
33
+ end
34
+
35
+ # Test for absence of class attribute value
36
+ #
37
+ Then(/^the element "([^"]*)" should not have class "([^"]*)"$/) do |element, value|
38
+ expect(page.evaluate_script("jQuery('#{selector_for(element)}').hasClass('" + value + "')")).to be_falsey
39
+ end
40
+
41
+ Then(/^I should have exactly "(\d+) ([^"]*)" within "([^"]*)"$/) do |number_of_elements, selector, parent|
42
+ with_scope(parent) do
43
+ elements = all(selector_for(selector))
44
+ expect(elements.size).to eq(number_of_elements.to_i)
45
+ end
46
+ end
47
+
48
+ Then(/^I should have not more than "(\d+) ([^"]*)" within "([^"]*)"$/) do |number_of_elements, selector, parent|
49
+ with_scope(parent) do
50
+ elements = all(selector_for(selector))
51
+ expect(elements.size).to be <= number_of_elements.to_i
52
+ end
53
+ end
54
+
55
+ Then(/^the element "([^"]*)" should not be visible after waiting (\d) seconds$/) do |element, seconds|
56
+ sleep(seconds.to_i)
57
+ expect(page.evaluate_script("jQuery('#{selector_for(element)}').is(':visible')")).to be_falsey
58
+ end
59
+
60
+ Then(/^the element "([^"]*)" should be visible after waiting (\d) seconds$/) do |element, seconds|
61
+ sleep(seconds.to_i)
62
+ expect(page.evaluate_script("jQuery('#{selector_for(element)}').is(':visible')")).to be_truthy
63
+ end
64
+
65
+ And(/^all elements "([^"]*)" within "([^"]*)" should have the class "([^"]*)"$/) do |selector, parent, value|
66
+ with_scope(parent) do
67
+ expect(all(selector_for(selector)).size).to eq(all(selector_for("#{selector}#{value}")).size)
68
+ end
69
+ end
70
+
71
+ Then(/^I native hover the element "([^"]*)"$/) do |element|
72
+ element = selector_for(element)
73
+ page.find(element).native.hover
74
+ end
75
+
76
+ # Test the page title
77
+ #
78
+ Then(/^I should see the page titled "([^\"]*)"$/) do |title|
79
+ expect(page).to have_title(title)
80
+ end
81
+
82
+ # use only for debugging
83
+ #
84
+ Then(/^I take a screenshot$/) do ||
85
+ page.save_screenshot('./cucumber_debug_screenshot.png', full: true)
86
+ end
87
+
88
+ # Save current page.
89
+ #
90
+ Then(/^show me the page$/) do
91
+ save_and_open_page # rubocop:disable Lint/Debugger
92
+ end
93
+
94
+ # Mark current test as pending.
95
+ #
96
+ Given(/^PENDING/) do
97
+ skip
98
+ end
99
+
100
+ # Wait x seconds.
101
+ #
102
+ # @yieldparam seconds [String] Seconds to wait.
103
+ Then(/^I wait for (\d+) seconds*$/) do |seconds|
104
+ sleep seconds.to_i
105
+ end
@@ -0,0 +1,31 @@
1
+ # Open given url.
2
+ #
3
+ # @yieldparam page_name [String] Name of page to open.
4
+ Given(/^(?:|I )am on "([^"]*)"$/) do |page_name|
5
+ visit path_to(page_name)
6
+ status_code = page.status_code.to_s # CODE_TO_OBJ matches string the net http class
7
+ expect(Net::HTTPResponse::CODE_TO_OBJ).to include(status_code)
8
+ response = Net::HTTPResponse::CODE_TO_OBJ[status_code].allocate # create a dummy instance to easily check the error type
9
+ expect(response).not_to be_a Net::HTTPClientError
10
+ expect(response).not_to be_a Net::HTTPServerError
11
+ expect(response).not_to be_a Net::HTTPError
12
+ end
13
+
14
+ # Check current url.
15
+ #
16
+ # @yieldparam page_name [String] Page to test.
17
+ Then(/^(?:|I )should be on "([^"]*)"$/) do |page_name|
18
+ current_path = URI.parse(current_url).path
19
+ expect(current_path).to eq path_to(page_name)
20
+ end
21
+
22
+ # Check current url query parameters.
23
+ #
24
+ # @yieldparam expected_pairs [String] GET Parameter to test.
25
+ Then(/^(?:|I )should have the following query string:$/) do |expected_pairs|
26
+ query = URI.parse(current_url).query
27
+ actual_params = query ? CGI.parse(query) : {}
28
+ expected_params = {}
29
+ expected_pairs.rows_hash.each_pair { |k, v| expected_params[k] = v.split(',') }
30
+ expect(actual_params).to eq expected_params
31
+ end
@@ -0,0 +1,2 @@
1
+ # Loads steps from directory `./step_definitions'.
2
+ Dir.glob(File.expand_path('../step_definitions/*.rb', __FILE__)).each { |step_file| require step_file }
@@ -0,0 +1,3 @@
1
+
2
+ # Loads ruby files from directory `supports'.
3
+ Dir.glob(File.expand_path('../support/*.rb', __FILE__)).each { |support_file| require support_file }
@@ -0,0 +1,13 @@
1
+ # Navigation helper module for cucumber steps
2
+ #
3
+ module NavigationHelpers
4
+ # Mapping for path names to real remote path
5
+ #
6
+ # @param path [String]
7
+ # @return [String]
8
+ def path_to(path)
9
+ path
10
+ end
11
+ end
12
+
13
+ World(NavigationHelpers)
@@ -0,0 +1,15 @@
1
+ # Cucumber step helper function for selector_for
2
+ #
3
+ module HtmlSelectorsHelpers
4
+ # Maps a name to a selector. Used primarily by the
5
+ #
6
+ # When /^(.+) within (.+)$/ do |step, scope|
7
+ #
8
+ # step definitions in web_steps.rb
9
+ #
10
+ def selector_for(locator)
11
+ locator
12
+ end
13
+ end
14
+
15
+ World(HtmlSelectorsHelpers)
@@ -0,0 +1,9 @@
1
+ # Cucumber step helper function for with_in
2
+ #
3
+ module WithinHelpers
4
+ def with_scope(locator)
5
+ locator ? within(*selector_for(locator)) { yield } : yield
6
+ end
7
+ end
8
+
9
+ World(WithinHelpers)
@@ -0,0 +1,15 @@
1
+ module Dkdeploy
2
+ module Cucumber
3
+ # Class for version number
4
+ #
5
+ class Version
6
+ MAJOR = 4
7
+ MINOR = 0
8
+ PATCH = 0
9
+
10
+ def self.to_s
11
+ "#{MAJOR}.#{MINOR}.#{PATCH}"
12
+ end
13
+ end
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,257 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dkdeploy-cucumber
3
+ version: !ruby/object:Gem::Version
4
+ version: 4.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Gleb Levitin
8
+ - Timo Webler
9
+ - Johannes Goslar
10
+ - Luka Lüdicke
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2017-08-28 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: bundler
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ - !ruby/object:Gem::Dependency
45
+ name: rack
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: '2.0'
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '2.0'
58
+ - !ruby/object:Gem::Dependency
59
+ name: rubocop
60
+ requirement: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - "~>"
63
+ - !ruby/object:Gem::Version
64
+ version: 0.48.1
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: 0.48.1
72
+ - !ruby/object:Gem::Dependency
73
+ name: rspec
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - "~>"
77
+ - !ruby/object:Gem::Version
78
+ version: '3.6'
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '3.6'
86
+ - !ruby/object:Gem::Dependency
87
+ name: capybara
88
+ requirement: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: 2.15.1
93
+ type: :development
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: 2.15.1
100
+ - !ruby/object:Gem::Dependency
101
+ name: phantomjs
102
+ requirement: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - "~>"
105
+ - !ruby/object:Gem::Version
106
+ version: 2.1.1.0
107
+ type: :development
108
+ prerelease: false
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - "~>"
112
+ - !ruby/object:Gem::Version
113
+ version: 2.1.1.0
114
+ - !ruby/object:Gem::Dependency
115
+ name: poltergeist
116
+ requirement: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - "~>"
119
+ - !ruby/object:Gem::Version
120
+ version: 1.16.0
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - "~>"
126
+ - !ruby/object:Gem::Version
127
+ version: 1.16.0
128
+ - !ruby/object:Gem::Dependency
129
+ name: cucumber
130
+ requirement: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - "~>"
133
+ - !ruby/object:Gem::Version
134
+ version: '2.4'
135
+ type: :runtime
136
+ prerelease: false
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - "~>"
140
+ - !ruby/object:Gem::Version
141
+ version: '2.4'
142
+ - !ruby/object:Gem::Dependency
143
+ name: rspec-expectations
144
+ requirement: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - "~>"
147
+ - !ruby/object:Gem::Version
148
+ version: '3.6'
149
+ type: :runtime
150
+ prerelease: false
151
+ version_requirements: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - "~>"
154
+ - !ruby/object:Gem::Version
155
+ version: '3.6'
156
+ - !ruby/object:Gem::Dependency
157
+ name: launchy
158
+ requirement: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - "~>"
161
+ - !ruby/object:Gem::Version
162
+ version: 2.4.3
163
+ type: :runtime
164
+ prerelease: false
165
+ version_requirements: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - "~>"
168
+ - !ruby/object:Gem::Version
169
+ version: 2.4.3
170
+ description: dkdeploy Cucumber step definitions
171
+ email:
172
+ - gleb.levitin@dkd.de
173
+ - timo.webler@dkd.de
174
+ - johannes.goslar@dkd.de
175
+ - luka.luedicke@dkd.de
176
+ executables: []
177
+ extensions: []
178
+ extra_rdoc_files: []
179
+ files:
180
+ - ".gitignore"
181
+ - ".rubocop.yml"
182
+ - ".travis.yml"
183
+ - CHANGELOG.md
184
+ - CONTRIBUTORS.md
185
+ - Gemfile
186
+ - LICENSE
187
+ - README.md
188
+ - Rakefile
189
+ - assets/dkdeploy-logo.png
190
+ - config/cucumber.yml
191
+ - dkdeploy-cucumber.gemspec
192
+ - features/click.feature
193
+ - features/content.feature
194
+ - features/form.feature
195
+ - features/htdocs/click.html
196
+ - features/htdocs/click1.html
197
+ - features/htdocs/click2.html
198
+ - features/htdocs/content.html
199
+ - features/htdocs/content.json
200
+ - features/htdocs/form.html
201
+ - features/htdocs/misc.html
202
+ - features/htdocs/url.html
203
+ - features/misc.feature
204
+ - features/support/env.rb
205
+ - features/url.feature
206
+ - lib/dkdeploy/cucumber.rb
207
+ - lib/dkdeploy/cucumber/step_definitions/click_steps.rb
208
+ - lib/dkdeploy/cucumber/step_definitions/content_steps.rb
209
+ - lib/dkdeploy/cucumber/step_definitions/form_steps.rb
210
+ - lib/dkdeploy/cucumber/step_definitions/images.rb
211
+ - lib/dkdeploy/cucumber/step_definitions/misc_steps.rb
212
+ - lib/dkdeploy/cucumber/step_definitions/url_steps.rb
213
+ - lib/dkdeploy/cucumber/steps.rb
214
+ - lib/dkdeploy/cucumber/support.rb
215
+ - lib/dkdeploy/cucumber/support/path.rb
216
+ - lib/dkdeploy/cucumber/support/selectors.rb
217
+ - lib/dkdeploy/cucumber/support/with.rb
218
+ - lib/dkdeploy/cucumber/version.rb
219
+ homepage: https://github.com/dkdeploy/dkdeploy-cucumber
220
+ licenses:
221
+ - MIT
222
+ metadata: {}
223
+ post_install_message:
224
+ rdoc_options: []
225
+ require_paths:
226
+ - lib
227
+ required_ruby_version: !ruby/object:Gem::Requirement
228
+ requirements:
229
+ - - "~>"
230
+ - !ruby/object:Gem::Version
231
+ version: '2.2'
232
+ required_rubygems_version: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
237
+ requirements: []
238
+ rubyforge_project:
239
+ rubygems_version: 2.6.12
240
+ signing_key:
241
+ specification_version: 4
242
+ summary: Cucumber step definitions for browser tests
243
+ test_files:
244
+ - features/click.feature
245
+ - features/content.feature
246
+ - features/form.feature
247
+ - features/htdocs/click.html
248
+ - features/htdocs/click1.html
249
+ - features/htdocs/click2.html
250
+ - features/htdocs/content.html
251
+ - features/htdocs/content.json
252
+ - features/htdocs/form.html
253
+ - features/htdocs/misc.html
254
+ - features/htdocs/url.html
255
+ - features/misc.feature
256
+ - features/support/env.rb
257
+ - features/url.feature