unobtainium-cucumber 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1e548c830ba46d389e732d11a3cee4e48c00a31b
4
+ data.tar.gz: f939dffce9e566047ed81b0ebdef13dfe48b2202
5
+ SHA512:
6
+ metadata.gz: c53e8436432b1a60edcb2ec8e2beed3e8756ab9c1e368773c86d12561229e1357b3ba84f07753eefbe84132d236b8cdf84cff3f0ce5643f31c330ec437c19b7f
7
+ data.tar.gz: c6f3ba4a52a937b58b7e4c30510b486b4925e13d0922ac2a40d798d4525955be40e72bd8deff612f8e2668d89ff989a24981e05371b86063de77f8bb17924d3c
data/.codeclimate.yml ADDED
@@ -0,0 +1,34 @@
1
+ ---
2
+ engines:
3
+ bundler-audit:
4
+ enabled: true
5
+ duplication:
6
+ enabled: true
7
+ exclude_fingerprints:
8
+ - d85d6f12c93d79ccd43868b8315d8816
9
+ - a8e2b4ccb258f16eda697c5f98e21823
10
+ - 442a316695836b4f4693fe3786cd3396
11
+ - 1c24bb5da72323796b645814cc006684
12
+ - 4ff1112a73f7be30ecefa7bd90fdbf5a
13
+ config:
14
+ languages:
15
+ - ruby
16
+ - javascript
17
+ - python
18
+ - php
19
+ fixme:
20
+ enabled: true
21
+ rubocop:
22
+ enabled: true
23
+ ratings:
24
+ paths:
25
+ - Gemfile.lock
26
+ - "**.inc"
27
+ - "**.js"
28
+ - "**.jsx"
29
+ - "**.module"
30
+ - "**.php"
31
+ - "**.py"
32
+ - "**.rb"
33
+ exclude_paths:
34
+ - spec/
data/.gitignore ADDED
@@ -0,0 +1,57 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
51
+
52
+ # Editor files
53
+ .*.sw*
54
+
55
+ # Cucumber
56
+ C:\\nppdf32Log\\debuglog.txt
57
+ config/*-local.yml
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,78 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.2
3
+
4
+ # Metrics
5
+
6
+ Metrics/LineLength:
7
+ Max: 83
8
+ Details: >-
9
+ Line length of 80 is ideal for readability and compatibility; we'll accept
10
+ an extra 3 for minor edge cases.
11
+
12
+ Metrics/MethodLength:
13
+ Max: 35
14
+
15
+ Metrics/BlockNesting:
16
+ Max: 5
17
+
18
+ Metrics/AbcSize:
19
+ Max: 50
20
+
21
+ Metrics/PerceivedComplexity:
22
+ Max: 15
23
+
24
+ Metrics/CyclomaticComplexity:
25
+ Max: 15
26
+
27
+ Metrics/ClassLength:
28
+ Max: 300
29
+
30
+ Metrics/ModuleLength:
31
+ Max: 300
32
+
33
+ # Style
34
+
35
+ Style/StringLiterals:
36
+ Enabled: false
37
+
38
+ Style/ConditionalAssignment:
39
+ Enabled: false
40
+
41
+ Style/EmptyLinesAroundModuleBody:
42
+ Enabled: false
43
+
44
+ Style/AndOr:
45
+ Enabled: false
46
+
47
+ Style/Not:
48
+ Enabled: false
49
+
50
+ Style/NegatedIf:
51
+ Enabled: false
52
+
53
+ Style/RedundantReturn:
54
+ Enabled: false
55
+
56
+ Style/IfUnlessModifier:
57
+ Enabled: false
58
+
59
+ Style/TrailingCommaInLiteral:
60
+ Enabled: false
61
+
62
+ Style/FirstParameterIndentation:
63
+ Enabled: false
64
+
65
+ Style/TrailingUnderscoreVariable:
66
+ Enabled: false
67
+
68
+ Style/NumericLiterals:
69
+ Enabled: false
70
+
71
+ Style/FileName:
72
+ Enabled: false
73
+
74
+ Style/SpaceAfterNot:
75
+ Enabled: false
76
+
77
+ Style/RegexpLiteral:
78
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0
4
+ - 2.1
5
+ - 2.2
6
+ script:
7
+ - bundle exec rake
8
+ - bundle exec codeclimate-test-reporter
9
+ addons:
10
+ code_climate:
11
+ repo_token: 2341a8db591ce8112bd9a012ff0e3cfa20dce5705e69e3a89fda6829caf4f7fd
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in unobtainium-cucumber.gemspec
4
+ gemspec
5
+
6
+ gem "codeclimate-test-reporter", group: :test, require: nil
data/Gemfile.lock ADDED
@@ -0,0 +1,106 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ unobtainium-cucumber (0.1.0)
5
+ cucumber (~> 2.0)
6
+ unobtainium (~> 0.10)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ appium_lib (8.2.1)
12
+ awesome_print (~> 1.6)
13
+ json (~> 1.8)
14
+ nokogiri (~> 1.6.6)
15
+ selenium-webdriver (~> 2.50)
16
+ tomlrb (~> 1.1)
17
+ archive-zip (0.7.0)
18
+ io-like (~> 0.3.0)
19
+ ast (2.3.0)
20
+ awesome_print (1.7.0)
21
+ builder (3.2.2)
22
+ childprocess (0.5.9)
23
+ ffi (~> 1.0, >= 1.0.11)
24
+ chromedriver-helper (1.0.0)
25
+ archive-zip (~> 0.7.0)
26
+ nokogiri (~> 1.6)
27
+ codeclimate-test-reporter (1.0.3)
28
+ simplecov
29
+ collapsium (0.8.2)
30
+ collapsium-config (0.4.3)
31
+ collapsium (~> 0.7)
32
+ cucumber (2.4.0)
33
+ builder (>= 2.1.2)
34
+ cucumber-core (~> 1.5.0)
35
+ cucumber-wire (~> 0.0.1)
36
+ diff-lcs (>= 1.1.3)
37
+ gherkin (~> 4.0)
38
+ multi_json (>= 1.7.5, < 2.0)
39
+ multi_test (>= 0.1.2)
40
+ cucumber-core (1.5.0)
41
+ gherkin (~> 4.0)
42
+ cucumber-wire (0.0.1)
43
+ diff-lcs (1.2.5)
44
+ docile (1.1.5)
45
+ ffi (1.9.14)
46
+ gherkin (4.0.0)
47
+ io-like (0.3.0)
48
+ json (1.8.3)
49
+ mini_portile2 (2.1.0)
50
+ multi_json (1.12.1)
51
+ multi_test (0.1.2)
52
+ nokogiri (1.6.8.1)
53
+ mini_portile2 (~> 2.1.0)
54
+ parser (2.3.3.1)
55
+ ast (~> 2.2)
56
+ phantomjs (2.1.1.0)
57
+ powerpack (0.1.1)
58
+ ptools (1.3.3)
59
+ rainbow (2.1.0)
60
+ rake (11.3.0)
61
+ rubocop (0.46.0)
62
+ parser (>= 2.3.1.1, < 3.0)
63
+ powerpack (~> 0.1)
64
+ rainbow (>= 1.99.1, < 3.0)
65
+ ruby-progressbar (~> 1.7)
66
+ unicode-display_width (~> 1.0, >= 1.0.1)
67
+ ruby-progressbar (1.8.1)
68
+ rubyzip (1.2.0)
69
+ selenium-webdriver (2.53.4)
70
+ childprocess (~> 0.5)
71
+ rubyzip (~> 1.0)
72
+ websocket (~> 1.0)
73
+ simplecov (0.12.0)
74
+ docile (~> 1.1.0)
75
+ json (>= 1.8, < 3)
76
+ simplecov-html (~> 0.10.0)
77
+ simplecov-html (0.10.0)
78
+ sys-proctable (1.1.3)
79
+ tomlrb (1.2.3)
80
+ unicode-display_width (1.1.1)
81
+ unobtainium (0.10.0)
82
+ collapsium (~> 0.8)
83
+ collapsium-config (~> 0.4)
84
+ ptools (~> 1.3)
85
+ sys-proctable (~> 1.1)
86
+ websocket (1.2.3)
87
+ yard (0.9.5)
88
+
89
+ PLATFORMS
90
+ ruby
91
+
92
+ DEPENDENCIES
93
+ appium_lib
94
+ bundler (~> 1.12)
95
+ chromedriver-helper
96
+ codeclimate-test-reporter
97
+ phantomjs
98
+ rake (~> 11.2)
99
+ rubocop (~> 0.46)
100
+ selenium-webdriver
101
+ simplecov (~> 0.12)
102
+ unobtainium-cucumber!
103
+ yard (~> 0.9)
104
+
105
+ BUNDLED WITH
106
+ 1.13.6
data/LICENSE ADDED
@@ -0,0 +1,30 @@
1
+ Copyright (c) Jens Finkhaeuser (http://finkhaeuser.de/) and other
2
+ unobtainium-cucumber contributors. All rights not covered below are reserved.
3
+
4
+ The MIT +no-false-attribs License (MITNFA)
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to
8
+ deal in the Software without restriction, including without limitation the
9
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
+ sell copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ Distributions of all or part of the Software intended to be used by the
17
+ recipients as they would use the unmodified Software, containing modifications
18
+ that substantially alter, remove, or disable functionality of the Software,
19
+ outside of the documented configuration mechanisms provided by the Software,
20
+ shall be modified such that the Original Author's bug reporting email addresses
21
+ and urls are either replaced with the contact information of the parties
22
+ responsible for the changes, or removed entirely.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30
+ IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,150 @@
1
+ # unobtainium-cucumber
2
+ *Cucumber specific extensions to unobtainium.*
3
+
4
+ Instead of requiring [unobtainium](https://github.com/jfinkhaeuser/unobtainium)
5
+ in your [cucumber](https://cucumber.io/) project, just require this gem. It'll
6
+ automatically some cucumber specific features to your project:
7
+
8
+ - Reset the driver after each scenario.
9
+ - Take screenshots on failures.
10
+
11
+ Of course, each of these can be configured.
12
+
13
+ [![Gem Version](https://badge.fury.io/rb/unobtainium-cucumber.svg)](https://badge.fury.io/rb/unobtainium-cucumber)
14
+ [![Build status](https://travis-ci.org/jfinkhaeuser/unobtainium-cucumber.svg?branch=master)](https://travis-ci.org/jfinkhaeuser/unobtainium-cucumber)
15
+ [![Code Climate](https://codeclimate.com/github/jfinkhaeuser/unobtainium-cucumber/badges/gpa.svg)](https://codeclimate.com/github/jfinkhaeuser/unobtainium-cucumber)
16
+ [![Test Coverage](https://codeclimate.com/github/jfinkhaeuser/unobtainium-cucumber/badges/coverage.svg)](https://codeclimate.com/github/jfinkhaeuser/unobtainium-cucumber/coverage)
17
+
18
+ # Usage
19
+
20
+ The project's own *cucumber*-based test suite demonstrates most of the details.
21
+
22
+ In brief, all the setup happens in the `features/support/env.rb` file:
23
+
24
+ ```ruby
25
+ require "unobtainium-cucumber"
26
+ ```
27
+
28
+ And that's it.
29
+
30
+ ## Configuration
31
+
32
+ All configuration for this gem happens in the `config.yml` read in by
33
+ *unobtainium*. All configuration keys respected in this gem live under the
34
+ top-level `cucumber` key, i.e.:
35
+
36
+ ```yaml
37
+ # config.yaml
38
+ cucumber:
39
+ # this gem's keys go here
40
+ ```
41
+
42
+ ## Driver Reset
43
+
44
+ By default, the driver's `#reset` function is called after each scenario for
45
+ drivers that respond to such a function.
46
+
47
+ You can switch this off with the `cucumber.driver_reset` flag:
48
+
49
+ ```yaml
50
+ # config.yaml
51
+ cucumber:
52
+ driver_reset: false
53
+ ```
54
+
55
+ - If the flag is `false`, driver reset is switched off.
56
+ - If the flag is undefined (i.e. `nil`) or any other value, driver reset is
57
+ switched on. The recommended value to switch it on explicitly is, of course,
58
+ `true`.
59
+
60
+ ## Status Actions
61
+
62
+ One of the convenient features of this gem is that it allows you to cleanly
63
+ define callbacks for a particular scenario status.
64
+
65
+ It's an extension of the [After hook](https://github.com/cucumber/cucumber/wiki/Hooks)
66
+ that allows you to specify whether your callback is invoked after a `Scenario`
67
+ or `Scenario Outline` (or both), and only it has `#passed?` or is `#failed?`
68
+ (or both). Status actions thus are actions triggered by a scenario status.
69
+
70
+ Status actions can be any function or block that takes two arguments, the
71
+ cucumber [World](https://github.com/cucumber/cucumber/wiki/A-Whole-New-World)
72
+ object, and the scenario itself (for further querying).
73
+
74
+ You can register them by including the `StatusActions` module in `World`, and
75
+ then calling `#register_action`:
76
+
77
+ ```ruby
78
+
79
+ World(StatusActions)
80
+
81
+ # ...
82
+
83
+ Given(/I foo/) do
84
+ # Registers #some_func for passed scenarios and outlines
85
+ register_action(:passed?, method(:some_func))
86
+
87
+ # Limits registration to outlines
88
+ register_action(:failed?, method(:some_func), type: :outline)
89
+
90
+ # Registers a block
91
+ register_action(:failed?) do |world, scenario|
92
+ # ...
93
+ end
94
+ end
95
+ ```
96
+
97
+ There are a number of other methods in the `StatusActions` module that you
98
+ can use, but this is by far the most important.
99
+
100
+ ### Configuration
101
+
102
+ Of course, the above is for programmatically adding actions. But `unobtainium`
103
+ is configuration driven, so it makes sense to configure status actions in this
104
+ gem:
105
+
106
+ ```yaml
107
+ # config.yaml
108
+ cucumber:
109
+ status_actions:
110
+ passed?:
111
+ - global_action
112
+ failed?:
113
+ outline:
114
+ - dummy_action
115
+ scenario:
116
+ - method_from_own_extension
117
+ ```
118
+
119
+ Note how you can either provide an `Array` of method names to a status key,
120
+ or further divide the status key into individual lists for outlines and
121
+ scenarios.
122
+
123
+ ### Builtin Status Actions
124
+
125
+ There are not many status actions built into this gem, although that number
126
+ may rise. Currently, there is:
127
+
128
+ - `#store_screenshot` writes a browser screenshot to the `screenshots`
129
+ directory.
130
+ - `#store_content` writes a dump of the page content to the `content`
131
+ directory.
132
+
133
+ File names are timestamped, and include the scenario name. That should
134
+ make debugging a failed scenario easier.
135
+
136
+ If you do not configure any actions, the default is to take screenshots after
137
+ any failure.
138
+
139
+ ### Custom Actions
140
+
141
+ As demonstrated earlier, custom actions are easy to define. If they are
142
+ resolvable before a scenario starts (i.e. files are appropriately required),
143
+ then you can configure them as string names in the configuration.
144
+
145
+ You can specify any method of the `World` object, so any from your own
146
+ exentsions to `World`. Alternatively, any function that is resolvable works.
147
+ You might have to use fully qualified names.
148
+
149
+ Custom actions have limited support facilities in the `Action::Support` module.
150
+ Check it out if you write your own.
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ # Rubocop
2
+ require 'rubocop/rake_task'
3
+ RuboCop::RakeTask.new(:rubocop)
4
+
5
+ # Cucumber
6
+ require 'cucumber'
7
+ require 'cucumber/rake/task'
8
+ Cucumber::Rake::Task.new(:cuke) do |t|
9
+ t.cucumber_opts = "--fail-fast --format=pretty --expand "\
10
+ "--order=random --backtrace"
11
+ end
12
+
13
+ # Documentation
14
+ require 'yard'
15
+ YARD::Rake::YardocTask.new do |t|
16
+ t.files = ['lib/**/*.rb']
17
+ t.options = ['-m', 'markdown']
18
+ t.stats_options = ['--list-undoc']
19
+ end
20
+
21
+ # Combined test task
22
+ desc "Test all the things!"
23
+ task :test do
24
+ Rake::Task[:rubocop].invoke
25
+ Rake::Task[:cuke].invoke
26
+ end
27
+
28
+ # Default is the test task
29
+ task default: :test
data/config/config.yml ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ #
3
+ # unobtainium-cucumber
4
+ # https://github.com/jfinkhaeuser/unobtainium-cucumber
5
+ #
6
+ # Copyright (c) 2016 Jens Finkhaeuser and other unobtainium-cucumber
7
+ # contributors. All rights reserved.
8
+ #
9
+
10
+ driver: headless
11
+
12
+ cucumber:
13
+
14
+ # The following configuration options may be used to change the behaviour of
15
+ # the test suite.
16
+ #
17
+ # driver_reset: false
18
+
19
+ # The following options are expected by the test suite. Changing them may
20
+ # make the test suite fail. Proceed with caution!
21
+ status_actions:
22
+ passed?:
23
+ - global_action
24
+ failed?:
25
+ outline:
26
+ - dummy_action
27
+ scenario:
28
+ - method_from_own_extension
@@ -0,0 +1,12 @@
1
+ Feature:
2
+ Action functions
3
+
4
+ Scenario: Screenshot taking
5
+ Given I take a screenshot
6
+ Then I expect there to be a matching screenshot file
7
+
8
+
9
+ Scenario: Content capture
10
+ Given I navigate to the best site in the world
11
+ When I capture the page content
12
+ Then I expect there to be a matching content file
@@ -0,0 +1,17 @@
1
+ Feature:
2
+ Action support functions
3
+
4
+ Scenario Outline: Filename from scenario
5
+ Given I have a scenario named <name>
6
+ And I provide a tag <tag>
7
+ And the timestamp is <timestamp>
8
+ Then I expect the filename to match <filename>
9
+
10
+ Examples:
11
+ # Note:
12
+ # - all caps NIL becomes Ruby nil.
13
+ # - the filename will be interpreted as a regular expression as much
14
+ # as possible.
15
+ | name | tag | timestamp | filename |
16
+ | some scenario | NIL | 2016-11-25T15:48:13Z | 2016_11_25T15_48_13Z-some_scenario |
17
+ | some \| pipe | the_tag | 2016-11-25T15:48:13Z | 2016_11_25T15_48_13Z-the_tag-some_pipe |
@@ -0,0 +1,17 @@
1
+ Feature:
2
+ Drivers should be automatically reset after each scenario
3
+
4
+ Background:
5
+ Given I remove any reset functions
6
+
7
+ Scenario: Reset driver by default
8
+ Given I run a scenario to test driver reset
9
+ Then the driver should be reset at the end
10
+
11
+ Scenario: Skip if driver does not define reset
12
+ Given I run a scenario with a driver that knowns no reset
13
+ Then the driver should not be reset at the end
14
+
15
+ Scenario: Skip if driver reset is switched off
16
+ Given I run a scenario with driver reset switched off
17
+ Then the driver should not be reset at the end
@@ -0,0 +1,7 @@
1
+ Feature:
2
+ User-defined extensions should work with this gem
3
+
4
+ Scenario: World contains user-defined extensions
5
+ Given I register an extension with cucumber's World
6
+ Then I expect this extension to be used
7
+