Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/maiha/crb

A cucumber console that offers cucumber world enviroment on irb
https://github.com/maiha/crb

Last synced: 2 months ago
JSON representation

A cucumber console that offers cucumber world enviroment on irb

Awesome Lists containing this project

README

        

crb
===

An irb console for cucumber world

Features
========

* Can define steps interactively
* Can execute steps interactively like debugger
* Can share cuke world and irb context in a same object
* Can see instance variables of step files via irb
* Supported hooks (but only before/after without parameters)
* Supported World methods

Usage
=====

Use 'crb' command as same as 'cucumber' command
% crb (... cucumber options ...)

And then you are in cucumber world via irb

Example
=======

% cd examples/i18n/en
% crb
irb(CRB:3):001:0>
^^^ This means a number of defined steps.

irb(CRB:3):001:0> Given "I have entered 3"
Undefined step: "I have entered 3"
=> #

irb(CRB:3):002:0> Given "I have entered 3 into the calculator"
=> [3]

irb(CRB:3):003:0> Given "I have entered 5 into the calculator"
=> [3, 5]

irb(CRB:3):004:0> Then "I press add"
=> 8

irb(CRB:3):005:0> @calc
=> #

You can operate your variables directly .

irb(CRB:3):006:0> @calc.push 1
=> [3, 5, 1]

irb(CRB:3):007:0> Then "I press add"
=> 9

I18N
====

I18N keywords are also available.

% cd examples/i18n/ja
% crb
irb(CRB:3):001:0> 前提 "3 を入力"
=> [3]
irb(CRB:3):002:0> @calc
=> #

Custom
======

% mkdir my-project
% crb my-project
irb(CRB:0):001:0> Given "ab"
Undefined step: "ab"
=> #
irb(CRB:0):002:0> Given(/^(..)$/){|i| p "Two chars for you! #{i}"}
=> "/^(..)$/ is defined"
irb(CRB:1):003:0> Given "ab"
"Two chars for you! ab"

World Methods
=============

Above crb(irb) context is a same object with cuke's world.
And there are following additional methods.

* before : execute before hooks. returns message (String)
* after : execute after hooks. returns message (String)
* steps : returns step definitions (Array[RbStepDefinition])
* support: returns support code object (Runtime::SupportCode)
* hooks : returns hooks (Hash[type=>Array[RbHook]])
* rb : returns ruby language support object (RbLanguage)

Restricted
==========

* Hooks are not called automatically because crb is free from
scenarios. Otherwise if hooks are called in each invokes,
we'll never succeed to "add" operation in above calculator.

* "before", "after" methods are the manual triggers for hooks.
And "Ctl-C" is binded as "before" filter too.

* To implement CRB, there are many ugly codes that closely
depend on cuke's internal structures like private methods
and instance vars. So it'll break soon after cuke's update.

Environment
===========

Tested on ruby-1.8.7, cucumber-1.0.0

Author
======

[email protected]