mortadella 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +24 -0
- data/Rakefile +2 -0
- data/features/basic_usage.feature +19 -0
- data/features/drying_up_fields.feature +28 -0
- data/features/step_definitions/steps.rb +9 -0
- data/features/support/env.rb +3 -0
- data/lib/mortadella.rb +45 -0
- data/mortadella.gemspec +24 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f0680e858918ad2037afeda8c7bc6f2093dee7d7
|
4
|
+
data.tar.gz: bd4407c36e775e05e21bf916d89e5b68fc0332d8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ff4ad205a289f8c6f2d223c686e69c3e3adf695b62ac0fbbdad3fb2866e6587b304e272f89dc3137183c533a5c7066821333f6645182b1d9a96a2e5f4133144a
|
7
|
+
data.tar.gz: 8bcc8976387cca926aee3ecfe5f69bc135941c037e504fd64b3d6770784d59116bc359bb8dfaf1ff7d6dcb0295d7e1a9f03b209d4e4aef5846fbd70bba36b618
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.1
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Originate
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Delicious Mock Ruby Tables
|
2
|
+
|
3
|
+
[![Build Status](https://circleci.com/gh/Originate/mortadella/tree/master.svg?style=shield)](https://circleci.com/gh/Originate/mortadella)
|
4
|
+
[![License](http://img.shields.io/:license-MIT-blue.svg?style=flat)](LICENSE.txt)
|
5
|
+
|
6
|
+
Mortadella makes it easy to programmatically build data tables
|
7
|
+
that can be compared to Cucumber tables
|
8
|
+
through `cucumber_table.diff! mortadella_table`.
|
9
|
+
|
10
|
+
You want to do this as much as possible.
|
11
|
+
Cucumber has very powerful built-in facilities
|
12
|
+
to visualize where and how two tables differ.
|
13
|
+
This gives you very readable error messages when your
|
14
|
+
code behaves differently than what Cucumber expects,
|
15
|
+
for free.
|
16
|
+
|
17
|
+
* [basic usage](https://github.com/Originate/mortadella/blob/master/features/basic_usage.feature)
|
18
|
+
* you can also [dry up repetitive fields](https://github.com/Originate/mortadella/blob/master/features/drying_up_fields.feature) for better readability
|
19
|
+
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
* add `gem 'mortadella'` to your `Gemfile`
|
24
|
+
* run `bundle`
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
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 data table from my Mortadella instance "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
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
Feature: Drying up repetitive fields
|
2
|
+
|
3
|
+
As a developer with a lot of repetitive data in my Cucumber tables
|
4
|
+
I want that redundant elements are omitted from my table
|
5
|
+
So that I can see better how data in my table is grouped and where it changes.
|
6
|
+
|
7
|
+
|
8
|
+
Scenario: drying up repetitive columns
|
9
|
+
Given I create a Mortadella instance with a DRY column: "m = Mortadella.new headers: ['DAY', 'ACTIVITY'], dry: ['DAY']"
|
10
|
+
|
11
|
+
And I add an activity for Monday: "m << ['Monday', 'mowing']"
|
12
|
+
And I add another activity for Monday: "m << ['Monday', 'musing']"
|
13
|
+
And I add another activity for Monday: "m << ['Monday', 'mentoring']"
|
14
|
+
|
15
|
+
And I add an activity for Tuesday: "m << ['Tuesday', 'typing']"
|
16
|
+
And I add another activity for Tuesday: "m << ['Tuesday', 'tutoring']"
|
17
|
+
And I add another activity for Tuesday: "m << ['Tuesday', 'throwing']"
|
18
|
+
|
19
|
+
When I request the data table from the Mortadella instance "m.table"
|
20
|
+
Then I receive a table with repeated day names cleared out for better readability
|
21
|
+
| DAY | ACTIVITY |
|
22
|
+
| Monday | mowing |
|
23
|
+
| | musing |
|
24
|
+
| | mentoring |
|
25
|
+
| Tuesday | typing |
|
26
|
+
| | tutoring |
|
27
|
+
| | throwing |
|
28
|
+
|
data/lib/mortadella.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Makes it easy to build DRY Cucumber-compatible tables
|
2
|
+
class Mortadella
|
3
|
+
|
4
|
+
attr_reader :table
|
5
|
+
|
6
|
+
|
7
|
+
def initialize headers:, dry: []
|
8
|
+
@headers = headers
|
9
|
+
|
10
|
+
@dry = dry
|
11
|
+
|
12
|
+
# The resulting Cucumber-compatible table structure
|
13
|
+
@table = [headers]
|
14
|
+
|
15
|
+
# The previously added row
|
16
|
+
@previous_row = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
# Adds the given row to the table
|
21
|
+
def << row
|
22
|
+
@table << dry_up(row)
|
23
|
+
@previous_row = row
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
# Returns a dried up version of the given row
|
28
|
+
# based on the row that came before in the table
|
29
|
+
#
|
30
|
+
# In a dried up row, any values that match the previous row are removed,
|
31
|
+
# stopping on the first difference
|
32
|
+
def dry_up row
|
33
|
+
return row unless @previous_row
|
34
|
+
result = row.clone
|
35
|
+
@previous_row.each_with_index do |previous_value, i|
|
36
|
+
if @dry.include?(@headers[i]) && row[i] == previous_value
|
37
|
+
result[i] = ''
|
38
|
+
else
|
39
|
+
break
|
40
|
+
end
|
41
|
+
end
|
42
|
+
result
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
data/mortadella.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "mortadella"
|
7
|
+
spec.version = "0.0.1"
|
8
|
+
spec.authors = ["Kevin Goslar"]
|
9
|
+
spec.email = ["kevin.goslar@gmail.com"]
|
10
|
+
spec.summary = %q{Mock Ruby Table Delivery}
|
11
|
+
spec.description = %q{A tool to create Ruby table object to be used for Cucumber comparisons}
|
12
|
+
spec.homepage = "https://github.com/Originate/mortadella"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", '~> 0'
|
21
|
+
spec.add_development_dependency "rake", '~> 0'
|
22
|
+
spec.add_development_dependency "cucumber", '~> 0'
|
23
|
+
spec.add_development_dependency "rspec", '~> 0'
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mortadella
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kevin Goslar
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: cucumber
|
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'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: A tool to create Ruby table object to be used for Cucumber comparisons
|
70
|
+
email:
|
71
|
+
- kevin.goslar@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".ruby-version"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- features/basic_usage.feature
|
83
|
+
- features/drying_up_fields.feature
|
84
|
+
- features/step_definitions/steps.rb
|
85
|
+
- features/support/env.rb
|
86
|
+
- lib/mortadella.rb
|
87
|
+
- mortadella.gemspec
|
88
|
+
homepage: https://github.com/Originate/mortadella
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.4.5
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Mock Ruby Table Delivery
|
112
|
+
test_files:
|
113
|
+
- features/basic_usage.feature
|
114
|
+
- features/drying_up_fields.feature
|
115
|
+
- features/step_definitions/steps.rb
|
116
|
+
- features/support/env.rb
|