Project

kappamaki

0.0
No commit activity in last 3 years
No release in over 3 years
Kappamaki is a collection of string manipulation methods that make parsing high-lever cucumber steps easier.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Code Climate Coverage Status Dependency Status

The name comes from the sushi roll filled with pieces of cucumber, which adds naturalness and freshness to a meal.

Usage

Kappamaki provides a number of helper methods that can be used directly in your Cucumber step definitions.

from_sentence

Parses a list of values from a sentence.

Given the restaurant offers cucumber rolls, philadelphia rolls, and avocado rolls

Your step definition would look like this:

Given /^the restaurant offers (.+)$/ do |menu_list|

  # menu_list is this string:
  'cucumber rolls, philadelphia rolls, and avocado rolls'

  # Let's parse this into an array
  menu = Kappamaki.from_sentence menu_list

  # The result, menu, is this array:
  ['cucumber rolls', 'philadelphia rolls', 'avocado rolls']

  # Now we can set up our menu here...
end

attributes_from_sentence

Parses key-value pairs from natural sentences.

When I order a dinner with starter: "miso soup" and entree: "cucumber rolls"

Your step definition would look like this:

When /^I order a dinner with (.+)$/ do |order_items|

  # order_items is this string:
  'starter: "miso soup" and entree: "cucumber rolls"'

  # Let's parse that string using Kappamaki
  order_data = Kappamaki.attributes_from_sentence order_items

  # The result, order_data, is this hash:
  { starter: 'miso soup',
    entree: 'cucumber rolls' }

  # now we can set up our order...
  create :order, order_data
end

symbolize_keys_deep

Converts the keys of a hash into symbols.

Then I am served these items
  | name          | count |
  | miso soup     | 1     |
  | cucumber roll | 8     |

Your step definition would look like this:

Then ^I am served these items do |entrees|
  entrees.hashes.each do |entree|

    # entree is this hash:
    { 'name' => 'miso soup', 'count' => '1' }

    # Let's convert the keys to symbols.
    Kappamaki.symbolize_keys_deep! entree

    # Now entree is this hash:
    { name: 'miso soup', count: '1' }

    # Now we can use this hash in places that expect hashes with symbols
    expect(order).to include entree
  end
end

Installation

  • add gem 'kappamaki' to your application's Gemfile
  • run bundle install
  • add require 'kappamaki' to your /features/support/env.rb file

Development

  • run tests: bundle exec rake
  • update dependencies: bundle update
  • push a new version to Rubygems: rake release