I’m a big fan of what Cucumber has to offer a .NET developer like myself. What gets me down is the problem that IronRuby never seems *quite* mature enough to run it.
I’ve encountered (what i believe to be) a bug in IronRuby 0.9.0.0. The following feature (with no .NET interop) works using the Ruby interpreter, but fails under IronRuby.
The specification to reproduce the bug is based on a simple calculator performing an addition task. IronRuby barfs with the following error:
In order to save time
as a math n00b
I want to be able to add 2 numbers
wrong number of arguments (1 for 0) (ArgumentError)
Hopefully the problem turns out to be something weird in my environment, but I’m reproducing the code below in case someone else would like to try it:
(i’ve also pushed it to Github: Ruby Calculator)
Feature: Addition In order to save time as a math n00b I want to be able to add 2 numbers Scenario: Addition Given I have entered the first number 2 into the calculator And I have entered the second number 3 into the calculator When I call the add method Then the result 5 should be returned Scenario Outline: More Addition Given I have entered the first number
into the calculator And I have entered the second number into the calculator When I call the method Then the result should be returned Examples: | x | y | method | result | | 2 | 3 | add | 5 | | 1 | 1 | add | 2 | | 0 | 0 | add | 0 | | -2 | 3 | add | 1 |
require "spec" require "lib/calculator" Before do @calc = Calculator.new end Given /^I have entered the first number (-?d+) into the calculator$/ do |n| @x = n.to_i end Given /^I have entered the second number (-?d+) into the calculator$/ do |n| @y = n.to_i end When /^I call the add method$/ do @result = @calc.add(@x, @y) end Then /^the result (d+) should be returned$/ do |n| @result.should equal(n.to_i) end
class Calculator def add(x, y) return x+y end end