Formatting the test result in Spec

I got the Spec working in IronRuby! Thanks everyone.

How can I get a detailed report (command line) when running the test?

Currently, I only get the following:

C:\Projects\FirstLookAtIronRuby\FirstLookAtIronRuby\TestSuite>ir
test_prime.rb
Loaded suite test_prime
Started

Finished in 0.015625 seconds.

0 tests, 0 assertions, 0 failures, 0 errors

Also, for some reason it says “0 tests” here is my test_prime.rb file:

require ‘test/unit’
require ‘rubygems’
require ‘spec’

require File.dirname(FILE) + ‘/bin/Debug/BusinessObjects.dll’

include BusinessObjects
include Test::Unit

describe PrimeService,“when 1 is passed to the prime service” do

it “should return true” do

primeService = PrimeService.new
primeService.IsPrime(1)

end

end

I changed the code to this but still not picking up the test:

describe PrimeService,“when 1 is passed to the prime service” do

it “should return true” do

primeService = PrimeService.new
primeService.IsPrime(1).should == true

end

Mohammad A. wrote:

I got the Spec working in IronRuby! Thanks everyone.

How can I get a detailed report (command line) when running the test?

Currently, I only get the following:

C:\Projects\FirstLookAtIronRuby\FirstLookAtIronRuby\TestSuite>ir
test_prime.rb
Loaded suite test_prime
Started

Finished in 0.015625 seconds.

0 tests, 0 assertions, 0 failures, 0 errors

Also, for some reason it says “0 tests” here is my test_prime.rb file:

require ‘test/unit’
require ‘rubygems’
require ‘spec’

require File.dirname(FILE) + ‘/bin/Debug/BusinessObjects.dll’

include BusinessObjects
include Test::Unit

describe PrimeService,“when 1 is passed to the prime service” do

it “should return true” do

primeService = PrimeService.new
primeService.IsPrime(1)

end

end

I had to configure the path for spec.bat using environment variables.

Now, I can run the specifications using the following:

spec test_prime.rb

but I still need to format is nicely. --format nested does not work it
complains that invalid --format parameter!

You are right!

require test/unit was the problem. I removed it and it worked smoothly!

Thanks,
Azam

Mohammad A. wrote:

I had to configure the path for spec.bat using environment variables.

Now, I can run the specifications using the following:

spec test_prime.rb

but I still need to format is nicely. --format nested does not work it
complains that invalid --format parameter!

Have you removed the test/unit require so that the test/unit runner data
isn’t coming back? I think that was a red herring earlier in your post.

Here’s the command I ran (full path to make sure I was running the right
spec.bat):

C:\OSS\ironruby\Merlin\Main\Bin\debug\spec.bat test.rb --format specdoc

I got back the following output (from a script similar to yours):

Some Simple assert

  • should show that 1 is equal to 1

Finished in 0.2343855 seconds

1 example, 0 failures

One other thing I noticed is that I have already installed win32console
gem on my machine but for some reason whenever I use the color option it
gives me the following output:

C:\Projects\FirstLookAtIronRuby\FirstLookAtIronRuby\TestSuite>spec
test_prime.rb
–format specdoc --colour
You must ‘gem install win32console’ to use colour on Windows

BusinessObjects::PrimeService when foo method is called

  • should return true

Finished in 0.265625 seconds

1 example, 0 failures

Thanks,
Azam