active_cucumber 0.0.10 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51a76f3bdbaa0df727d7aeca2971ff1eb003d179
4
- data.tar.gz: 8241aaae7b03a1cd3c4367ad989d21a31bc35568
3
+ metadata.gz: 82983292d8a2b4e6df0cd50cd877e235f614275c
4
+ data.tar.gz: da7a7f2dfa980ebda5473095de60f5330cd065ac
5
5
  SHA512:
6
- metadata.gz: c4ac02e89ff2de842f4dc2b468ebed869a814c776398450e21f1ccd98c2dc1b31aec223db46cace7ed01dcbf7f466910824fcef5c90aacd50400159b13d4bb90
7
- data.tar.gz: 46cf5be5cee5156333881d9255b92fc34e3fd75bfa8ed96eae978f5c89b0e3818a9f556e09e162e232c3985ffc9aaacc58f38b0e74b53e5fc8d7d697ab930c5a
6
+ metadata.gz: 6b60d2f0802e3ab25501630987719839a9c8a1eb95b9502a2a4a6e8851a1e2d6b1da4f61b5463f0d78382f1c0498c00a6e05cd3985b5a98ee548070bbb15723c
7
+ data.tar.gz: 9b7b0e600056a6166b62f94d19c40b9e6921faca98acfac453928022cb16bd900ebf5c1dbcf0d95552b7ae3955c4c47f71b89069298588829c46bd75c8f4da8c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_cucumber (0.0.10)
4
+ active_cucumber (0.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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.0.10'
6
+ s.version = '0.1.0'
7
7
  s.authors = ['Kevin Goslar']
8
8
  s.email = ['kevin.goslar@gmail.com']
9
9
  s.summary = %s(ActiveRecord tools for Cucumber)
@@ -66,7 +66,7 @@ Feature: ActiveCucumber.create_many
66
66
  When running "ActiveCucumber.create_many Episode, table" with this table:
67
67
  | SHOW | NAME | YEAR |
68
68
  | Star Trek TNG | Encounter at Farpoint | 1987 |
69
- | Star Trek TOS | The Paradise Syndrome | 1994 |
69
+ | Star Trek TOS | The Paradise Syndrome | 1968 |
70
70
  Then the database contains the given episodes
71
71
  And the database contains the shows "Star Trek TNG" and "Star Trek TOS"
72
72
 
@@ -0,0 +1,32 @@
1
+ Feature: Comparing arrays of ActiveRecord instances
2
+
3
+ As a developer having complex database query logic
4
+ I want to be able to compare against a manually created array of ActiveRecord objects
5
+ So that I can use ActiveCucumber for a large variety of data sources.
6
+
7
+ Rules:
8
+ - one can give an ActiveRecord class or an array of ActiveRecord instances to ActiveCucumber
9
+ - ActiveCucumber choses the Cucumperer based on the class of each record
10
+
11
+
12
+ Background:
13
+ Given the episodes:
14
+ | NAME | YEAR |
15
+ | Encounter at Farpoint | 1987 |
16
+ | All Good Things | 1994 |
17
+
18
+
19
+ Scenario: comparing all instances of an ActiveRecord class
20
+ When running "ActiveCucumber.diff_all! Episode, table" with this table:
21
+ | NAME | YEAR |
22
+ | Encounter at Farpoint | 1987 |
23
+ | All Good Things | 1994 |
24
+ Then the test passes
25
+
26
+
27
+ Scenario: comparing an array of ActiveRecord instances
28
+ When running "ActiveCucumber.diff_all! [Episode.first, Episode.last], table" with this table:
29
+ | NAME | YEAR |
30
+ | Encounter at Farpoint | 1987 |
31
+ | All Good Things | 1994 |
32
+ Then the test passes
@@ -0,0 +1,19 @@
1
+ Feature: Using contextual data
2
+
3
+ As a developer wanting to use non-database data in my database specs
4
+ I want to be able to provide contextual data to ActiveCucumber
5
+ So that I can use it in my specs.
6
+
7
+ Rules:
8
+ - contextual data is provided as an additional parameter containing key-value pairs in calls to ActiveCucumber
9
+ - all contextual data is made available to Cucumberators as instance variables whose name is the key and value is the value
10
+
11
+
12
+ Scenario: using contextual data
13
+ Given the subscriptions:
14
+ | SUBSCRIBER | SHOW |
15
+ | Q | Star Trek TNG |
16
+ When running "ActiveCucumber.diff_all! Subscription, table, context: { current_user: 'Q' }" with this table:
17
+ | SUBSCRIBER | SHOW |
18
+ | me | Star Trek TNG |
19
+ Then the test passes
@@ -0,0 +1,41 @@
1
+ Feature: Comparing different field types
2
+
3
+ As a developer testing a relational database
4
+ I want to verify my database content and associations the same way
5
+ So that database verifications are intuitive.
6
+
7
+ Rules:
8
+ - content in data columns without a Cucumberator is compared as-is with the table content
9
+ - content in data columns can be modified through a Cucumberator before verification
10
+ - associated records can be converted to text via a Cucumberator
11
+
12
+
13
+ Background:
14
+ Given the episodes:
15
+ | SHOW | NAME | YEAR |
16
+ | Star Trek TNG | Encounter at Farpoint | 1987 |
17
+ | Star Trek TNG | All Good Things | 1994 |
18
+
19
+
20
+ Scenario: verifying string fields
21
+ When running "ActiveCucumber.diff_all! Episode, table" with this table:
22
+ | NAME |
23
+ | Encounter at Farpoint |
24
+ | All Good Things |
25
+ Then the test passes
26
+
27
+
28
+ Scenario: verifying non-string fields
29
+ When running "ActiveCucumber.diff_all! Episode, table" with this table:
30
+ | YEAR |
31
+ | 1987 |
32
+ | 1994 |
33
+ Then the test passes
34
+
35
+
36
+ Scenario: verifying associated fields through a Cucumberator
37
+ When running "ActiveCucumber.diff_all! Episode, table" with this table:
38
+ | SHOW | NAME |
39
+ | Star Trek TNG | Encounter at Farpoint |
40
+ | Star Trek TNG | All Good Things |
41
+ Then the test passes
@@ -0,0 +1,32 @@
1
+ Feature: Verifying only certain columns
2
+
3
+ As a developer working only on a subset of database columns
4
+ I want to specify only those columns in my tests
5
+ So that my specs are concise, noise free, and to the point.
6
+
7
+ Rules:
8
+ - tables given to `diff_all!` can contain only a subset of the existing columns
9
+ - only the given columns are verified against the database content
10
+
11
+
12
+ Background:
13
+ Given the episodes:
14
+ | SHOW | NAME | YEAR |
15
+ | Star Trek TNG | Encounter at Farpoint | 1987 |
16
+ | Star Trek TNG | All Good Things | 1994 |
17
+
18
+
19
+ Scenario: verifying all columns
20
+ When running "ActiveCucumber.diff_all! Episode, table" with this table:
21
+ | SHOW | NAME | YEAR |
22
+ | Star Trek TNG | Encounter at Farpoint | 1987 |
23
+ | Star Trek TNG | All Good Things | 1994 |
24
+ Then the test passes
25
+
26
+
27
+ Scenario: verifying a subset of columns
28
+ When running "ActiveCucumber.diff_all! Episode, table" with this table:
29
+ | YEAR |
30
+ | 1987 |
31
+ | 1994 |
32
+ Then the test passes
@@ -0,0 +1,35 @@
1
+ Feature: Verifying only certain database rows
2
+
3
+ As a developer specifying the result of database operations
4
+ I want to have the choice to verify either the full database content or only a part of it
5
+ So that my specs aren't polluted by independent side effects and remain focussed on the functionality described.
6
+
7
+ Rules:
8
+ - when providing an ActiveRecord class to `ActiveCucumber.diff_all!`
9
+ it verifies the whole database table
10
+ - when providing an AREL query to `ActiveCucumber.diff_all!`
11
+ it verifies only the specified records in the respective table
12
+
13
+
14
+ Background:
15
+ Given the episodes:
16
+ | SHOW | NAME | YEAR |
17
+ | Star Trek TOS | The Paradise Syndrome | 1968 |
18
+ | Star Trek TNG | Encounter at Farpoint | 1987 |
19
+ | Star Trek TNG | All Good Things | 1994 |
20
+
21
+
22
+ Scenario: comparing against the whole table by providing an ActiveRecord class
23
+ When running "ActiveCucumber.diff_all! Episode, table" with this table:
24
+ | SHOW | NAME | YEAR |
25
+ | Star Trek TOS | The Paradise Syndrome | 1968 |
26
+ | Star Trek TNG | Encounter at Farpoint | 1987 |
27
+ | Star Trek TNG | All Good Things | 1994 |
28
+ Then the test passes
29
+
30
+
31
+ Scenario: comparing against a subset of a table by providing an AREL query
32
+ When running "ActiveCucumber.diff_all! Show.first.episodes, table" with this table:
33
+ | SHOW | NAME | YEAR |
34
+ | Star Trek TOS | The Paradise Syndrome | 1968 |
35
+ Then the test passes
@@ -1,8 +1,13 @@
1
- Feature: ActiveCucumber.diff_all!
1
+ Feature: comparing against all existing records
2
2
 
3
- As a Cucumber user
4
- I want to verify all existing records using a Cucumber table
5
- So that I can easily and intuitively check the result of my database-facing operations.
3
+ As a developer verifying my database content
4
+ I want that my specs verify the exact database content
5
+ So that I can be sure that my application behaves exactly as I think it does.
6
+
7
+ Rules:
8
+ - missing rows cause test failure
9
+ - extra rows cause test failure
10
+ - mismatching fields cause test failure
6
11
 
7
12
 
8
13
  Background:
@@ -12,30 +17,6 @@ Feature: ActiveCucumber.diff_all!
12
17
  | Star Trek TNG | All Good Things | 1994 |
13
18
 
14
19
 
15
- Scenario: verifying string fields
16
- When running "ActiveCucumber.diff_all! Episode, table" with this table:
17
- | NAME |
18
- | Encounter at Farpoint |
19
- | All Good Things |
20
- Then the test passes
21
-
22
-
23
- Scenario: verifying non-string fields
24
- When running "ActiveCucumber.diff_all! Episode, table" with this table:
25
- | YEAR |
26
- | 1987 |
27
- | 1994 |
28
- Then the test passes
29
-
30
-
31
- Scenario: verifying associated fields through a Cucumberator
32
- When running "ActiveCucumber.diff_all! Episode, table" with this table:
33
- | SHOW | NAME |
34
- | Star Trek TNG | Encounter at Farpoint |
35
- | Star Trek TNG | All Good Things |
36
- Then the test passes
37
-
38
-
39
20
  Scenario: complete table match
40
21
  When running "ActiveCucumber.diff_all! Episode, table" with this table:
41
22
  | SHOW | NAME | YEAR |
@@ -69,13 +50,3 @@ Feature: ActiveCucumber.diff_all!
69
50
  | Star Trek TNG | All Good Things |
70
51
  Then the test fails
71
52
  And Cucumparer prints the error message "Tables were not identical"
72
-
73
-
74
- Scenario: using context values
75
- Given the subscriptions:
76
- | SUBSCRIBER | SHOW |
77
- | Q | Star Trek TNG |
78
- When running "ActiveCucumber.diff_all! Subscription, table, context: { current_user: 'Q' }" with this table:
79
- | SUBSCRIBER | SHOW |
80
- | me | Star Trek TNG |
81
- Then the test passes
@@ -2,8 +2,8 @@ module ActiveCucumber
2
2
 
3
3
  class Cucumparer
4
4
 
5
- def initialize clazz, cucumber_table, context
6
- @clazz = clazz
5
+ def initialize database_content, cucumber_table, context
6
+ @database_content = database_content
7
7
  @cucumber_table = cucumber_table
8
8
  @context = context
9
9
  end
@@ -11,7 +11,8 @@ module ActiveCucumber
11
11
  # Returns all entries in the database as a horizontal Mortadella table
12
12
  def to_horizontal_table
13
13
  mortadella = Mortadella::Horizontal.new headers: @cucumber_table.headers
14
- @clazz.order('id ASC').each do |record|
14
+ @database_content = @database_content.all if @database_content.respond_to? :all
15
+ @database_content.each do |record|
15
16
  cucumberator = cucumberator_for record
16
17
  mortadella << @cucumber_table.headers.map do |header|
17
18
  cucumberator.value_for header
@@ -33,20 +34,20 @@ module ActiveCucumber
33
34
  private
34
35
 
35
36
  # Returns the Cucumberator subclass to be used by this Cucumparer instance
36
- def cucumberator_class
37
- cucumberator_class_name.constantize
37
+ def cucumberator_class object
38
+ cucumberator_class_name(object).constantize
38
39
  rescue NameError
39
40
  Cucumberator
40
41
  end
41
42
 
42
43
  # Returns the name of the Cucumberator subclass to be used by this Cucumparer instance.
43
- def cucumberator_class_name
44
- "#{@clazz.name}Cucumberator"
44
+ def cucumberator_class_name object
45
+ "#{object.class.name}Cucumberator"
45
46
  end
46
47
 
47
48
  # Returns the Cucumberator object for the given ActiveRecord instance
48
49
  def cucumberator_for object
49
- cucumberator_class.new object, @context
50
+ cucumberator_class(object).new object, @context
50
51
  end
51
52
 
52
53
  end
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.0.10
4
+ version: 0.1.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-11-29 00:00:00.000000000 Z
11
+ date: 2015-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -213,7 +213,12 @@ files:
213
213
  - documentation/vertical_diff.png
214
214
  - features/active_cucumber/create_many.feature
215
215
  - features/active_cucumber/create_one.feature
216
- - features/active_cucumber/diff_all.feature
216
+ - features/active_cucumber/diff_all/arrays_of_objects.feature
217
+ - features/active_cucumber/diff_all/context_values.feature
218
+ - features/active_cucumber/diff_all/converting_data.feature
219
+ - features/active_cucumber/diff_all/filtering_columns.feature
220
+ - features/active_cucumber/diff_all/filtering_rows.feature
221
+ - features/active_cucumber/diff_all/mismatching_data.feature
217
222
  - features/active_cucumber/diff_one.feature
218
223
  - features/step_definitions/steps.rb
219
224
  - features/support/director.rb