cucumber-sammies 0.1.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1493e1ca46f94974635f114d9c67c651b1ed51be
4
- data.tar.gz: ab713fc9ce8690970eb22037ca4f467c840dfd52
2
+ SHA256:
3
+ metadata.gz: c1ed1a19baeb0b3139a821b3248d3d5b89c53a7b288421177db5ddeba51af0bf
4
+ data.tar.gz: f611c0f31fbf84da8a0518727eadf214a16960d740228b83d077b159b5028614
5
5
  SHA512:
6
- metadata.gz: 8c185e173ad04bd24193823bc09f550f5fda65226d2b2f7b170e61fb5d42457d52204e6d64e12a6a3c6e37c7b5b38794829d525ec913d095afaa42fa569b70c5
7
- data.tar.gz: 21e55714cd0997c6d868a5f777d3f4eb50c1eab7887218baef171364d92510fe7f8d0ac90e1b451ac0714da8c45dbd72fb40b01b47a83efbf5acf4ff0ca4d96b
6
+ metadata.gz: 6f52a72fb4f89071f7abf6099d53479964303444fa2e12a367f432e0a20c9b08643514b50027e8a4a69f83e6f9111aa188bd59576d1edcf279bb7638f813d01a
7
+ data.tar.gz: 5e36fdb0f0ce8f692ed23f45de38f11636e728e4f2ea32485a4906bd84290f4c8cd813da90980ba20079a737bb21fd920d3848d2fba649de01c13e3472a6cd21
@@ -0,0 +1,434 @@
1
+ # Continue here: https://raw.githubusercontent.com/rubocop-hq/rubocop/master/config/default.yml
2
+ # TODO: Skipped rails or naming or style
3
+
4
+ AllCops:
5
+ Exclude:
6
+ - 'config/**/*'
7
+ - 'lib/tasks/**/*'
8
+ - 'db/schema.rb'
9
+ - 'node_modules/**/*'
10
+ - 'vendor/**/*'
11
+ - '.git/**/*'
12
+ - 'db/**/*'
13
+ - 'lib/tasks/cucumber.rake'
14
+ - 'config/routes.rb'
15
+ - 'features/**/*'
16
+ EnabledByDefault: false
17
+ DisabledByDefault: true
18
+
19
+ require: rubocop-performance
20
+
21
+ Bundler/DuplicatedGem:
22
+ Enabled: true
23
+
24
+ Bundler/InsecureProtocolSource:
25
+ Enabled: true
26
+
27
+ Bundler/OrderedGems:
28
+ Enabled: true
29
+
30
+ Gemspec/DuplicatedAssignment:
31
+ Enabled: true
32
+
33
+ Gemspec/OrderedDependencies:
34
+ Enabled: true
35
+
36
+ Gemspec/RequiredRubyVersion:
37
+ Enabled: true
38
+
39
+ Layout/BlockEndNewline:
40
+ Enabled: true
41
+
42
+ Layout/ClassStructure:
43
+ Enabled: true
44
+
45
+ Layout/ClosingParenthesisIndentation:
46
+ Enabled: true
47
+
48
+ Layout/ConditionPosition:
49
+ Enabled: true
50
+
51
+ Layout/DefEndAlignment:
52
+ Enabled: true
53
+
54
+ Layout/ElseAlignment:
55
+ Enabled: true
56
+
57
+ Layout/EmptyLineBetweenDefs:
58
+ Enabled: true
59
+
60
+ Layout/EmptyLines:
61
+ Enabled: true
62
+
63
+ Layout/EmptyLinesAroundAccessModifier:
64
+ Enabled: true
65
+
66
+ Layout/EndAlignment:
67
+ Enabled: true
68
+
69
+ Layout/EndOfLine:
70
+ Enabled: true
71
+
72
+ Layout/EmptyLinesAroundArguments:
73
+ Enabled: true
74
+
75
+ Layout/IndentationWidth:
76
+ Enabled: true
77
+
78
+ Layout/InitialIndentation:
79
+ Enabled: true
80
+
81
+ Layout/LeadingEmptyLines:
82
+ Enabled: true
83
+
84
+ Layout/SpaceAfterColon:
85
+ Enabled: true
86
+
87
+ Layout/SpaceAfterComma:
88
+ Enabled: true
89
+
90
+ Layout/SpaceAfterNot:
91
+ Enabled: true
92
+
93
+ Layout/SpaceAfterSemicolon:
94
+ Enabled: true
95
+
96
+ Layout/SpaceAroundEqualsInParameterDefault:
97
+ Enabled: true
98
+
99
+ Layout/SpaceAroundKeyword:
100
+ Enabled: true
101
+
102
+ Layout/SpaceBeforeComma:
103
+ Enabled: true
104
+
105
+ Layout/SpaceInsideStringInterpolation:
106
+ Enabled: true
107
+
108
+ Layout/IndentationStyle:
109
+ Enabled: true
110
+
111
+ Layout/TrailingEmptyLines:
112
+ Enabled: true
113
+
114
+ Layout/TrailingWhitespace:
115
+ Enabled: true
116
+
117
+ Lint/AssignmentInCondition:
118
+ Enabled: true
119
+
120
+ Lint/BooleanSymbol:
121
+ Enabled: true
122
+
123
+ Lint/CircularArgumentReference:
124
+ Enabled: true
125
+
126
+ Lint/Debugger:
127
+ Enabled: true
128
+
129
+ Lint/DuplicateCaseCondition:
130
+ Enabled: true
131
+
132
+ Lint/DuplicateMethods:
133
+ Enabled: true
134
+
135
+ Lint/DuplicateHashKey:
136
+ Enabled: true
137
+
138
+ Lint/EachWithObjectArgument:
139
+ Enabled: true
140
+
141
+ Lint/ElseLayout:
142
+ Enabled: true
143
+
144
+ Lint/EmptyEnsure:
145
+ Enabled: true
146
+
147
+ Lint/EmptyExpression:
148
+ Enabled: true
149
+
150
+ Lint/EmptyInterpolation:
151
+ Enabled: true
152
+
153
+ Lint/EmptyWhen:
154
+ Enabled: true
155
+
156
+ Lint/EnsureReturn:
157
+ Enabled: true
158
+
159
+ Lint/FloatOutOfRange:
160
+ Enabled: true
161
+
162
+ Lint/FormatParameterMismatch:
163
+ Enabled: true
164
+
165
+ Lint/SuppressedException:
166
+ Enabled: true
167
+
168
+ Lint/ImplicitStringConcatenation:
169
+ Enabled: true
170
+
171
+ Lint/IneffectiveAccessModifier:
172
+ Enabled: true
173
+
174
+ Lint/InheritException:
175
+ Enabled: true
176
+
177
+ Lint/InterpolationCheck:
178
+ Enabled: true
179
+
180
+ Lint/LiteralAsCondition:
181
+ Enabled: true
182
+
183
+ Lint/LiteralInInterpolation:
184
+ Enabled: true
185
+
186
+ Lint/Loop:
187
+ Enabled: true
188
+
189
+ Lint/MissingCopEnableDirective:
190
+ Enabled: true
191
+
192
+ Lint/MultipleComparison:
193
+ Enabled: true
194
+
195
+ Lint/NestedMethodDefinition:
196
+ Enabled: true
197
+
198
+ Lint/NextWithoutAccumulator:
199
+ Enabled: true
200
+
201
+ Lint/NonLocalExitFromIterator:
202
+ Enabled: true
203
+
204
+ # This caused too much confusion.
205
+ Lint/NumberConversion:
206
+ Enabled: false
207
+
208
+ Lint/ParenthesesAsGroupedExpression:
209
+ Enabled: true
210
+
211
+ Lint/PercentStringArray:
212
+ Enabled: true
213
+
214
+ Lint/PercentSymbolArray:
215
+ Enabled: true
216
+
217
+ Lint/RandOne:
218
+ Enabled: true
219
+
220
+ Lint/RedundantWithIndex:
221
+ Enabled: true
222
+
223
+ Lint/RedundantWithObject:
224
+ Enabled: true
225
+
226
+ Lint/RegexpAsCondition:
227
+ Enabled: true
228
+
229
+ Lint/RequireParentheses:
230
+ Enabled: true
231
+
232
+ Lint/RescueException:
233
+ Enabled: true
234
+
235
+ Lint/RescueType:
236
+ Enabled: true
237
+
238
+ Lint/ReturnInVoidContext:
239
+ Enabled: true
240
+
241
+ Lint/SafeNavigationChain:
242
+ Enabled: true
243
+
244
+ Lint/SafeNavigationConsistency:
245
+ Enabled: true
246
+
247
+ Lint/ShadowedArgument:
248
+ Enabled: true
249
+
250
+ Lint/ShadowedException:
251
+ Enabled: true
252
+
253
+ Lint/ShadowingOuterLocalVariable:
254
+ Enabled: true
255
+
256
+ Lint/RedundantStringCoercion:
257
+ Enabled: true
258
+
259
+ Lint/Syntax:
260
+ Enabled: true
261
+
262
+ Lint/UnderscorePrefixedVariableName:
263
+ Enabled: true
264
+
265
+ Lint/UnifiedInteger:
266
+ Enabled: true
267
+
268
+ Lint/RedundantRequireStatement:
269
+ Enabled: true
270
+
271
+ Lint/RedundantSplatExpansion:
272
+ Enabled: true
273
+
274
+ Lint/UnreachableCode:
275
+ Enabled: true
276
+
277
+ Lint/UnusedBlockArgument:
278
+ Enabled: true
279
+
280
+ Lint/UnusedMethodArgument:
281
+ Enabled: true
282
+
283
+ Lint/UselessAccessModifier:
284
+ Enabled: true
285
+
286
+ Lint/UselessAssignment:
287
+ Enabled: true
288
+
289
+ Lint/UselessComparison:
290
+ Enabled: true
291
+
292
+ Lint/UselessElseWithoutRescue:
293
+ Enabled: true
294
+
295
+ Lint/UselessSetterCall:
296
+ Enabled: true
297
+
298
+ Lint/Void:
299
+ Enabled: true
300
+
301
+ Metrics/AbcSize:
302
+ Enabled: true
303
+ Max: 150
304
+
305
+ Metrics/BlockLength:
306
+ Enabled: true
307
+ Max: 100
308
+
309
+ Metrics/BlockNesting:
310
+ Enabled: true
311
+ Max: 3
312
+
313
+ Metrics/ClassLength:
314
+ Description: 'Avoid long classes'
315
+ Enabled: true
316
+ Max: 250
317
+
318
+ Metrics/CyclomaticComplexity:
319
+ Enabled: true
320
+ Max: 12
321
+
322
+ Layout/LineLength:
323
+ Enabled: true
324
+ Max: 200
325
+
326
+ Metrics/MethodLength:
327
+ Description: 'Avoid long methods.'
328
+ Enabled: true
329
+ Max: 50
330
+
331
+ Metrics/ModuleLength:
332
+ Description: 'Avoid long modules.'
333
+ Enabled: true
334
+ Max: 250
335
+
336
+ Metrics/ParameterLists:
337
+ Description: 'Avoid long parameter lists.'
338
+ Enabled: true
339
+ Max: 100
340
+
341
+ Metrics/PerceivedComplexity:
342
+ Enabled: true
343
+ Max: 15
344
+
345
+ Performance/Caller:
346
+ Enabled: true
347
+
348
+ Performance/Casecmp:
349
+ Enabled: true
350
+
351
+ # TODO: Re-enable
352
+ Performance/ChainArrayAllocation:
353
+ Enabled: false
354
+
355
+ Performance/CompareWithBlock:
356
+ Enabled: true
357
+
358
+ Performance/Count:
359
+ Enabled: true
360
+
361
+ Performance/Detect:
362
+ Enabled: true
363
+
364
+ Performance/DoubleStartEndWith:
365
+ Enabled: true
366
+
367
+ Performance/EndWith:
368
+ Enabled: true
369
+
370
+ Performance/FixedSize:
371
+ Enabled: true
372
+
373
+ Performance/FlatMap:
374
+ Enabled: true
375
+
376
+ Performance/InefficientHashSearch:
377
+ Enabled: true
378
+
379
+ Performance/RangeInclude:
380
+ Enabled: true
381
+
382
+ Performance/RedundantBlockCall:
383
+ Enabled: true
384
+
385
+ Performance/RedundantMatch:
386
+ Enabled: true
387
+
388
+ Performance/RedundantMerge:
389
+ Enabled: true
390
+
391
+ Style/RedundantSortBy:
392
+ Enabled: true
393
+
394
+ Performance/RegexpMatch:
395
+ Enabled: true
396
+
397
+ Performance/ReverseEach:
398
+ Enabled: true
399
+
400
+ Style/Sample:
401
+ Enabled: true
402
+
403
+ Performance/Size:
404
+ Enabled: true
405
+
406
+ Performance/StartWith:
407
+ Enabled: true
408
+
409
+ Performance/StringReplacement:
410
+ Enabled: true
411
+
412
+ Performance/TimesMap:
413
+ Enabled: true
414
+
415
+ Performance/UnfreezeString:
416
+ Enabled: true
417
+
418
+ Style/RedundantSort:
419
+ Enabled: true
420
+
421
+ Security/Eval:
422
+ Enabled: true
423
+
424
+ Security/JSONLoad:
425
+ Enabled: true
426
+
427
+ Security/MarshalLoad:
428
+ Enabled: true
429
+
430
+ Security/Open:
431
+ Enabled: true
432
+
433
+ Security/YAMLLoad:
434
+ Enabled: true
@@ -0,0 +1 @@
1
+ 2.7.1
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cucumber-sammies (0.2.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (13.0.1)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 2.1)
16
+ cucumber-sammies!
17
+ rake (~> 13.0.1)
18
+
19
+ BUNDLED WITH
20
+ 2.1.4
data/README.md CHANGED
@@ -1,12 +1,11 @@
1
1
  # Cucumber::Sammies
2
2
 
3
3
  [![Code Climate](https://codeclimate.com/github/starfighterheavy/cucumber-sammies/badges/gpa.svg)](https://codeclimate.com/github/starfighterheavy/cucumber-sammies)
4
- [![Dependency Status](https://gemnasium.com/starfighterheavy/cucumber-sammies.svg)](https://gemnasium.com/starfighterheavy/cucumber-sammies)
5
4
  [![Gem Version](https://badge.fury.io/rb/cucumber-sammies.svg)](https://badge.fury.io/rb/cucumber-sammies)
6
5
 
7
6
  ![Cucumber Sandwhiches](./sammies.jpg)
8
7
 
9
- Simple & tasty step definitions for your Rails application that are meant to compliment [Speewald](https://github.com/makandra/spreewald).
8
+ Simple & tasty Cucumber step definitions for your Rails application. Many of these steps were originally created by [Spreewald](https://github.com/makandra/spreewald).
10
9
 
11
10
  ## Installation
12
11
 
@@ -26,13 +25,13 @@ Or install it yourself as:
26
25
 
27
26
  ## Usage
28
27
 
29
- To use `cucumber-sammies` in your cucumber tests, add this line to your `features/support/env.rb` file.
28
+ To use `cucumber-sammies` in your cucumber tests, add a line like this to your `features/support/env.rb` file.
30
29
 
31
30
  ```ruby
32
- require 'cucumber/sammies/step_definitions/*'
31
+ require 'cucumber/sammies/step_definitions/form_steps'
33
32
  ```
34
33
 
35
- Or your can require individual step definition files by replacing `*` with the file name you want.
34
+ All the steps can be found in the [step_definitions directory](https://github.com/starfighterheavy/cucumber-sammies/tree/master/lib/cucumber/sammies/step_definitions)
36
35
 
37
36
  ## Development
38
37
 
@@ -42,7 +41,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
42
41
 
43
42
  ## Contributing
44
43
 
45
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cucumber-sammies. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/starfighterheavy/cucumber-sammies. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
46
45
 
47
46
  ## License
48
47
 
@@ -50,4 +49,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
50
49
 
51
50
  ## Code of Conduct
52
51
 
53
- Everyone interacting in the Cucumber::Sammies project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/cucumber-sammies/blob/master/CODE_OF_CONDUCT.md).
52
+ Everyone interacting in the Cucumber::Sammies project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/starfighterheavy/cucumber-sammies/blob/master/CODE_OF_CONDUCT.md).
@@ -1,4 +1,3 @@
1
-
2
1
  lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require "cucumber/sammies/version"
@@ -23,6 +22,6 @@ Gem::Specification.new do |spec|
23
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
23
  spec.require_paths = ["lib"]
25
24
 
26
- spec.add_development_dependency "bundler", "~> 1.16"
27
- spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "bundler", "~> 2.1"
26
+ spec.add_development_dependency "rake", "~> 13.0"
28
27
  end
@@ -1,7 +1,4 @@
1
- # coding: UTF-8
2
-
3
1
  Dir[File.join(File.dirname(__FILE__), '/step_definitions/*_steps.rb')].each do |f|
4
2
  name = File.basename(f, '.rb')
5
3
  require "cucumber/sammies/step_definitions/#{name}"
6
4
  end
7
-
@@ -1,3 +1,7 @@
1
+ Then /^I should see an image with the src "(.*)"$/ do |image_src|
2
+ expect(page).to have_xpath("//img[contains(@src,'#{image_src}')]")
3
+ end
4
+
1
5
  Then /^the page title should be "(.*)"$/ do |title|
2
6
  expect(page.title).to eq(title)
3
7
  end
@@ -6,10 +10,18 @@ Then /^the page body should include "(.*)"$/ do |content|
6
10
  expect(page.body).to include(content)
7
11
  end
8
12
 
13
+ Then /^I should see "(.*)"$/ do |content|
14
+ expect(page).to have_content(content, normalize_ws: true)
15
+ end
16
+
17
+ Then /^I should not see "(.*)"$/ do |content|
18
+ expect(page).not_to have_content(content, normalize_ws: true)
19
+ end
20
+
9
21
  Then(/^I see the (.*) flash message$/) do |message|
10
- expect(page).to have_content(resolve_locale(message))
22
+ expect(page).to have_content(resolve_locale(message), normalize_ws: true)
11
23
  end
12
24
 
13
25
  Then(/^I (should )?see the localized text for "(.*)"$/) do |_should, message|
14
- expect(page).to have_content(resolve_locale(message))
26
+ expect(page).to have_content(resolve_locale(message), normalize_ws: true)
15
27
  end
@@ -5,12 +5,3 @@ end
5
5
  Given /^the "(.*)" ENV should be set to "(.*)"$/ do |key, value|
6
6
  expect(ENV[key]).to eq value
7
7
  end
8
-
9
-
10
- Then /^"(.*)" should raise a "(.*)" error$/ do |expression, error|
11
- expect { eval(expression) }.to raise_error(/#{error}/)
12
- end
13
-
14
- Then /^"(.*)" should not raise a "(.*)" error$/ do |expression, error|
15
- expect { eval(expression) }.not_to raise_error(/#{error}/)
16
- end
@@ -1,5 +1,13 @@
1
- When(/^I click "(.*)"$/) do |link|
2
- click_on link
1
+ When('I confirm') do
2
+ page.driver.browser.switch_to.alert.accept
3
+ end
4
+
5
+ When('I hit enter on {string}') do |id|
6
+ page.find("##{id}").send_keys(:return)
7
+ end
8
+
9
+ Then('the {string} field should contain {string}') do |label, value|
10
+ expect(find_field(label).value).to eq(value)
3
11
  end
4
12
 
5
13
  When(/^I click the first "(.*)"$/) do |link|
@@ -10,6 +18,10 @@ When(/^I click the "(.*)" submit button$/) do |link|
10
18
  find(link).click
11
19
  end
12
20
 
21
+ When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
22
+ select(value, from: field)
23
+ end
24
+
13
25
  When(/^I check the ([^"]+) box$/) do |label|
14
26
  check resolve_locale(label)
15
27
  end
@@ -38,7 +50,36 @@ def select_year_month(year:, month:, day: nil, field:)
38
50
  field = find(:xpath, ".//label[contains(.,'#{field}')]")[:for]
39
51
  field.gsub!(/_[1-3]{1}i$/, '')
40
52
  end
41
- select year, :from => "#{field}_1i"
42
- select month, :from => "#{field}_2i"
43
- select day, :from => "#{field}_3i" if day
53
+ select year, from: "#{field}_1i"
54
+ select month, from: "#{field}_2i"
55
+ select day, from: "#{field}_3i" if day
56
+ end
57
+
58
+ When /^(?:|I )fill in "([^"]*)" (?:with|for) "([^"]*)"$/ do |field, value|
59
+ fill_in(field, with: value)
60
+ end
61
+
62
+ Then /^nothing should be selected for "([^"]*)"$/ do |field|
63
+ select = find_field(field)
64
+ begin
65
+ selected_option = select.find(:xpath, ".//option[@selected = 'selected']") || select.all(:css, 'option').first
66
+ value = selected_option ? selected_option.value : nil
67
+ value.should be_blank
68
+ rescue Capybara::ElementNotFound
69
+ Rails.logger.info "Element not found: #{field}"
70
+ end
71
+ end
72
+
73
+ # Checks for the presence of an option in a select
74
+ Then /^"([^"]*)" should( not)? be an option for "([^"]*)"$/ do |value, negate, field|
75
+ xpath = ".//option[text() = '#{value}']"
76
+ if negate
77
+ begin
78
+ field_labeled(field).find(:xpath, xpath).should_not be_present
79
+ rescue Capybara::ElementNotFound
80
+ Rails.logger.info "Element not found: #{field}"
81
+ end
82
+ else
83
+ field_labeled(field).find(:xpath, xpath).should be_present
84
+ end
44
85
  end
@@ -0,0 +1,11 @@
1
+ When("the {string} is performed with arg {string}") do |job, arg|
2
+ job.constantize.send("perform_now", arg)
3
+ end
4
+
5
+ When("the {string} is performed with the following:") do |job, args|
6
+ job.constantize.send("perform_now", *args.rows_hash.values)
7
+ end
8
+
9
+ When("the {string} is performed") do |job|
10
+ job.constantize.send("perform_now")
11
+ end
@@ -1,10 +1,51 @@
1
+ require_relative '../support/resolvers'
2
+
3
+ When('I switch to the new tab') do
4
+ page.driver.browser.switch_to.window(page.driver.browser.window_handles.last)
5
+ end
6
+
7
+ Then('the {string} button should be disabled') do |text|
8
+ expect(page).to have_button(text, disabled: true)
9
+ end
10
+
11
+ When('I hover over {string}') do |el|
12
+ page.find(el).hover
13
+ end
14
+
15
+ When('I click the {word} {string} icon') do |index, icon|
16
+ page.all('i', text: icon)[index.to_i - 1].click
17
+ sleep(1)
18
+ end
19
+
20
+ Then('I should see {int} {string} icons') do |count, icon|
21
+ expect(page.all('i', text: icon).size).to eq(count)
22
+ end
23
+
24
+ Then('I should not see a {string} icon') do |icon|
25
+ expect(page.all('i', text: icon).size).to eq(0)
26
+ end
27
+
28
+ When('I click the first {string} button') do |button|
29
+ first(:button, button).click
30
+ end
31
+
32
+ When('I click the {string} icon') do |icon|
33
+ page.find('i', text: /#{icon}/i).click
34
+ end
35
+
36
+ When(/^I click "(.*)"$/) do |link|
37
+ click_on link
38
+ end
39
+
40
+ When 'I reload the page' do
41
+ visit current_url
42
+ end
43
+
1
44
  Then(/^I am taken to (a|an|the) (.*) page$/) do |inclusive, path|
2
45
  path.split(' ').each do |part|
3
46
  expect(current_path.split('/')).to include(part)
4
47
  end
5
- unless inclusive == 'the'
6
- expect(current_path.split('/').last.to_i).to be > 0
7
- end
48
+ expect(current_path.split('/').last.to_i).to be > 0 unless inclusive == 'the'
8
49
  end
9
50
 
10
51
  When(/^I set the subdomain to "(.*)"$/) do |subdomain|
@@ -15,6 +56,39 @@ When /^I visit "(.*)"$/ do |path|
15
56
  visit path
16
57
  end
17
58
 
59
+ When /^(?:|I )go to the (.+) page$/ do |page_name|
60
+ visit resolve_path(page_name)
61
+ end
62
+
63
+ When /^(?:|I )press "([^"]*)"$/ do |button|
64
+ click_button(button)
65
+ end
66
+
67
+ When /^(?:|I )follow "([^"]*)"$/ do |link|
68
+ click_link(link)
69
+ end
70
+
71
+ When /^I click on "([^\"]+)"$/ do |text|
72
+ contains_text = %{contains(., \"#{text}\")}
73
+ # find the innermost selector that matches
74
+ element = page.find(:xpath, ".//*[#{contains_text} and not (./*[#{contains_text}])]")
75
+ element.click
76
+ end
77
+
18
78
  Then(/^I wait ([0-9]+) seconds$/) do |seconds|
19
79
  sleep seconds.to_i
20
80
  end
81
+
82
+ Then /^(?:|I )should be on the (.+) page$/ do |page_name|
83
+ fragment = URI.parse(current_url).fragment
84
+ fragment.sub!(/[#?].*/, '') if fragment # most js frameworks will usually use ? and # for params, we dont care about those
85
+ current_path = URI.parse(current_url).path
86
+ current_path << "##{fragment}" if fragment.present?
87
+ expected_path = resolve_path(page_name)
88
+
89
+ # Consider two pages equal if they only differ by a trailing slash.
90
+ current_path = expected_path if current_path.chomp('/') == expected_path.chomp('/')
91
+ current_path = expected_path if current_path.gsub('/#', '#') == expected_path.gsub('/#', '#')
92
+
93
+ current_path.should == expected_path
94
+ end
@@ -3,8 +3,8 @@ Then /^I should not see the table "(.*)"$/ do |caption|
3
3
  end
4
4
 
5
5
  Then /^the table "(.*)" should contain:$/ do |caption, data|
6
- table = page.find('caption', text: caption).first(:xpath,".//..").all('tr').map { |tr|
7
- tr.all('th,td').map { |col| col.text }
8
- }
6
+ table = page.find('caption', text: caption).first(:xpath, './/..').all('tr').map do |tr|
7
+ tr.all('th,td').map(&:text)
8
+ end
9
9
  data.diff!(table)
10
10
  end
@@ -0,0 +1,70 @@
1
+ # From: https://raw.githubusercontent.com/starfighterheavy/spreewald/master/lib/spreewald/timecop_steps.rb
2
+
3
+ if defined?(Timecop)
4
+
5
+ module TimecopHarness
6
+ # When you have to make your rails app time zone aware you have to go 100%
7
+ # otherwise you are better off ignoring time zones at all.
8
+ # https://makandracards.com/makandra/8723-guide-to-localizing-a-rails-application
9
+
10
+ def use_timezones?
11
+ active_record_loaded = defined?(ActiveRecord::Base)
12
+ (!active_record_loaded || ActiveRecord::Base.default_timezone != :local) && Time.zone
13
+ end
14
+
15
+ def parse_time(str)
16
+ if use_timezones?
17
+ Time.zone.parse(str)
18
+ else
19
+ Time.parse(str)
20
+ end
21
+ end
22
+
23
+ def current_time
24
+ if use_timezones?
25
+ Time.current
26
+ else
27
+ Time.now
28
+ end
29
+ end
30
+ end
31
+
32
+ World(TimecopHarness)
33
+
34
+ # Example:
35
+ #
36
+ # Given the date is 2012-02-10
37
+ # Given the time is 2012-02-10 13:40
38
+ When /^the (?:date|time) is "?(\d{4}-\d{2}-\d{2}(?: \d{1,2}:\d{2})?)"?$/ do |time|
39
+ Timecop.travel(parse_time(time))
40
+ end
41
+
42
+ # Example:
43
+ #
44
+ # Given the time is 13:40
45
+ When /^the time is "?(\d{1,2}:\d{2})"?$/ do |time_without_date|
46
+ Timecop.travel(parse_time(time_without_date)) # date will be today
47
+ end
48
+
49
+ # Example:
50
+ #
51
+ # When it is 10 minutes later
52
+ # When it is a few hours earlier
53
+ When /^it is (\d+|a|some|a few) (seconds?|minutes?|hours?|days?|weeks?|months?|years?) (later|earlier)$/ do |amount, unit, direction|
54
+ amount = case amount
55
+ when 'a'
56
+ 1
57
+ when 'some', 'a few'
58
+ 10
59
+ else
60
+ amount.to_i
61
+ end
62
+ amount = -amount if direction == 'earlier'
63
+ Timecop.travel(current_time + amount.send(unit))
64
+ end
65
+
66
+ After do
67
+ Timecop.return
68
+ end
69
+
70
+ end
@@ -1,11 +1,23 @@
1
+ When('I peak at the logs') do
2
+ page.driver.manage.get_log(:browser)
3
+ end
4
+
5
+ When('I wait {float} seconds') do |seconds|
6
+ sleep(seconds)
7
+ end
8
+
1
9
  When /^I log the page$/ do
2
10
  Cucumber.logger.info page.body
3
11
  end
4
12
 
5
13
  Then /^I pry$/ do
6
- binding.pry
14
+ binding.pry # rubocop:disable Lint/Debugger
7
15
  end
8
16
 
9
17
  Then /^I sleep (.*) seconds$/ do |seconds|
10
18
  sleep seconds.to_f
11
19
  end
20
+
21
+ Then /^it should work$/ do
22
+ pending
23
+ end
@@ -0,0 +1,25 @@
1
+ module Resolvers
2
+ def resolve_locale(str)
3
+ str = str.gsub(/\s/, '.')
4
+ I18n.t(str)
5
+ end
6
+
7
+ def resolve_path(str)
8
+ send(str.tr(' ', '_') + '_path')
9
+ end
10
+
11
+ def resolve_ivar(str)
12
+ model = str.tr(' ', '_')
13
+ instance_variable_get("@#{model}")
14
+ end
15
+
16
+ def set_ivar(str, value)
17
+ model = str.tr(' ', '_')
18
+ instance_variable_set("@#{model}", value)
19
+ end
20
+
21
+ def resolve_class(str)
22
+ str.singularize.titleize.delete(' ').constantize
23
+ end
24
+ end
25
+ World(Resolvers)
@@ -1,5 +1,5 @@
1
1
  module Cucumber
2
2
  module Sammies
3
- VERSION = "0.1.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-sammies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Kirst
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-27 00:00:00.000000000 Z
11
+ date: 2020-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: '2.1'
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
- version: '1.16'
26
+ version: '2.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.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
- version: '10.0'
40
+ version: '13.0'
41
41
  description:
42
42
  email:
43
43
  - jskirst@gmail.com
@@ -46,8 +46,11 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - ".gitignore"
49
+ - ".rubocop.yml"
50
+ - ".ruby-version"
49
51
  - CODE_OF_CONDUCT.md
50
52
  - Gemfile
53
+ - Gemfile.lock
51
54
  - LICENSE.txt
52
55
  - README.md
53
56
  - Rakefile
@@ -61,10 +64,12 @@ files:
61
64
  - lib/cucumber/sammies/step_definitions/data_steps.rb
62
65
  - lib/cucumber/sammies/step_definitions/environment_steps.rb
63
66
  - lib/cucumber/sammies/step_definitions/form_steps.rb
67
+ - lib/cucumber/sammies/step_definitions/job_steps.rb
64
68
  - lib/cucumber/sammies/step_definitions/navigation_steps.rb
65
- - lib/cucumber/sammies/step_definitions/resolvers.rb
66
69
  - lib/cucumber/sammies/step_definitions/table_steps.rb
70
+ - lib/cucumber/sammies/step_definitions/time_steps.rb
67
71
  - lib/cucumber/sammies/step_definitions/troubleshooting_steps.rb
72
+ - lib/cucumber/sammies/support/resolvers.rb
68
73
  - lib/cucumber/sammies/version.rb
69
74
  - sammies.jpg
70
75
  homepage: https://github.com/starfighterheavy/cucumber-sammies
@@ -86,8 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
91
  - !ruby/object:Gem::Version
87
92
  version: '0'
88
93
  requirements: []
89
- rubyforge_project:
90
- rubygems_version: 2.5.2
94
+ rubygems_version: 3.1.2
91
95
  signing_key:
92
96
  specification_version: 4
93
97
  summary: Cucumber step definitions for rails applications.
@@ -1,23 +0,0 @@
1
- def resolve_locale(str)
2
- str = str.gsub(/\s/, '.')
3
- I18n.t(str)
4
- end
5
-
6
- def resolve_path(str)
7
- str.gsub(' ', '_') + '_path'
8
- end
9
-
10
- def resolve_ivar(str)
11
- model = str.gsub(' ', '_')
12
- instance_variable_get("@#{model}")
13
- end
14
-
15
- def set_ivar(str, value)
16
- model = str.gsub(' ', '_')
17
- instance_variable_set("@#{model}", value)
18
- end
19
-
20
-
21
- def resolve_class(str)
22
- str.singularize.titleize.gsub(' ', '').constantize
23
- end