GitXplorerGitXplorer
k

kappamaki

public
3 stars
0 forks
2 issues

Commits

List of commits on branch master.
Verified
1de5725249d7e773eb72b60d47bc7444398bbeee

Cleanup (#3)

kkevgo committed 4 years ago
Unverified
967e3550b5ff258b5d1f0c69beb919321dc5b053

Logo

committed 8 years ago
Unverified
0c3431eb828e8dc737acb7c0eef2745827134654

Add rake as a dependency

committed 9 years ago
Unverified
f087d6e2bead0df038fe772e191d559467aa5ffc

Documentation update

committed 9 years ago
Unverified
ee2bb57c6b9094157076b56e9eecf1ce968a0dfd

Run linter on Travis

committed 9 years ago
Unverified
4b94633f413b778466fddc6d7e6c05d718cf243d

Dependencies badge

kkevgo committed 9 years ago

README

The README file for this repository.

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