Project

mortadella

0.0
No commit activity in last 3 years
No release in over 3 years
A tool to create Ruby table object to be used for Cucumber comparisons
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Mortadella for Ruby

Build Status Coverage Status Code Climate

Mortadella for Ruby makes it easy to programmatically build data tables that can be compared to Cucumber for Ruby tables through cucumber_table.diff! mortadella_table.

You want to do this as much as possible. Cucumber for Ruby has very powerful built-in facilities to visualize where and how two tables differ:

Oh no, our algorithm selected too many apples!

Installation

  • add gem 'mortadella' to your Gemfile
  • run bundle install

Usage

Mortadella supports horizontal and vertical Cucumber tables.

Horizontal Tables

  • In your cucumber spec, define the expected data in table form

    Then I have these ingredients
      | INGREDIENT | AMOUNT |
      | flour      | 12 oz  |
      | butter     | 2 oz   |
      | apples     | 3 pc   |
  • in the step definition for this, build an equivalent Mortadella table with the actual data, and diff the Cucumber table with the expected data against it.

    Then /^I have these ingredients$/ do |expected_ingredients|
      actual_ingredients = Mortadella::Horizontal.new headers: ['INGREDIENT', 'AMOUNT']
      actual_ingredients << ['flour', '12 oz']   # This data should come from your app
      actual_ingredients << ['butter', '2 oz']   # This data should come from your app
      actual_ingredients << ['apples', '3 pc']   # This data should come from your app
      expected_ingredients.diff! actual_ingredients.table
    end
  • you can also dry up repetitive fields for better readability

  • or filter the columns of your finished table by calling keep_matching_colums

Vertical Tables

  • In your cucumber spec, define the expected data in table form

    Then my pie conforms to these specs:
      | WEIGHT   | 2 lbs |
      | PORTIONS | 8     |
      | CALORIES | 500   |
  • in the step definition for this, build an equivalent Mortadella table with the actual data, and diff the Cucumber table with the expected data against it.

    Then /^My pie has these metrics:$/ do |expected_metrics|
      actual_metrics = Mortadella::Vertical.new
      actual_metrics['WEIGHT'] = '2 lbs'   # This data should come from your app
      actual_metrics['PORTIONS'] = 8       # This data should come from your app
      actual_metrics['CALORIES'] = 500     # This data should come from your app
      expected_metrics.diff! actual_metrics.table
    end

Development

  • set up local environment: bundle install
  • run all tests: make test
    • run linter only: make lint
    • run tests only: make features
  • publish a new gem: