mortadella 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d262e9420c66f885fce3433ffe7561223bda92af
4
- data.tar.gz: 07b7dd17e3765b29a143e8885ff791fc21ed5efc
3
+ metadata.gz: dcb0135d2cd6149ea0a5e5f0a27eae2050372ec3
4
+ data.tar.gz: c03efef5ceb407af06e1f4919f832add627348d4
5
5
  SHA512:
6
- metadata.gz: aab43937cad6d38d7e12ec49eb3c1b0d4e6503f8d510e2bc0503ad6d375f229e4ba54cb836a6af42110dfc2dd0ac209365265ead7574390763108392d0d94de3
7
- data.tar.gz: 826aabe59c6e123d823202d8078c014fc5d0c1c9015bff60668b811eab8a674624483e6f3ee63c9006f5fc5b8afba53743b17c6bfc9866ec7b852497c1869764
6
+ metadata.gz: d7b5aa25740a8721fa811fb717d9958c8e2bd40b9dc3123adcdc9fdcb928d7739bb48f13af20d6baa9425e85c0531af16662abc9d3b3f3f9fe206d61f1036e5d
7
+ data.tar.gz: d7111ad812fb2f701ebe03d580ee4f1e77ebfdf52a70ad72c48ee50c86f73800c15daa65a98aa2b12c2dcb83da64a04090d6177479e9470d6c93f420b90f4b59
data/.rubocop.yml CHANGED
@@ -9,6 +9,13 @@ Metrics/LineLength:
9
9
  Style/EmptyLines:
10
10
  Enabled: false
11
11
 
12
+ Style/EmptyLinesAroundClassBody:
13
+ EnforcedStyle: empty_lines
14
+
15
+ Style/EmptyLinesAroundModuleBody:
16
+ EnforcedStyle: empty_lines
17
+
18
+
12
19
 
13
20
  Style/MethodDefParentheses:
14
21
  EnforcedStyle: require_no_parentheses
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.2
1
+ 2.2.3
data/Gemfile.lock CHANGED
@@ -1,48 +1,47 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mortadella (0.0.2)
4
+ mortadella (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- ast (2.0.0)
10
- astrolabe (1.3.0)
11
- parser (>= 2.2.0.pre.3, < 3.0)
9
+ ast (2.1.0)
10
+ astrolabe (1.3.1)
11
+ parser (~> 2.2)
12
12
  builder (3.2.2)
13
- cucumber (2.0.0)
13
+ cucumber (2.1.0)
14
14
  builder (>= 2.1.2)
15
- cucumber-core (~> 1.1.3)
15
+ cucumber-core (~> 1.3.0)
16
16
  diff-lcs (>= 1.1.3)
17
- gherkin (~> 2.12)
17
+ gherkin3 (~> 3.1.0)
18
18
  multi_json (>= 1.7.5, < 2.0)
19
19
  multi_test (>= 0.1.2)
20
- cucumber-core (1.1.3)
21
- gherkin (~> 2.12.0)
20
+ cucumber-core (1.3.0)
21
+ gherkin3 (~> 3.1.0)
22
22
  diff-lcs (1.2.5)
23
- gherkin (2.12.2)
24
- multi_json (~> 1.3)
25
- multi_json (1.11.1)
23
+ gherkin3 (3.1.2)
24
+ multi_json (1.11.2)
26
25
  multi_test (0.1.2)
27
- parser (2.2.2.5)
26
+ parser (2.2.3.0)
28
27
  ast (>= 1.1, < 3.0)
29
28
  powerpack (0.1.1)
30
29
  rainbow (2.0.0)
31
30
  rake (10.4.2)
32
- rspec (3.2.0)
33
- rspec-core (~> 3.2.0)
34
- rspec-expectations (~> 3.2.0)
35
- rspec-mocks (~> 3.2.0)
36
- rspec-core (3.2.3)
37
- rspec-support (~> 3.2.0)
38
- rspec-expectations (3.2.1)
31
+ rspec (3.3.0)
32
+ rspec-core (~> 3.3.0)
33
+ rspec-expectations (~> 3.3.0)
34
+ rspec-mocks (~> 3.3.0)
35
+ rspec-core (3.3.2)
36
+ rspec-support (~> 3.3.0)
37
+ rspec-expectations (3.3.1)
39
38
  diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.2.0)
41
- rspec-mocks (3.2.1)
39
+ rspec-support (~> 3.3.0)
40
+ rspec-mocks (3.3.2)
42
41
  diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.2.0)
44
- rspec-support (3.2.2)
45
- rubocop (0.32.0)
42
+ rspec-support (~> 3.3.0)
43
+ rspec-support (3.3.0)
44
+ rubocop (0.34.2)
46
45
  astrolabe (~> 1.3)
47
46
  parser (>= 2.2.2.5, < 3.0)
48
47
  powerpack (~> 0.1)
@@ -60,3 +59,6 @@ DEPENDENCIES
60
59
  rake
61
60
  rspec
62
61
  rubocop
62
+
63
+ BUNDLED WITH
64
+ 1.10.6
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # Delicious Mock Ruby Tables
2
2
 
3
3
  [![Build Status](https://circleci.com/gh/Originate/mortadella/tree/master.svg?style=shield)](https://circleci.com/gh/Originate/mortadella)
4
+ [![Dependency Status](https://gemnasium.com/Originate/mortadella.svg)](https://gemnasium.com/Originate/mortadella)
4
5
  [![License](http://img.shields.io/:license-MIT-blue.svg?style=flat)](LICENSE.txt)
5
6
 
7
+
6
8
  Mortadella makes it easy to programmatically build data tables
7
9
  that can be compared to Cucumber tables
8
10
  through `cucumber_table.diff! mortadella_table`.
@@ -23,6 +25,11 @@ _Oh no, our algorithm selected too many apples!_
23
25
 
24
26
  ## Usage
25
27
 
28
+ Mortadella supports horizontal and vertical Cucumber tables.
29
+
30
+
31
+ ### Horizontal Tables
32
+
26
33
  * In your cucumber spec, define the expected data in table form
27
34
 
28
35
  ```cucumber
@@ -30,6 +37,7 @@ _Oh no, our algorithm selected too many apples!_
30
37
  | INGREDIENT | AMOUNT |
31
38
  | flour | 12 oz |
32
39
  | butter | 2 oz |
40
+ | apples | 3 pc |
33
41
  ```
34
42
 
35
43
  * in the step definition for this, build an equivalent Mortadella table with the actual data,
@@ -37,11 +45,50 @@ _Oh no, our algorithm selected too many apples!_
37
45
 
38
46
  ```ruby
39
47
  Then /^I have these ingredients$/ do |expected_ingredients|
40
- actual_ingredients = Mortadella.new headers: ['INGREDIENT', 'AMOUNT']
48
+ actual_ingredients = Mortadella::Horizontal.new headers: ['INGREDIENT', 'AMOUNT']
41
49
  actual_ingredients << ['flour', '12 oz'] # This data should come from your app
42
50
  actual_ingredients << ['butter', '2 oz'] # This data should come from your app
51
+ actual_ingredients << ['apples', '3 pc'] # This data should come from your app
43
52
  expected_ingredients.diff! actual_ingredients.table
44
53
  end
45
54
  ```
46
55
 
47
- * you can also [dry up repetitive fields](https://github.com/Originate/mortadella/blob/master/features/drying_up_fields.feature) for better readability
56
+ * you can also
57
+ [dry up repetitive fields](https://github.com/Originate/mortadella/blob/master/features/horizontal_tables/drying_up_fields.feature)
58
+ for better readability
59
+
60
+
61
+ ### Vertical Tables
62
+
63
+ * In your cucumber spec, define the expected data in table form
64
+
65
+ ```cucumber
66
+ Then my pie conforms to these specs:
67
+ | WEIGHT | 2 lbs |
68
+ | PORTIONS | 8 |
69
+ | CALORIES | 500 |
70
+ ```
71
+
72
+ * in the step definition for this, build an equivalent Mortadella table with the actual data,
73
+ and diff the Cucumber table with the expected data against it.
74
+
75
+ ```ruby
76
+ Then /^My pie has these metrics:$/ do |expected_metrics|
77
+ actual_metrics = Mortadella::Vertical.new
78
+ actual_metrics['WEIGHT'] = '2 lbs' # This data should come from your app
79
+ actual_metrics['PORTIONS'] = 8 # This data should come from your app
80
+ actual_metrics['CALORIES'] = 500 # This data should come from your app
81
+ expected_metrics.diff! actual_metrics.table
82
+ end
83
+ ```
84
+
85
+
86
+ ## Development
87
+
88
+ * set up local environment: `bundle install`
89
+ * run all tests: `bundle exec rake`
90
+ * run linter only: `rake lint`
91
+ * run tests only: `rake features`
92
+ * publish a new gem:
93
+ * update the version in [mortadella.gemspec](mortadella.gemspec)
94
+ * `rake release`
@@ -0,0 +1,19 @@
1
+ Feature: Creating mock data tables
2
+
3
+ As a Cucumber user
4
+ I want to programmatically create horizontal mock data tables from application data
5
+ So that I can use Cucumber's built-in table diffing to verify my application data ergonomically.
6
+
7
+
8
+ Scenario: Creating a simple data table
9
+ Given I create a horizontal Mortadella instance: "m = Mortadella::Horizontal.new headers: ['DAY', 'ACTIVITY']"
10
+ And I add a data row: "m << ['Monday', 'mowing']"
11
+ And I add another data row: "m << ['Tuesday', 'tutoring']"
12
+ And I add another data row: "m << ['Wednesday', 'welcoming']"
13
+ When I request the instance data table "m.table"
14
+ Then Mortadella returns an object that matches this Cucumber table
15
+ | DAY | ACTIVITY |
16
+ | Monday | mowing |
17
+ | Tuesday | tutoring |
18
+ | Wednesday | welcoming |
19
+
@@ -6,7 +6,7 @@ Feature: Drying up repetitive fields
6
6
 
7
7
 
8
8
  Scenario: drying up repetitive columns
9
- Given I have a Mortadella instance with a DRY column: "m = Mortadella.new headers: ['DAY', 'ACTIVITY'], dry: ['DAY']"
9
+ Given I have a Mortadella instance with a DRY column: "m = Mortadella::Horizontal.new headers: ['DAY', 'ACTIVITY'], dry: ['DAY']"
10
10
 
11
11
  And I add an activity for Monday: "m << ['Monday', 'mowing']"
12
12
  And I add another activity for Monday: "m << ['Monday', 'musing']"
@@ -17,7 +17,7 @@ Feature: Drying up repetitive fields
17
17
  And I add another activity for Tuesday: "m << ['Tuesday', 'throwing']"
18
18
 
19
19
  When I request the instance data table "m.table"
20
- Then I receive a table with repeated day names cleared out for better readability
20
+ Then Mortadella returns a table with repeated day names cleared out for better readability
21
21
  | DAY | ACTIVITY |
22
22
  | Monday | mowing |
23
23
  | | musing |
@@ -6,13 +6,13 @@ Feature: Verifying emptiness
6
6
 
7
7
 
8
8
  Scenario: an empty table
9
- Given I have a Mortadella instance: "m = Mortadella.new headers: ['foo']"
9
+ Given I have a Mortadella instance: "m = Mortadella::Horizontal.new headers: ['foo']"
10
10
  When I ask it whether it is empty: "m.empty?"
11
11
  Then it responds with true
12
12
 
13
13
 
14
14
  Scenario: a non-empty table
15
- Given I have a Mortadella instance: "m = Mortadella.new headers: ['foo']"
15
+ Given I have a Mortadella instance: "m = Mortadella::Horizontal.new headers: ['foo']"
16
16
  And I add a data row: "m << ['bar']"
17
17
  When I ask it whether it is empty: "m.empty?"
18
18
  Then it responds with false
@@ -4,8 +4,7 @@ end
4
4
 
5
5
 
6
6
 
7
-
8
- Then(/^I receive/) do |table|
7
+ Then(/^Mortadella returns/) do |table|
9
8
  table.diff! @result
10
9
  end
11
10
 
@@ -1,3 +1,4 @@
1
1
  require 'bundler/setup'
2
2
  Bundler.setup
3
- require 'mortadella'
3
+ require 'mortadella/horizontal'
4
+ require 'mortadella/vertical'
@@ -0,0 +1,18 @@
1
+ Feature: Creating vertical mock data tables
2
+
3
+ As a Cucumber user
4
+ I want to programmatically create vertical mock data tables from application data
5
+ So that I can use Cucumber's built-in table diffing to verify my application data ergonomically.
6
+
7
+
8
+ Scenario: Creating a simple data table
9
+ Given I create a vertical Mortadella instance: "m = Mortadella::Vertical.new"
10
+ And I add a data row: "m['NAME'] = 'Mortadella'"
11
+ And I add another data row: "m['TYPE'] = 'Ruby Gem'"
12
+ And I add another data row: "m['AUTHOR'] = 'Kevin Goslar'"
13
+ When I request the instance data table "m.table"
14
+ Then Mortadella returns an object that matches this Cucumber table
15
+ | NAME | Mortadella |
16
+ | TYPE | Ruby Gem |
17
+ | AUTHOR | Kevin Goslar |
18
+
@@ -0,0 +1,54 @@
1
+ module Mortadella
2
+
3
+ # Makes it easy to build DRY horizontal Cucumber-compatible tables
4
+ class Horizontal
5
+
6
+ attr_reader :table
7
+
8
+
9
+ def initialize headers:, dry: []
10
+ @headers = headers
11
+
12
+ @dry = dry
13
+
14
+ # The resulting Cucumber-compatible table structure
15
+ @table = [headers]
16
+
17
+ # The previously added row
18
+ @previous_row = nil
19
+ end
20
+
21
+
22
+ # Adds the given row to the table
23
+ def << row
24
+ @table << dry_up(row)
25
+ @previous_row = row
26
+ end
27
+
28
+
29
+ # Returns a dried up version of the given row
30
+ # based on the row that came before in the table
31
+ #
32
+ # In a dried up row, any values that match the previous row are removed,
33
+ # stopping on the first difference
34
+ def dry_up row
35
+ return row unless @previous_row
36
+ result = row.clone
37
+ @previous_row.each_with_index do |previous_value, i|
38
+ if @dry.include?(@headers[i]) && row[i] == previous_value
39
+ result[i] = ''
40
+ else
41
+ break
42
+ end
43
+ end
44
+ result
45
+ end
46
+
47
+
48
+ def empty?
49
+ @table.size == 1
50
+ end
51
+
52
+ end
53
+
54
+ end
@@ -0,0 +1,26 @@
1
+ module Mortadella
2
+
3
+ # Makes it easy to build DRY horizontal Cucumber-compatible tables
4
+ class Vertical
5
+
6
+ attr_reader :table
7
+
8
+
9
+ def initialize
10
+ @table = []
11
+ end
12
+
13
+
14
+ # Adds the given row to the table
15
+ def []= header, row
16
+ @table << [header, row]
17
+ end
18
+
19
+
20
+ def empty?
21
+ @table.size == 1
22
+ end
23
+
24
+ end
25
+
26
+ end
data/mortadella.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'mortadella'
7
- s.version = '0.1.0'
7
+ s.version = '0.2.0'
8
8
  s.authors = ['Kevin Goslar']
9
9
  s.email = ['kevin.goslar@gmail.com']
10
10
  s.summary = %s(Mock Ruby Table Delivery)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mortadella
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.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-06-12 00:00:00.000000000 Z
11
+ date: 2015-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -96,12 +96,14 @@ files:
96
96
  - README.md
97
97
  - Rakefile
98
98
  - circle.yml
99
- - features/basic_usage.feature
100
- - features/drying_up_fields.feature
101
- - features/emptiness.feature
99
+ - features/horizontal_tables/basic_usage.feature
100
+ - features/horizontal_tables/drying_up_fields.feature
101
+ - features/horizontal_tables/emptiness.feature
102
102
  - features/step_definitions/steps.rb
103
103
  - features/support/env.rb
104
- - lib/mortadella.rb
104
+ - features/vertical_tables/basic_usage.feature
105
+ - lib/mortadella/horizontal.rb
106
+ - lib/mortadella/vertical.rb
105
107
  - mortadella.gemspec
106
108
  homepage: https://github.com/Originate/mortadella
107
109
  licenses:
@@ -123,11 +125,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
125
  version: '0'
124
126
  requirements: []
125
127
  rubyforge_project:
126
- rubygems_version: 2.4.5
128
+ rubygems_version: 2.4.5.1
127
129
  signing_key:
128
130
  specification_version: 4
129
131
  summary: Mock Ruby Table Delivery
130
- test_files:
131
- - features/basic_usage.feature
132
- - features/drying_up_fields.feature
133
- - features/emptiness.feature
132
+ test_files: []
@@ -1,19 +0,0 @@
1
- Feature: Creating mock data tables
2
-
3
- As a Cucumber user
4
- I want to programmatically create mock data tables from application data
5
- So that I can use Cucumber's built-in table diffing functionality to verify my application behavior ergonomically.
6
-
7
-
8
- Scenario: Creating a simple data table
9
- Given I create a Mortadella instance: "m = Mortadella.new headers: ['DAY', 'ACTIVITY']"
10
- And I add a data row: "m << ['Monday', 'mowing']"
11
- And I add another data row: "m << ['Tuesday', 'tutoring']"
12
- And I add another data row: "m << ['Wednesday', 'welcoming']"
13
- When I request the instance data table "m.table"
14
- Then I receive an object that matches this Cucumber table
15
- | DAY | ACTIVITY |
16
- | Monday | mowing |
17
- | Tuesday | tutoring |
18
- | Wednesday | welcoming |
19
-
data/lib/mortadella.rb DELETED
@@ -1,48 +0,0 @@
1
- # Makes it easy to build DRY Cucumber-compatible tables
2
- class Mortadella
3
- attr_reader :table
4
-
5
-
6
- def initialize headers:, dry: []
7
- @headers = headers
8
-
9
- @dry = dry
10
-
11
- # The resulting Cucumber-compatible table structure
12
- @table = [headers]
13
-
14
- # The previously added row
15
- @previous_row = nil
16
- end
17
-
18
-
19
- # Adds the given row to the table
20
- def << row
21
- @table << dry_up(row)
22
- @previous_row = row
23
- end
24
-
25
-
26
- # Returns a dried up version of the given row
27
- # based on the row that came before in the table
28
- #
29
- # In a dried up row, any values that match the previous row are removed,
30
- # stopping on the first difference
31
- def dry_up row
32
- return row unless @previous_row
33
- result = row.clone
34
- @previous_row.each_with_index do |previous_value, i|
35
- if @dry.include?(@headers[i]) && row[i] == previous_value
36
- result[i] = ''
37
- else
38
- break
39
- end
40
- end
41
- result
42
- end
43
-
44
-
45
- def empty?
46
- @table.size == 1
47
- end
48
- end