cucumber_tricks 0.0.1

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.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ODg2ZDVlNTFhZmRjNjdhYjZlZGJlZmYxM2Q5YWU5YTlkNWQyYTdmNg==
5
+ data.tar.gz: !binary |-
6
+ Njg0YTdlMGE3OWRlMDU5ZGMyMTk0MzFlODhiNWFjNWQ0NGZmZWY5Yg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ YjBiNWM0M2Y1YjFhOWM1MmVjZDAwODQxMzM5OWZkZjU3NzhlZTkyNWNlYWFm
10
+ OGU2OTI1MTcwNzJkYjgwMjU0ZTkzNTY1MGZiM2ZhNTg2NmNiNjgzOGU5YmUz
11
+ ZGNiMDc1MjlhZjc5NzcwMDgyYWM1YjBjOTNjYjg1NTI1ZGJmMzE=
12
+ data.tar.gz: !binary |-
13
+ MzI4NmRlYmVlY2RiMjEyNzBiOTY3MTg3NDhlMjMyODY2ODhkMTcwYzEzYjVm
14
+ OWFmNjhiYzE3Mjg2MjVlZWRlMDBlMWE1M2NlNzQ1MDY1MzM2ZWY2MDk1YTRm
15
+ YTA0OTI3M2M4NGIzZDg2OWJkNzYxYjM2ODliMWFiN2Q2NDk5YTA=
Binary file
Binary file
@@ -0,0 +1,26 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .ruby-version
6
+ Gemfile.lock
7
+ coverage
8
+ InstalledFiles
9
+ lib/bundler/man
10
+ pkg
11
+ rdoc
12
+ spec/reports
13
+ test/tmp
14
+ test/version_tmp
15
+ tmp
16
+ vendor
17
+
18
+ # YARD artifacts
19
+ .yardoc
20
+ _yardoc
21
+ doc/
22
+
23
+ # emacs files
24
+ *~
25
+ *#
26
+ .#*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cucumber_tricks.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Philou
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # CucumberTricks
2
+
3
+ Cucumber step definition dsl extension to easily define more readable steps.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'cucumber_tricks'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install cucumber_tricks
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cucumber_tricks/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cucumber_tricks"
8
+ spec.version = CucumberTricks::VERSION
9
+ spec.authors = ["Philou"]
10
+ spec.email = ["philippe.bourgau@gmail.com"]
11
+ spec.description = %q{Cucumber step definition dsl extension to easily define more readable steps}
12
+ spec.summary = %q{Allows to reference entities with pronouns in gherkin, and to have dual steps, taking a single parameter, or a more detailed table.}
13
+ spec.homepage = "https://github.com/philou/cucumber_tricks"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "cucumber"
22
+
23
+ spec.add_development_dependency "bundler"
24
+ spec.add_development_dependency "rake"
25
+ end
@@ -0,0 +1,3 @@
1
+ require "cucumber_tricks/version"
2
+ require "cucumber_tricks/dsl_extensions"
3
+ require "cucumber_tricks/table_extensions"
@@ -0,0 +1,71 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ # Special capture form able to match short pronoun forms.
4
+ # NameOrPronounTransform('tool', 'hammer') would use the regex
5
+ #
6
+ # /^(a|an|the|this) tool( "([^"]*)")?$/
7
+ #
8
+ # Allowing to match things like
9
+ #
10
+ # * the tool "saw"
11
+ # * a tool
12
+ # * this tool
13
+ #
14
+ # The first time this capture is matched in a scenario, the given value
15
+ # is stored for any subsequent capture where no value is specified.
16
+ #
17
+ # If ever the first capture does not provide an explicit value, then
18
+ # the given default value is used (aka 'hammer' in the previous example)
19
+ #
20
+ def NameOrPronounTransform(kind, default_value)
21
+
22
+ knows_this_kind_of_things = Module.new do
23
+ self.send(:define_method, "main_#{kind}_name") do
24
+ @main_value ||= default_value
25
+ end
26
+ self.send(:define_method, "register_#{kind}_name") do |value|
27
+ @main_value ||= value
28
+ end
29
+ end
30
+
31
+ World(knows_this_kind_of_things)
32
+
33
+ Transform(/^(a|an|the|this|of) #{kind}( "([^"]*)")?$/) do |_prefix, _quoted_thing_name, thing_name|
34
+ if thing_name.nil?
35
+ self.send("main_#{kind}_name")
36
+ else
37
+ self.send("register_#{kind}_name",thing_name)
38
+ thing_name
39
+ end
40
+ end
41
+ end
42
+
43
+
44
+ # GivenEither, WhenEither and ThenEither defines 2 steps in 1 call.
45
+ # * &bloc : is the implementation of the step, taking a table as argument
46
+ # * table_regex : is the regex with no arguments, matching the table
47
+ # * inline_regex : is a regex matching a single textual argument, that
48
+ # will be embedded in a one cell table before calling the block
49
+ #
50
+ # example:
51
+ #
52
+ # GivenEither(/^I have an? ("[^"]*")$/,
53
+ # /^I have the following animals$/) do |table|
54
+ # create_animals(table)
55
+ # end
56
+ #
57
+ def register_either_step_definitions(adverb, inline_regex, table_regex, &block)
58
+ send(adverb,inline_regex) do |arg|
59
+ self.instance_exec(cucumber_table(arg), &block)
60
+ end
61
+ send(adverb,table_regex, &block)
62
+ end
63
+ def GivenEither(inline_regex, table_regex, &block)
64
+ register_either_step_definitions('Given', inline_regex, table_regex, &block)
65
+ end
66
+ def WhenEither(inline_regex, table_regex, &block)
67
+ register_either_step_definitions('When', inline_regex, table_regex, &block)
68
+ end
69
+ def ThenEither(inline_regex, table_regex, &block)
70
+ register_either_step_definitions('Then', inline_regex, table_regex, &block)
71
+ end
@@ -0,0 +1,42 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ class Cucumber::Ast::Table
4
+
5
+ def hashes_with_defaults(main_column, defaults = {})
6
+ hashes_with_default_column(main_column).map do |hash|
7
+ defaults.merge(hash)
8
+ end
9
+ end
10
+
11
+ def hash_2_lists
12
+ result = {}
13
+ raw.each do |row|
14
+ raise StandardError.new("hash_2_lists tables must have a '=>' in the second column") unless row.size == 1 or row[1] == '=>'
15
+
16
+ result[row[0]] = row.drop(2).reject &:empty?
17
+ end
18
+ result
19
+ end
20
+
21
+ private
22
+
23
+ def hashes_with_default_column(main_column)
24
+ if column_names.size == 1
25
+ raw.map do |row|
26
+ { main_column => row.first }
27
+ end
28
+ else
29
+ hashes
30
+ end
31
+ end
32
+
33
+ end
34
+
35
+
36
+ module KnowsCucumberTables
37
+ def cucumber_table(single_value)
38
+ Cucumber::Ast::Table.new([[single_value]])
39
+ end
40
+ end
41
+
42
+ World(KnowsCucumberTables)
@@ -0,0 +1,3 @@
1
+ module CucumberTricks
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cucumber_tricks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Philou
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - !binary |-
12
+ LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURrakNDQW5xZ0F3SUJB
13
+ Z0lCQVRBTkJna3Foa2lHOXcwQkFRVUZBREJITVJrd0Z3WURWUVFEREJCd2FH
14
+ bHMKYVhCd1pTNWliM1Z5WjJGMU1SVXdFd1lLQ1pJbWlaUHlMR1FCR1JZRloy
15
+ MWhhV3d4RXpBUkJnb0praWFKay9JcwpaQUVaRmdOamIyMHdIaGNOTVRNd09U
16
+ SXpNVEV3T1RBM1doY05NVFF3T1RJek1URXdPVEEzV2pCSE1Sa3dGd1lEClZR
17
+ UUREQkJ3YUdsc2FYQndaUzVpYjNWeVoyRjFNUlV3RXdZS0NaSW1pWlB5TEdR
18
+ QkdSWUZaMjFoYVd3eEV6QVIKQmdvSmtpYUprL0lzWkFFWkZnTmpiMjB3Z2dF
19
+ aU1BMEdDU3FHU0liM0RRRUJBUVVBQTRJQkR3QXdnZ0VLQW9JQgpBUUM4Q3Bv
20
+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WTJHem1pZy80UHVCRjRxM25od1BneFY2SDNTSDQvUHk3UUY1Q09aUFFsQ2RC
37
+ d1BZY3pxVwpYeEliWGhSVlhjZ2pCSFQwdzJIc1hrT3dtbVl2QnpicmZxdFR4
38
+ NU5zd3dIY0llUVpCL05JRDdiZXJJZjlhd3gzCnlMY2wxY21tNUFMdEovK0Jr
39
+ a21wMGk0YW1YZVRETXZxOXI4UEJzVnNRd3hZT1lKQlArVW14ejNQWDZIakZI
40
+ clEKWGRrWHgzb1oKLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
41
+ date: 2014-06-03 00:00:00.000000000 Z
42
+ dependencies:
43
+ - !ruby/object:Gem::Dependency
44
+ name: cucumber
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: bundler
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ - !ruby/object:Gem::Dependency
72
+ name: rake
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ description: Cucumber step definition dsl extension to easily define more readable
86
+ steps
87
+ email:
88
+ - philippe.bourgau@gmail.com
89
+ executables: []
90
+ extensions: []
91
+ extra_rdoc_files: []
92
+ files:
93
+ - .gitignore
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - cucumber_tricks.gemspec
99
+ - lib/cucumber_tricks.rb
100
+ - lib/cucumber_tricks/dsl_extensions.rb
101
+ - lib/cucumber_tricks/table_extensions.rb
102
+ - lib/cucumber_tricks/version.rb
103
+ homepage: https://github.com/philou/cucumber_tricks
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ! '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.0.3
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Allows to reference entities with pronouns in gherkin, and to have dual steps,
127
+ taking a single parameter, or a more detailed table.
128
+ test_files: []
Binary file