active_cucumber 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.gitignore +1 -0
- data/Gemfile.lock +31 -1
- data/README.md +16 -1
- data/active_cucumber.gemspec +2 -1
- data/features/active_cucumber/attributes_for.feature +38 -0
- data/features/active_cucumber/create_one.feature +4 -4
- data/features/active_cucumber/diff_all/converting_data.feature +14 -5
- data/features/step_definitions/steps.rb +10 -0
- data/features/support/env.rb +4 -0
- data/features/support/show_cucumberator.rb +1 -1
- data/lib/active_cucumber/active_record_builder.rb +5 -0
- data/lib/active_cucumber.rb +8 -0
- metadata +18 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0e739af29fff1e73b368fa346b762f1b3e6e9af6
|
|
4
|
+
data.tar.gz: 03fb6ad6386402aee9243080ced90dca08f38a0a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d578b1a265feccfa2e71bbff1a15083bd4fabb2b60b832cf6b6095a62520c93933ec202b95fffd8508e321dd85d2630b4cffe2e7153178333aa391729dccf53f
|
|
7
|
+
data.tar.gz: e2c934e70da9018950f972efbdcfdb5034eae84296a72d0d529c553d21a791ad1aa3b8181085088b141c9cb718a9493f56ad126bb9812303038c393c70f94846
|
data/.coveralls.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
repo_token: UA9N9NOPq8BmyiuyP47XfY72kBpmRkVKy
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
active_cucumber (0.
|
|
4
|
+
active_cucumber (0.2.0)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
@@ -25,6 +25,13 @@ GEM
|
|
|
25
25
|
parser (~> 2.2)
|
|
26
26
|
builder (3.2.2)
|
|
27
27
|
colorize (0.7.7)
|
|
28
|
+
coveralls (0.8.10)
|
|
29
|
+
json (~> 1.8)
|
|
30
|
+
rest-client (>= 1.6.8, < 2)
|
|
31
|
+
simplecov (~> 0.11.0)
|
|
32
|
+
term-ansicolor (~> 1.3)
|
|
33
|
+
thor (~> 0.19.1)
|
|
34
|
+
tins (~> 1.6.0)
|
|
28
35
|
cucumber (2.1.0)
|
|
29
36
|
builder (>= 2.1.2)
|
|
30
37
|
cucumber-core (~> 1.3.0)
|
|
@@ -39,6 +46,9 @@ GEM
|
|
|
39
46
|
gherkin (~> 2.12.2)
|
|
40
47
|
multi_json (~> 1.11.2)
|
|
41
48
|
diff-lcs (1.2.5)
|
|
49
|
+
docile (1.1.5)
|
|
50
|
+
domain_name (0.5.25)
|
|
51
|
+
unf (>= 0.0.5, < 1.0.0)
|
|
42
52
|
factory_girl (4.5.0)
|
|
43
53
|
activesupport (>= 3.0.0)
|
|
44
54
|
faker (1.6.1)
|
|
@@ -46,18 +56,26 @@ GEM
|
|
|
46
56
|
gherkin (2.12.2)
|
|
47
57
|
multi_json (~> 1.3)
|
|
48
58
|
gherkin3 (3.1.2)
|
|
59
|
+
http-cookie (1.0.2)
|
|
60
|
+
domain_name (~> 0.5)
|
|
49
61
|
i18n (0.7.0)
|
|
50
62
|
json (1.8.3)
|
|
51
63
|
kappamaki (0.0.3)
|
|
64
|
+
mime-types (2.99)
|
|
52
65
|
minitest (5.8.3)
|
|
53
66
|
mortadella (0.2.1)
|
|
54
67
|
multi_json (1.11.2)
|
|
55
68
|
multi_test (0.1.2)
|
|
69
|
+
netrc (0.11.0)
|
|
56
70
|
parser (2.2.3.0)
|
|
57
71
|
ast (>= 1.1, < 3.0)
|
|
58
72
|
powerpack (0.1.1)
|
|
59
73
|
rainbow (2.0.0)
|
|
60
74
|
rake (10.4.2)
|
|
75
|
+
rest-client (1.8.0)
|
|
76
|
+
http-cookie (>= 1.0.2, < 2.0)
|
|
77
|
+
mime-types (>= 1.16, < 3.0)
|
|
78
|
+
netrc (~> 0.7)
|
|
61
79
|
rspec (3.4.0)
|
|
62
80
|
rspec-core (~> 3.4.0)
|
|
63
81
|
rspec-expectations (~> 3.4.0)
|
|
@@ -81,11 +99,22 @@ GEM
|
|
|
81
99
|
ruby-progressbar (~> 1.7)
|
|
82
100
|
tins (<= 1.6.0)
|
|
83
101
|
ruby-progressbar (1.7.5)
|
|
102
|
+
simplecov (0.11.1)
|
|
103
|
+
docile (~> 1.1.0)
|
|
104
|
+
json (~> 1.8)
|
|
105
|
+
simplecov-html (~> 0.10.0)
|
|
106
|
+
simplecov-html (0.10.0)
|
|
84
107
|
sqlite3 (1.3.11)
|
|
108
|
+
term-ansicolor (1.3.2)
|
|
109
|
+
tins (~> 1.0)
|
|
110
|
+
thor (0.19.1)
|
|
85
111
|
thread_safe (0.3.5)
|
|
86
112
|
tins (1.6.0)
|
|
87
113
|
tzinfo (1.2.2)
|
|
88
114
|
thread_safe (~> 0.1)
|
|
115
|
+
unf (0.1.4)
|
|
116
|
+
unf_ext
|
|
117
|
+
unf_ext (0.0.7.1)
|
|
89
118
|
|
|
90
119
|
PLATFORMS
|
|
91
120
|
ruby
|
|
@@ -94,6 +123,7 @@ DEPENDENCIES
|
|
|
94
123
|
active_cucumber!
|
|
95
124
|
activerecord
|
|
96
125
|
bundler
|
|
126
|
+
coveralls
|
|
97
127
|
cucumber
|
|
98
128
|
cucumber_lint
|
|
99
129
|
factory_girl
|
data/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
# ActiveCucumber
|
|
1
|
+
# ActiveCucumber
|
|
2
|
+
[](https://circleci.com/gh/Originate/active_cucumber) [](https://codeclimate.com/github/Originate/active_cucumber) [](https://gemnasium.com/Originate/active_cucumber) [](https://coveralls.io/github/Originate/active_cucumber?branch=kg-coveralls) [](https://badge.fury.io/rb/active_cucumber)
|
|
2
3
|
|
|
3
4
|
High-level Cucumber helpers for performing
|
|
4
5
|
[ActiveRecord](http://guides.rubyonrails.org/active_record_basics.html)-based
|
|
@@ -31,6 +32,7 @@ Given(/^the episodes:$/) do |table|
|
|
|
31
32
|
end
|
|
32
33
|
```
|
|
33
34
|
|
|
35
|
+
|
|
34
36
|
### Transforming values
|
|
35
37
|
|
|
36
38
|
Let's say our data model also contains a `Series` class
|
|
@@ -105,6 +107,7 @@ class EpisodeCreator < ActiveCucumber::Creator
|
|
|
105
107
|
end
|
|
106
108
|
```
|
|
107
109
|
|
|
110
|
+
|
|
108
111
|
### Context values
|
|
109
112
|
|
|
110
113
|
You can provide extra values to ActiveCucumber that are available as instance
|
|
@@ -140,6 +143,18 @@ end
|
|
|
140
143
|
```
|
|
141
144
|
|
|
142
145
|
|
|
146
|
+
### Retrieving record attributes
|
|
147
|
+
|
|
148
|
+
If you want to create the database record yourself,
|
|
149
|
+
you can have ActiveCucumber parse a Cucumber table into an attributes hash by calling
|
|
150
|
+
|
|
151
|
+
```ruby
|
|
152
|
+
ActiveCucumber.attributes_for <class>, table
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
with a vertical Cucumber table.
|
|
156
|
+
|
|
157
|
+
|
|
143
158
|
## Verifying database records
|
|
144
159
|
|
|
145
160
|
ActiveCucumber allows to compare ActiveRecord objects
|
data/active_cucumber.gemspec
CHANGED
|
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = 'active_cucumber'
|
|
6
|
-
s.version = '0.
|
|
6
|
+
s.version = '0.2.0'
|
|
7
7
|
s.authors = ['Kevin Goslar']
|
|
8
8
|
s.email = ['kevin.goslar@gmail.com']
|
|
9
9
|
s.summary = %s(ActiveRecord tools for Cucumber)
|
|
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
|
|
|
17
17
|
|
|
18
18
|
s.add_development_dependency 'activerecord'
|
|
19
19
|
s.add_development_dependency 'bundler'
|
|
20
|
+
s.add_development_dependency 'coveralls'
|
|
20
21
|
s.add_development_dependency 'cucumber'
|
|
21
22
|
s.add_development_dependency 'cucumber_lint'
|
|
22
23
|
s.add_development_dependency 'factory_girl'
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
Feature: ActiveCucumber.attributes_for
|
|
2
|
+
|
|
3
|
+
As a developer testing my own record create code
|
|
4
|
+
I want to be able to convert Cucumber tables into attribute hashes
|
|
5
|
+
So that I can use ActiveCucumber to parse Cucumber tables.
|
|
6
|
+
|
|
7
|
+
Rules:
|
|
8
|
+
- ActiveCucumbe.attributes_for(Class, table) returns the attributes of the given table as a hash
|
|
9
|
+
- the creator for this class is used to parse attributes in the Cucumber table
|
|
10
|
+
- related objects are getting created in the database
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Scenario: data attributes
|
|
14
|
+
When running "ActiveCucumber.attributes_for Episode, table" with this table:
|
|
15
|
+
| NAME | Encounter at Farpoint |
|
|
16
|
+
Then it returns the hash
|
|
17
|
+
"""
|
|
18
|
+
{
|
|
19
|
+
name: 'Encounter at Farpoint'
|
|
20
|
+
}
|
|
21
|
+
"""
|
|
22
|
+
And the database contains no episodes
|
|
23
|
+
And the database contains no shows
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
Scenario: associated objects are built
|
|
27
|
+
When running "ActiveCucumber.attributes_for Episode, table" with this table:
|
|
28
|
+
| SHOW | Star Trek TNG |
|
|
29
|
+
| NAME | Encounter at Farpoint |
|
|
30
|
+
Then it returns the hash
|
|
31
|
+
"""
|
|
32
|
+
{
|
|
33
|
+
show: Show.find_by(name: 'Star Trek TNG'),
|
|
34
|
+
name: 'Encounter at Farpoint'
|
|
35
|
+
}
|
|
36
|
+
"""
|
|
37
|
+
And the database contains no episodes
|
|
38
|
+
And the database contains the show "Star Trek TNG"
|
|
@@ -5,20 +5,20 @@ Feature: ActiveCucumber.create_one
|
|
|
5
5
|
|
|
6
6
|
Scenario: creating string columns
|
|
7
7
|
When running "ActiveCucumber.create_one Episode, table" with this table:
|
|
8
|
-
| NAME
|
|
8
|
+
| NAME | Encounter at Farpoint |
|
|
9
9
|
Then the database contains the given episode
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
Scenario: creating integer columns
|
|
13
13
|
When running "ActiveCucumber.create_one Episode, table" with this table:
|
|
14
|
-
| YEAR
|
|
14
|
+
| YEAR | 1994 |
|
|
15
15
|
Then the database contains the given episode
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
Scenario: creating associated objects
|
|
19
19
|
When running "ActiveCucumber.create_one Episode, table" with this table:
|
|
20
|
-
| SHOW
|
|
21
|
-
| NAME
|
|
20
|
+
| SHOW | Star Trek TNG |
|
|
21
|
+
| NAME | Encounter at Farpoint |
|
|
22
22
|
Then the database contains the given episode
|
|
23
23
|
And the database contains the show "Star Trek TNG"
|
|
24
24
|
|
|
@@ -5,9 +5,8 @@ Feature: Comparing different field types
|
|
|
5
5
|
So that database verifications are intuitive.
|
|
6
6
|
|
|
7
7
|
Rules:
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
- associated records can be converted to text via a Cucumberator
|
|
8
|
+
- the user can define a Cucumberator to define custom Cucumber representations of fields or associated records
|
|
9
|
+
- if the Cucumberator doesn't define a conversion or is missing altogether, the content is compared as-is
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
Background:
|
|
@@ -17,7 +16,17 @@ Feature: Comparing different field types
|
|
|
17
16
|
| Star Trek TNG | All Good Things | 1994 |
|
|
18
17
|
|
|
19
18
|
|
|
20
|
-
Scenario: verifying
|
|
19
|
+
Scenario: verifying a record without a Cucumberator
|
|
20
|
+
Given the genres:
|
|
21
|
+
| NAME |
|
|
22
|
+
| Science Fiction |
|
|
23
|
+
When running "ActiveCucumber.diff_all! Genre, table" with this table:
|
|
24
|
+
| NAME |
|
|
25
|
+
| Science Fiction |
|
|
26
|
+
Then the test passes
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
Scenario: verifying fields not defined in the Cucumberator
|
|
21
30
|
When running "ActiveCucumber.diff_all! Episode, table" with this table:
|
|
22
31
|
| NAME |
|
|
23
32
|
| Encounter at Farpoint |
|
|
@@ -25,7 +34,7 @@ Feature: Comparing different field types
|
|
|
25
34
|
Then the test passes
|
|
26
35
|
|
|
27
36
|
|
|
28
|
-
Scenario: verifying
|
|
37
|
+
Scenario: verifying numeric fields
|
|
29
38
|
When running "ActiveCucumber.diff_all! Episode, table" with this table:
|
|
30
39
|
| YEAR |
|
|
31
40
|
| 1987 |
|
|
@@ -28,6 +28,16 @@ Then(/^"(.*?)" does not have a director$/) do |show_name|
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
|
|
31
|
+
Then(/^it returns the hash$/) do |hash_string|
|
|
32
|
+
expect(@result).to match eval hash_string
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
Then(/^the database contains no (episodes|shows)$/) do |class_name|
|
|
37
|
+
expect(class_name.classify.constantize).to have(0).records
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
|
|
31
41
|
Then(/^the database contains the given episode$/) do
|
|
32
42
|
expect(Episode).to have(1).instance
|
|
33
43
|
ActiveCucumber.diff_one! Episode.first, @previous_table
|
data/features/support/env.rb
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
require 'coveralls'
|
|
2
|
+
Coveralls.wear!
|
|
3
|
+
|
|
1
4
|
require 'active_record'
|
|
2
5
|
require 'sqlite3'
|
|
3
6
|
require 'mortadella'
|
|
@@ -79,6 +82,7 @@ Before do
|
|
|
79
82
|
Episode.delete_all
|
|
80
83
|
Subscription.delete_all
|
|
81
84
|
Director.delete_all
|
|
85
|
+
Genre.delete_all
|
|
82
86
|
@error_checked = false
|
|
83
87
|
end
|
|
84
88
|
|
|
@@ -10,6 +10,11 @@ module ActiveCucumber
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
|
|
13
|
+
def attributes_for attributes
|
|
14
|
+
@creator_class.new(attributes, @context).factorygirl_attributes
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
|
|
13
18
|
# Creates all entries in the given horizontal table hash
|
|
14
19
|
def create_many table
|
|
15
20
|
table.map do |row|
|
data/lib/active_cucumber.rb
CHANGED
|
@@ -6,6 +6,14 @@ require 'active_cucumber/creator'
|
|
|
6
6
|
# The main namespace for this gem
|
|
7
7
|
module ActiveCucumber
|
|
8
8
|
|
|
9
|
+
# Returns the attributes to create an instance of the given ActiveRecord class
|
|
10
|
+
# that matches the given vertical Cucumber table
|
|
11
|
+
def self.attributes_for activerecord_class, cucumber_table, context: {}
|
|
12
|
+
builder = ActiveRecordBuilder.new activerecord_class, context
|
|
13
|
+
builder.attributes_for ActiveCucumber.vertical_table(cucumber_table)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
|
|
9
17
|
# Creates entries of the given ActiveRecord class
|
|
10
18
|
# specified by the given horizontal Cucumber table
|
|
11
19
|
def self.create_many activerecord_class, cucumber_table, context: {}
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_cucumber
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kevin Goslar
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-12-
|
|
11
|
+
date: 2015-12-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -38,6 +38,20 @@ dependencies:
|
|
|
38
38
|
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: coveralls
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
41
55
|
- !ruby/object:Gem::Dependency
|
|
42
56
|
name: cucumber
|
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -199,6 +213,7 @@ executables: []
|
|
|
199
213
|
extensions: []
|
|
200
214
|
extra_rdoc_files: []
|
|
201
215
|
files:
|
|
216
|
+
- ".coveralls.yml"
|
|
202
217
|
- ".gitignore"
|
|
203
218
|
- ".rubocop.yml"
|
|
204
219
|
- Gemfile
|
|
@@ -211,6 +226,7 @@ files:
|
|
|
211
226
|
- cucumber_lint.yml
|
|
212
227
|
- documentation/horizontal_diff.png
|
|
213
228
|
- documentation/vertical_diff.png
|
|
229
|
+
- features/active_cucumber/attributes_for.feature
|
|
214
230
|
- features/active_cucumber/create_many.feature
|
|
215
231
|
- features/active_cucumber/create_one.feature
|
|
216
232
|
- features/active_cucumber/diff_all/arrays_of_objects.feature
|