[Ironruby-core] RSpec Test Format

Mohammad Azam lists at ruby-forum.com
Mon Jul 6 22:11:06 EDT 2009


I have done BDD in C# and my question is that how Spec in IronRuby makes
it easier. Here is what my test looks like:

require 'rubygems'
require 'spec'

require File.dirname(__FILE__) + '/bin/Debug/BusinessObjects.dll'

include BusinessObjects

primeService = PrimeService.new

describe PrimeService,"when 1 is passed" do

it "should return true" do

primeService.IsPrime(1).should == true

end

end

describe PrimeService, "when 2 is passed" do

it "should return true" do

primeService.IsPrime(2).should == true

end

end

describe PrimeService, "when a number less then zero is passed" do

it "should throw an error for invalid input exception" do

lambda {primeService.IsPrime(-1)}.should raise_error

end

end

describe PrimeService, "when a prime number is passed" do

it "should return a true value" do

prime_numbers = [3,23,5,7,11,13,19,17,29]

prime_numbers.each{|x| primeService.IsPrime(x).should == true}

end

end


Is this the normal way of writing unit test BDD style using Spec and
IronRuby or am I missing something?
-- 
Posted via http://www.ruby-forum.com/.


More information about the Ironruby-core mailing list