Actually I also thought of that and I did separated them in multiple
scenarios. Now, I am having trouble writing the step.
Here is the feature file:


Feature: Prime Service

As a crazy person I need to know whether a number is prime or not

Scenario Outline: Find if the number if prime or not
Given I have a number
When I pass the <number> to the prime service
Then the service should display <result> indicating whether input is prime
or not

Examples:

| number| result|
|  1  | false |
|  2  | true |
|  3  | true |
|  4  | false |

Scenario Outline: Throw exception if the number is negative
Given I have a negative number
When I pass the <number> to the prime service
Then the service should return false

Examples:

| number|
|  -1  |
|  -2  |
|  -3  |
|  -4  |


And here are the steps:

require 'rubygems'
require 'spec/expectations'

require File.expand_path("bin/Debug/BusinessObjects.dll")

include BusinessObjects

Before do

@primeService = PrimeService.new

end

Given /I have a number/ do

end

When "I pass the $number to the prime service" do |number|

@result = @primeService.IsPrime(number.to_i)

end

Then /the service should display (.*) indicating whether input is prime or
not/ do |result|

@result.to_s.should == result

end

Given /I have a negative number/ do

end

When "I pass the $number to the prime service" do |number|

@result = @primeService.IsPrime(number.to_i)

end

Then /the service should return (.*)/ do |result|

@result.to_s.should == result

end


Also, not sure how to check for exception right now!





On Thu, Sep 24, 2009 at 1:10 PM, Jim Deville <jdevi...@microsoft.com> wrote:

> You should probably split that into 2 scenarios. One for finding prime or
> not, and one for throwing if the number is negative.
>
>
>
> There might be an else construct, but I would argue that if you need an
> else/but, then you have 2 behaviors in a single scenario.
>
>
>
> JD
>
>
>
> *From:* ironruby-core-boun...@rubyforge.org [mailto:
> ironruby-core-boun...@rubyforge.org] *On Behalf Of *Mohammad Azam
> *Sent:* Thursday, September 24, 2009 1:07 PM
> *To:* ironruby-core@rubyforge.org
> *Subject:* [Ironruby-core] Is there a But keyword in Cucumber?
>
>
>
> I am using Cucumber and now I need to use a But keyword (if there is any)
>
>
>
> Scenario Outline: Find if the number if prime or not
>
> Given I have a number
>
> When I pass the <number> to the prime service
>
> Then the service should display <result> indicating whether input is prime
> or not
>
> But if the number is negative
>
> Then the prime service should throw an exception
>
>
>
> But it shows up as "Then" and not "But". Is there anything related to "But"
> in Cucumber.
>
>
>
>
> --
> Mohammad Azam
> MVP (Microsoft Valuable Professional)
> www.highoncoding.com
> www.azamsharp.com
>
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core@rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>
>


-- 
Mohammad Azam
MVP (Microsoft Valuable Professional)
www.highoncoding.com
www.azamsharp.com
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

Reply via email to