Giter Club home page Giter Club logo

lime's Introduction

Lime

Website / Source Code / Report Issue / Mailing List

Description

Lime is pure-Ruby Gherkin-style test framework.

Instruction

Lime lets you write features scripts using Ruby, yet still do so with a close approximation to Gherkin domain language.

Feature "Addition" do
  To "avoid silly mistakes"
  As "a math idiot"
  We "need to calculate the sum of numbers"

  Scenario "Add two numbers" do
    Given "I have a calculator"
    Given "I have entered 50 into the calculator"
    Given "I have entered 70 into the calculator"
    When  "I press add"
    Then  "the result should be 120 on the screen"
  end

  Scenario "Add three numbers" do
    Given "I have a calculator"
    Given "I have entered 50 into the calculator"
    Given "I have entered 70 into the calculator"
    Given "I have entered 90 into the calculator"
    When  "I press add"
    Then  "the result should be 2101 on the screen"
  end

  Given 'I have a calculator' do
    require 'calculator'
    @calculator = Calculator.new
  end

  Given 'I have entered (((\d+))) into the calculator' do |n|
    @calculator.push n.to_i
  end

  When 'I press add' do
    @result = @calculator.add
  end

  Then 'the result should be (((\d+))) on the screen' do |n|
    @result.assert == n.to_i
  end
end

The last set of Given and When procedures are called the advice definitions. These can be placed in their own modules and included into the Feature scope like any other module. They simply need to include the Lime::Featurette module to do so. For instance:

module CalculatorAdvice
  include Lime::Featurette

  Given 'I have a calculator' do
    require 'calculator'
    @calculator = Calculator.new
  end

  Given 'I have entered (((\d+))) into the calculator' do |n|
    @calculator.push n.to_i
  end

  When 'I press add' do
    @result = @calculator.add
  end

  Then 'the result should be (((\d+))) on the screen' do |n|
    @result.assert == n.to_i
  end
end

If you add such scripts to a subdirectory called featurettes relative to the feature that uses them, then they will be loaded automatically when features are run.

Speaking of which, to run features use the rubytest command line tool.

$ rubytest -Ilib spec/feature_addition.rb

See RubyTest to learn more.

Copyrights

Copyright (c) 2011 Rubyworks

Lime is distributed according to the terms of the FreeBSD license.

See LICENSE.txt for details.

lime's People

Contributors

trans avatar

Watchers

 avatar James Cloos avatar  avatar

lime's Issues

Modular Step Definitions

Step definition needs to be able to be defined in modules and included into features.

Step definitions aren't defined a methods, so we can't utilize Ruby's include in the normal fashion. We will probably have to create a traits like system.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.