cucumber_factory 1.15.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -4
- data/CHANGELOG.md +18 -0
- data/Gemfile.cucumber-2.4.lock +2 -2
- data/Gemfile.cucumber-3.0.lock +2 -2
- data/Gemfile.cucumber-3.1.lock +2 -2
- data/README.md +7 -2
- data/lib/cucumber_factory/factory.rb +12 -6
- data/lib/cucumber_factory/version.rb +1 -1
- data/spec/cucumber_factory/steps_spec.rb +31 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 856fe1922e3b069b305e514911da87b4432acc34c89105b46cbf06d6cdd997be
|
4
|
+
data.tar.gz: a0f9631996850758343f66f79d96d88a1cf0216c4df464a8132677d462766525
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31d7825ded3ed0ed9e9c29a490ecbff0028b710cb4f33bddbf1e3846a744444c9ae53a852b37db72284a57f4ef40515e166f8043dbf4d96db5412205a7f3b3c0
|
7
|
+
data.tar.gz: 71ede7f9b7ae86335fb3eb1cd27ff9c72bd9ec9fbd958585fe4293443c7b6608b3cd0c21ea994971946ac69091722eb2a27714492d34a5e792583068c412b666
|
data/.travis.yml
CHANGED
@@ -9,6 +9,8 @@ gemfile:
|
|
9
9
|
- Gemfile.cucumber-3.0
|
10
10
|
- Gemfile.cucumber-3.1
|
11
11
|
|
12
|
+
dist: trusty
|
13
|
+
|
12
14
|
matrix:
|
13
15
|
exclude:
|
14
16
|
- gemfile: Gemfile.cucumber-3.1
|
@@ -39,7 +41,3 @@ script: bundle exec rake current_rspec
|
|
39
41
|
sudo: false
|
40
42
|
|
41
43
|
cache: bundler
|
42
|
-
|
43
|
-
notifications:
|
44
|
-
email:
|
45
|
-
- fail@makandra.de
|
data/CHANGELOG.md
CHANGED
@@ -15,6 +15,24 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
|
|
15
15
|
|
16
16
|
-
|
17
17
|
|
18
|
+
## 2.0.0 - 2020-02-10
|
19
|
+
|
20
|
+
### Breaking changes
|
21
|
+
|
22
|
+
- CucumberFactory now raises an `ArgumentError` if some parts of a matched step were not used. For example, while this step was accepted in recent versions, it will now complain with the message `Unable to parse attributes " and the ".`:
|
23
|
+
```
|
24
|
+
Given there is a user with the attribute 'foo' and the
|
25
|
+
```
|
26
|
+
|
27
|
+
|
28
|
+
### Compatible changes
|
29
|
+
|
30
|
+
- Single quoted attribute values and model names are now supported. Example:
|
31
|
+
|
32
|
+
```
|
33
|
+
Given 'jack' is a user with the first name 'Jack'
|
34
|
+
```
|
35
|
+
|
18
36
|
## 1.15.1 - 2019-05-30
|
19
37
|
|
20
38
|
### Compatible changes
|
data/Gemfile.cucumber-2.4.lock
CHANGED
data/Gemfile.cucumber-3.0.lock
CHANGED
data/Gemfile.cucumber-3.1.lock
CHANGED
data/README.md
CHANGED
@@ -190,8 +190,13 @@ Development
|
|
190
190
|
|
191
191
|
There are tests in `spec`. We only accept PRs with tests. To run tests:
|
192
192
|
|
193
|
-
- Install Ruby
|
194
|
-
- Create a local MySQL database `cucumber_factory_test`
|
193
|
+
- Install the Ruby version stated in `.ruby-version`
|
194
|
+
- Create a local MySQL/MariaDB database named `cucumber_factory_test`
|
195
|
+
```
|
196
|
+
$ mysql -u root -p
|
197
|
+
> create database cucumber_factory_test;
|
198
|
+
```
|
199
|
+
|
195
200
|
- Copy `spec/support/database.sample.yml` to `spec/support/database.yml` and enter your local credentials for the test databases
|
196
201
|
- Install development dependencies using `bundle install`
|
197
202
|
- Run tests with the default symlinked Gemfile using `bundle exec rspec` or explicit with `BUNDLE_GEMFILE=Gemfile.cucumber-x.x bundle exec rspec spec`
|
@@ -6,13 +6,13 @@ module CucumberFactory
|
|
6
6
|
TEXT_ATTRIBUTES_PATTERN = ' (?:with|and) these attributes:'
|
7
7
|
|
8
8
|
RECORD_PATTERN = 'there is an? (.+?)( \(.+?\))?'
|
9
|
-
NAMED_RECORD_PATTERN = '"([^\"]*)" is an? (.+?)( \(.+?\))?'
|
9
|
+
NAMED_RECORD_PATTERN = '(?:"([^\"]*)"|\'([^\']*)\') is an? (.+?)( \(.+?\))?'
|
10
10
|
|
11
11
|
NAMED_RECORDS_VARIABLE = :'@named_cucumber_factory_records'
|
12
12
|
|
13
13
|
VALUE_INTEGER = /\d+/
|
14
14
|
VALUE_DECIMAL = /[\d\.]+/
|
15
|
-
VALUE_STRING = /"[^"]*"/
|
15
|
+
VALUE_STRING = /"[^"]*"|'[^']*'/
|
16
16
|
VALUE_ARRAY = /\[[^\]]*\]/
|
17
17
|
VALUE_LAST_RECORD = /\babove\b/
|
18
18
|
|
@@ -30,7 +30,7 @@ module CucumberFactory
|
|
30
30
|
NAMED_CREATION_STEP_DESCRIPTOR = {
|
31
31
|
:kind => :Given,
|
32
32
|
:pattern => /^#{NAMED_RECORD_PATTERN}#{ATTRIBUTES_PATTERN}?$/,
|
33
|
-
:block => lambda { |a1, a2, a3, a4, a5| CucumberFactory::Factory.send(:parse_named_creation, self, a1, a2, a3, a4, a5) }
|
33
|
+
:block => lambda { |a1, a2, a3, a4, a5, a6| CucumberFactory::Factory.send(:parse_named_creation, self, a1, a2, a3, a4, a5, a6) }
|
34
34
|
}
|
35
35
|
|
36
36
|
CREATION_STEP_DESCRIPTOR = {
|
@@ -42,7 +42,7 @@ module CucumberFactory
|
|
42
42
|
NAMED_CREATION_STEP_DESCRIPTOR_WITH_TEXT_ATTRIBUTES = {
|
43
43
|
:kind => :Given,
|
44
44
|
:pattern => /^"#{NAMED_RECORD_PATTERN}#{ATTRIBUTES_PATTERN}#{TEXT_ATTRIBUTES_PATTERN}?$/,
|
45
|
-
:block => lambda { |a1, a2, a3, a4, a5, a6| CucumberFactory::Factory.send(:parse_named_creation, self, a1, a2, a3, a4, a5, a6) },
|
45
|
+
:block => lambda { |a1, a2, a3, a4, a5, a6, a7| CucumberFactory::Factory.send(:parse_named_creation, self, a1, a2, a3, a4, a5, a6, a7) },
|
46
46
|
:priority => true
|
47
47
|
}
|
48
48
|
|
@@ -93,8 +93,9 @@ module CucumberFactory
|
|
93
93
|
named_records(world)[name] = record
|
94
94
|
end
|
95
95
|
|
96
|
-
def parse_named_creation(world,
|
96
|
+
def parse_named_creation(world, double_quote_name, single_quote_name, raw_model, raw_variant, raw_attributes, raw_boolean_attributes, raw_multiline_attributes = nil)
|
97
97
|
record = parse_creation(world, raw_model, raw_variant, raw_attributes, raw_boolean_attributes, raw_multiline_attributes)
|
98
|
+
name = [double_quote_name, single_quote_name].compact.first
|
98
99
|
set_named_record(world, name, record)
|
99
100
|
end
|
100
101
|
|
@@ -103,11 +104,16 @@ module CucumberFactory
|
|
103
104
|
model_class = build_strategy.model_class
|
104
105
|
attributes = {}
|
105
106
|
if raw_attributes.try(:strip).present?
|
106
|
-
|
107
|
+
raw_attribute_fragment_regex = /(?:the |and |with |but |,| )+(.*?) (#{VALUE_SCALAR}|#{VALUE_ARRAY}|#{VALUE_LAST_RECORD})/
|
108
|
+
raw_attributes.scan(raw_attribute_fragment_regex).each do |fragment|
|
107
109
|
attribute = attribute_name_from_prose(fragment[0])
|
108
110
|
value = fragment[1]
|
109
111
|
attributes[attribute] = attribute_value(world, model_class, attribute, value)
|
110
112
|
end
|
113
|
+
unused_raw_attributes = raw_attributes.gsub(raw_attribute_fragment_regex, '')
|
114
|
+
if unused_raw_attributes.present?
|
115
|
+
raise ArgumentError, "Unable to parse attributes #{unused_raw_attributes.inspect}."
|
116
|
+
end
|
111
117
|
end
|
112
118
|
if raw_boolean_attributes.try(:strip).present?
|
113
119
|
raw_boolean_attributes.scan(/(?:which|who|that|is| )*(not )?(.+?)(?: and | but |,|$)+/).each do |fragment|
|
@@ -434,4 +434,35 @@ tags: ["foo", "bar"]
|
|
434
434
|
obj.attributes[:tags].should == ['foo', 'bar']
|
435
435
|
end
|
436
436
|
|
437
|
+
it "should allow single quote for attribute values" do
|
438
|
+
MachinistModel.should_receive(:make).with({ :attribute => "foo"})
|
439
|
+
invoke_cucumber_step("there is a machinist model with the attribute 'foo'")
|
440
|
+
end
|
441
|
+
|
442
|
+
it "should allow mixed single and double quotes for different attribute values" do
|
443
|
+
MachinistModel.should_receive(:make).with({ :attribute => "foo", :other_attribute => "bar" })
|
444
|
+
invoke_cucumber_step("there is a machinist model with the attribute 'foo' and the other attribute \"bar\"")
|
445
|
+
end
|
446
|
+
|
447
|
+
it "should allow mixed single quotes for model names" do
|
448
|
+
invoke_cucumber_step("'Some Prequel' is a movie with the title \"Before Sunrise\"")
|
449
|
+
invoke_cucumber_step('there is a movie with the title "Limitless"')
|
450
|
+
invoke_cucumber_step('there is a movie with the title \'Before Sunset\' and the prequel "Some Prequel"')
|
451
|
+
movie = Movie.find_by_title!('Before Sunset')
|
452
|
+
prequel = Movie.find_by_title!('Before Sunrise')
|
453
|
+
movie.prequel.should == prequel
|
454
|
+
end
|
455
|
+
|
456
|
+
it 'should not raise an error for a blank instance name' do
|
457
|
+
MachinistModel.should_receive(:make).with({ :attribute => 'foo' })
|
458
|
+
invoke_cucumber_step("'' is a machinist model with the attribute 'foo'")
|
459
|
+
end
|
460
|
+
|
461
|
+
it 'should warn if there are unused fragments' do
|
462
|
+
MachinistModel.should_not_receive(:make)
|
463
|
+
lambda { invoke_cucumber_step("there is a machinist model with the attribute NOQUOTES") }.should raise_error(ArgumentError, 'Unable to parse attributes " with the attribute NOQUOTES".')
|
464
|
+
lambda { invoke_cucumber_step("there is a machinist model with the attribute 'foo' and the ") }.should raise_error(ArgumentError, 'Unable to parse attributes " and the ".')
|
465
|
+
lambda { invoke_cucumber_step("there is a machinist model with the attribute 'foo'. the other_attribute 'bar' and the third attribute 'baz'") }.should raise_error(ArgumentError, 'Unable to parse attributes ".".')
|
466
|
+
end
|
467
|
+
|
437
468
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber_factory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henning Koch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
- !ruby/object:Gem::Version
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
|
-
rubygems_version: 3.
|
137
|
+
rubygems_version: 3.1.2
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: Create records from Cucumber features without writing step definitions.
|