Giter Site home page Giter Site logo

cucumber-lua's Introduction

Cucumber-Lua

Build Status

A wire protocol server for cucumber-ruby that executes steps defined in Lua

Installation

  1. Install Lua 5.2

  2. Install cucumber-lua using luarocks:

luarocks build https://raw.github.com/cucumber/cucumber-lua/master/cucumber-lua-0.0-2.rockspec
  1. Install Ruby, cucumber-ruby and the wire protocol gem.

Create a Gemfile

source 'https://rubygems.org'

gem "cucumber"
gem "cucumber-wire"

Then ask Bundler to install the gems:

bundle install

Add a file to load the wire protocol plugin:

echo "require 'cucumber/wire'" > features/support/wire.rb
  1. Add a .wire file telling cucumber that Lua is listening:
/features/step_definitions/cucumber-lua.wire
host: 0.0.0.0
port: 9666

Usage

Run the cucumber-lua server:

cucumber-lua

Then run cucumber in another terminal:

bundle exec cucumber

Lua Step Definitions

cucumber-lua expects you to define a single file for step definitions (features/step_definitions/steps.lua). If you need anything more than a single file, use lua modules and require them from your main steps file (that means we don't need luafilesystem).

Create your step definitions using the following global keywords:

  • Before(fn) - called before each scenario
  • After(fn) - called after each scenario
  • Given(step, fn) - define a step where a pre-condition/state is declared
  • When(step, fn) - define a step where user action or behaviour is performed
  • Then(step, fn) - define a step where the outcome is observed
  • Pending(message) - indicate a step as pending implementation

Note: If a Before or After function fails the whole scenario is reported as failed.

/features/step_definitions/steps.lua
Calculator = require("calculator")

Before(function()
    Calculator:Reset()
end)

After(function()
    print("I am called after each scenario")
end)

Given("I have entered (%d+) into the calculator", function (number)
    Calculator:Enter(number)
end)

When("I press add", function ()
    Calculator:Add()
end)

Then("the result should be (%d+) on the screen", function (number)
    assert(Calculator.result == tonumber(number),
           "Expected " .. number .. ", was " .. Calculator.result)
end)

Then("Something not yet implemented", function ()
    Pending("It's not ready yet")
end)

Running the Cucumber-Lua specs

lua spec/runner.lua

cucumber-lua's People

Contributors

britzl avatar dependabot[bot] avatar joshski avatar mattwynne avatar mend-for-github-com[bot] avatar mpkorstanje avatar mxygem avatar renovate[bot] avatar xtrasimplicity avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cucumber-lua's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

bundler
Gemfile
  • cucumber undefined
  • aruba undefined

  • Check this box to trigger a request for Renovate to run again on this repository

Lack of CI-based testing

Hi all,

I've just noticed that there isn't any continuous integration testing for this repository.

It would be great to have something like this, so that we can ensure that all tests pass prior to merging PRs.

I'm happy to take a look at getting the foundations of this going, though I admit I haven't used lua in close to 15 years. @olleolleolle or @mvz, would either of you be able to enable this repo in the Cucumber Travis CI or Circle CI account, if it hasn't already been done so?

Thanks!

cucumber-lua doesn't work with current ruby/cucumber

Steps to reproduce:

GIVEN

Install Ruby (for cucumber)
https://rubyinstaller.org/downloads/ (allow putting ruby in your PATH)
Install Ruby gems (distribution/source package for ruby, similar to Pip for python, and LuaRocks for Lua)
https://rubygems.org/pages/download
as it says, DL the file, unzip it (ie: C:\rubygems-2.7.1)
in command line, run
> ruby setup.rb
add the binary to PATH
> ;C:\rubygems-2.7.1\bin
Install Cucumber
> gem install cucumber

(optional) Install MinGW (or a favourite compiler), and add it to PATH
> ;C:\MinGW\bin

Install Lua version 5.2 source code (yes. this is a bitch.)
https://stackoverflow.com/questions/16641826/how-do-i-build-lua-for-windows-using-mingw-and-msys
https://www.lua.org/ftp/ -> unzip to anywhere (it has a containing folder)
cd in to the containing folder, or move the contents of the containing folder to, ie: C:\lua
from command line, run
> mingw32-make PLAT=mingw
in that folder. Lua binaries should be somewhere inside src now.

Create a LUA_HOME Environment variable, for where you installed it, for easy reference later
 > LUA_HOME = C:\lua\src
Add the src folder to PATH (LUA_HOME must be visible, so you can't add this to system vars,
    if home is a user var)
 > ;%LUA_HOME%

Install LuaRocks (this is also not the most fun)
Download Luarocks binary https://luarocks.github.io/luarocks/releases/ (latest win32.zip)
Open command window -> navigate to unzipped folder, and run command:

 > install /MW
 
 or, if you have a microsoft c++ compiler installer with "cl" in the path, and don't want to use ming,
 
 > install

Add the luarocks to PATH
 > ;C:\Program Files (x86)\LuaRocks
Add where rocks (busted,cucumber) put their binaries to PATH as well
 > ;%LUA_HOME%/systree/bin
 Add lua rocks path to LUA_PATH environment variable
 > ;%LUA_HOME%/systree/share/lua/5.2/?.lua
Add lua dlls folder to LUA_CPATH
 > ;%LUA_HOME%/systree/lib/lua/5.2/?.dll

Install Lua Cucumber with luarocks https://github.com/cucumber/cucumber-lua

luarocks build https://raw.github.com/cucumber/cucumber-lua/master/cucumber-lua-0.0-2.rockspec

Download Calculator example from https://github.com/cucumber/cucumber-lua/tree/master/examples/calculator

WHEN

Run

cucumber-lua

In another console run

cucumber

THEN

Result:

undefined method `[]' for nil:NilClass (NoMethodError)
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.0.0/lib/cucumber/core/ast/location.rb:16:in `from_file_colon_line'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-wire-0.0.1/lib/cucumber/wire/step_definition.rb:12:in `initialize'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-wire-0.0.1/lib/cucumber/wire/protocol/requests.rb:28:in `new'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-wire-0.0.1/lib/cucumber/wire/protocol/requests.rb:28:in `create_step_match'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-wire-0.0.1/lib/cucumber/wire/protocol/requests.rb:19:in `block in handle_success'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-wire-0.0.1/lib/cucumber/wire/protocol/requests.rb:18:in `map'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-wire-0.0.1/lib/cucumber/wire/protocol/requests.rb:18:in `handle_success'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-wire-0.0.1/lib/cucumber/wire/data_packet.rb:30:in `handle_with'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-wire-0.0.1/lib/cucumber/wire/connection.rb:23:in `call_remote'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-wire-0.0.1/lib/cucumber/wire/request_handler.rb:10:in `execute'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-wire-0.0.1/lib/cucumber/wire/protocol/requests.rb:14:in `execute'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-wire-0.0.1/lib/cucumber/wire/protocol.rb:8:in `step_matches'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-wire-0.0.1/lib/cucumber/wire/connections.rb:33:in `block in step_matches'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-wire-0.0.1/lib/cucumber/wire/connections.rb:33:in `map'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-wire-0.0.1/lib/cucumber/wire/connections.rb:33:in `step_matches'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.0.1/lib/cucumber/step_match_search.rb:19:in `call'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.0.1/lib/cucumber/step_match_search.rb:19:in `call'
C:/Ruby24-x64/lib/ruby/2.4.0/delegate.rb:83:in `method_missing'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.0.1/lib/cucumber/step_match_search.rb:62:in `call'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.0.1/lib/cucumber/filters/activate_steps.rb:66:in `matches'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.0.1/lib/cucumber/filters/activate_steps.rb:47:in `result'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.0.1/lib/cucumber/filters/activate_steps.rb:37:in `find_match'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.0.1/lib/cucumber/filters/activate_steps.rb:33:in `attempt_to_activate'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.0.1/lib/cucumber/filters/activate_steps.rb:29:in `map'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.0.1/lib/cucumber/filters/activate_steps.rb:29:in `new_test_steps'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.0.1/lib/cucumber/filters/activate_steps.rb:23:in `test_case'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.0.1/lib/cucumber/filters/activate_steps.rb:12:in `test_case'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.0.0/lib/cucumber/core/test/case.rb:25:in `describe_to'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.0.1/lib/cucumber/filters/activate_steps.rb:12:in `test_case'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.0.0/lib/cucumber/core/test/case.rb:25:in `describe_to'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.0.0/lib/cucumber/core/test/filters/locations_filter.rb:18:in `block in done'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.0.0/lib/cucumber/core/test/filters/locations_filter.rb:17:in `each'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.0.0/lib/cucumber/core/test/filters/locations_filter.rb:17:in `done'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.0.0/lib/cucumber/core/filter.rb:62:in `done'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.0.0/lib/cucumber/core/test/filters/tag_filter.rb:18:in `done'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.0.0/lib/cucumber/core/compiler.rb:24:in `done'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.0.0/lib/cucumber/core/gherkin/parser.rb:37:in `done'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.0.0/lib/cucumber/core.rb:32:in `parse'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-core-3.0.0/lib/cucumber/core.rb:21:in `compile'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.0.1/lib/cucumber/runtime.rb:74:in `run!'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.0.1/lib/cucumber/cli/main.rb:33:in `execute!'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/cucumber-3.0.1/bin/cucumber:9:in `<top (required)>'
C:/Ruby24-x64/bin/cucumber:23:in `load'
C:/Ruby24-x64/bin/cucumber:23:in `<main>'

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.