Also, I like to mention that for some reason I had to provide the --guess parameter for cucumber to work. icucumber features/some_step.rb --guess
If I don't use the guess parameter then it was picking the values from the previous defined examples. On Thu, Sep 24, 2009 at 2:34 PM, Mohammad Azam <azamsh...@gmail.com> wrote: > In a week or two I will be writing detailed articles discussing Cucumber > with IronRuby. I will also record several screencasts and a podcast session > which will all be hosted on http://www.highoncoding.com. > Thanks, > Azam > > > On Thu, Sep 24, 2009 at 2:31 PM, Jim Deville <jdevi...@microsoft.com>wrote: > >> No prob. I know of at least one Ruby company that is using it, I don’t >> know about any IronRuby users, but I hope there are some J >> >> >> >> JD >> >> >> >> *From:* ironruby-core-boun...@rubyforge.org [mailto: >> ironruby-core-boun...@rubyforge.org] *On Behalf Of *Mohammad Azam >> *Sent:* Thursday, September 24, 2009 2:27 PM >> >> *To:* ironruby-core@rubyforge.org >> *Subject:* Re: [Ironruby-core] Is there a But keyword in Cucumber? >> >> >> >> Thanks JD!! >> >> >> >> It never occurred to me that I can store the number in a @n_number >> variable and use it later. Here is the version that is working perfectly: >> >> >> >> I will be interested to know if people are actually using Cucumber in >> their companies to write acceptance tests. >> >> >> >> Given /I have a negative number/ do >> >> >> >> end >> >> >> >> When "I pass the negative $n_number to the prime service" do |n_number| >> >> >> >> @n_number = n_number.to_i >> >> >> >> end >> >> >> >> Then /the service should throw exception/ do >> >> >> >> lambda >> {...@primeservice.isprime(@n_number)}.should<%...@primeservice.isprime(@n_number)%7d.should>raise_error >> >> >> >> end >> >> >> >> On Thu, Sep 24, 2009 at 2:08 PM, Jim Deville <jdevi...@microsoft.com> >> wrote: >> >> You are missing the lambda keyword. I would also just store the number at >> that point, and perform the operation in the Then step. >> >> >> >> When "I pass the negative $n_number to the prime service" do |n_number| >> >> @n_number = n_number >> >> end >> >> >> >> Then /the service should throw exception/ do >> >> lambda >> {...@primeservice.isprime(@n_number.to_i)}.should<%...@primeservice.isprime(@n_number.to_i)%7d.should>raise_error >> >> end >> >> >> >> JD >> >> >> >> *From:* ironruby-core-boun...@rubyforge.org [mailto: >> ironruby-core-boun...@rubyforge.org] *On Behalf Of *Mohammad Azam >> *Sent:* Thursday, September 24, 2009 1:58 PM >> >> >> *To:* ironruby-core@rubyforge.org >> *Subject:* Re: [Ironruby-core] Is there a But keyword in Cucumber? >> >> >> >> I am having trouble in where to throw the exception. The exception will be >> thrown in "When" and not "Then" as shown below: >> >> >> >> Scenario Outline: Throw exception if the number is negative >> >> Given I have a negative number >> >> When I pass the negative <n_number> to the prime service >> >> Then the service should throw exception >> >> >> >> *Steps: * >> >> >> >> >> >> Given /I have a negative number/ do >> >> >> >> end >> >> >> >> When "I pass the negative $n_number to the prime service" do |n_number| >> >> >> >> lambda >> {...@primeservice.isprime(n_number.to_i)}.should<%...@primeservice.isprime(n_number.to_i)%7d.should>raise_error >> >> >> >> end >> >> >> >> Then /the service should throw exception/ do >> >> >> >> >> >> end >> >> >> >> *The above throws the following exception: * >> >> >> >> * * >> >> *C:\Projects\ILoveIronRuby\ILoveIronRuby\testing>icucumber >> features/primeservice.* >> >> *feature --guess --no-color* >> >> *odd number list for Hash (SyntaxError)* >> >> * >> C:\DevTools\IronRuby\ironruby\Merlin\Main\Languages\Ruby\Libraries.LCA_RESTRICTE >> * >> >> *D\Builtins\KernelOps.cs:1341:in `require'* >> >> * >> c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.101/bin/../lib/cucumber/rb_support/r >> * >> >> *b_language.rb:101:in `load_code_file'* >> >> *custom_require.rb:30:in `require'* >> >> * >> c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.101/bin/../lib/cucumber/rb_support/r >> * >> >> *b_language.rb:46:in `step_definitions_for'* >> >> *polyglot.rb:69:in `require'* >> >> * >> c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.101/bin/../lib/cucumber/step_mother. >> * >> >> *rb:118:in `load_code_file'* >> >> * >> c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.101/bin/../lib/cucumber/step_mother. >> * >> >> *rb:110:in `load_code_files'* >> >> * >> c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.101/bin/../lib/cucumber/step_mother. >> * >> >> *rb:109:in `load_code_files'* >> >> * >> c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.101/bin/../lib/cucumber/cli/main.rb: >> * >> >> *48:in `execute!'* >> >> * >> c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.101/bin/../lib/cucumber/cli/main.rb: >> * >> >> *23:in `execute'* >> >> * >> C:\DevTools\IronRuby\ironruby\Merlin\Main\Languages\Ruby\Libraries.LCA_RESTRICTE >> * >> >> *D\Extensions\IListOps.cs:810:in `each'* >> >> *c:/ruby/lib/ruby/gems/1.8/gems/cucumber-0.3.101/bin/cucumber:9* >> >> *c:/ruby/bin/cucumber:19* >> >> * >> C:\DevTools\IronRuby\ironruby\Merlin\Main\Languages\Ruby\Libraries.LCA_RESTRICTE >> * >> >> *D\Builtins\KernelOps.cs:1326:in `load'* >> >> * * >> >> *C:\Projects\ILoveIronRuby\ILoveIronRuby\testing>* >> >> >> >> >> >> >> >> >> >> >> >> On Thu, Sep 24, 2009 at 1:37 PM, Jim Deville <jdevi...@microsoft.com> >> wrote: >> >> To check for an exception: you need to get it into the form lambda { expr >> }.should raise_error ErrorType where expr is your test expression, and >> ErrorType is the type of the error you expect. In this case, you might >> need to have the second feature read “When I pass the negative number >> <number> to the prime service” so that you can parse it differently and just >> store the number, then in the Then step for that negative number, you can do >> lambda { @primeService.IsPrime(number.to_i) }.should raise_error Exception >> >> >> >> Does that help? >> >> JD >> >> >> >> *From:* ironruby-core-boun...@rubyforge.org [mailto: >> ironruby-core-boun...@rubyforge.org] *On Behalf Of *Mohammad Azam >> *Sent:* Thursday, September 24, 2009 1:30 PM >> >> >> *To:* ironruby-core@rubyforge.org >> >> *Subject:* Re: [Ironruby-core] Is there a But keyword in Cucumber? >> >> >> >> 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 >> >> >> >> >> -- >> 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 >> >> > > > -- > Mohammad Azam > MVP (Microsoft Valuable Professional) > www.highoncoding.com > www.azamsharp.com > -- 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