Skip to content

maiha/crb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"
  => #<Cucumber::Undefined: 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
  => #<Calculator:0x7faa0a3e5218 @args=[3, 5]>

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
  => #<Calculator:0x7ff45ecdbc70 @args=[3]>


Custom
======

  % mkdir my-project
  % crb my-project
  irb(CRB:0):001:0> Given "ab"
  Undefined step: "ab"
  => #<Cucumber::Undefined: 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
======

  maiha@wota.jp

About

A cucumber console that offers cucumber world enviroment on irb

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages