Forum: IronRuby no such file to load -- spec/story (LoadError)

Posted by Sundae Oliseh (oliseh)
on 2010-11-25 16:18
Hi Guys,

I'm trying to run the following script:

require 'rubygems'
require 'spec/story'

steps_for(:product_x) do
  Given("Product $productName at $price") do |productName, price|
   pending "Need to complete implementation for accessing C# object"
  end
  When("user requests a $amount user license") do |amount|
    pending "Need to complete implementation for accessing C# object"
  end
  When("this does not include support") do
    pending "Need to complete implementation for accessing C# object"
  end
  Then("the price should be $price") do |price|
    pending "Need to complete implementation for accessing C# object"
  end
end

with_steps_for(:product_x) do
     run File.dirname(__FILE__) + "/pricing_scenarios_for_product_x"
end


And I get this error:

C:/Program Files/IronRuby
1.0/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
31:in `require': no such file to load -- spec/story (LoadError)
        from C:/Program Files/IronRuby
1.0/lib/ruby/site_ruby/1.8/rubygems/custo
m_require.rb:31:in `require'
        from pricing_scenarios_for_product_x_story.rb:2

Any ideas of what I'm doing wrong?

Thanks for any attention.
Posted by Sundae Oliseh (oliseh)
on 2010-11-26 20:15
I stumbled on this link...very similar to the problem I'm having

http://old.nabble.com/New-setup-error.-no-such-fil...

They suggest to run this: script/generate rspec

how do I run it? When I paste it Ironruby command prompt I get the 
following message:

'script' is not recognized as an internal or external command,
operable program or batch file.

Anybody ?


Sundae Oliseh wrote in post #963907:
> Hi Guys,
>
> I'm trying to run the following script:
>
> require 'rubygems'
> require 'spec/story'
>
> steps_for(:product_x) do
>   Given("Product $productName at $price") do |productName, price|
>    pending "Need to complete implementation for accessing C# object"
>   end
>   When("user requests a $amount user license") do |amount|
>     pending "Need to complete implementation for accessing C# object"
>   end
>   When("this does not include support") do
>     pending "Need to complete implementation for accessing C# object"
>   end
>   Then("the price should be $price") do |price|
>     pending "Need to complete implementation for accessing C# object"
>   end
> end
>
> with_steps_for(:product_x) do
>      run File.dirname(__FILE__) + "/pricing_scenarios_for_product_x"
> end
>
>
> And I get this error:
>
> C:/Program Files/IronRuby
> 1.0/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
> 31:in `require': no such file to load -- spec/story (LoadError)
>         from C:/Program Files/IronRuby
> 1.0/lib/ruby/site_ruby/1.8/rubygems/custo
> m_require.rb:31:in `require'
>         from pricing_scenarios_for_product_x_story.rb:2
>
> Any ideas of what I'm doing wrong?
>
> Thanks for any attention.
Posted by Shay Friedman (shayfriedman)
on 2010-11-26 22:38
(Received via mailing list)
script/generate is for rspec-rails (which is a rails plug-in).

I seems like you're not testing a rails app, so you need to install the
rspec gem in order to use it. Have you done that?

Shay.
Posted by Cory Foy (Guest)
on 2010-11-26 22:58
(Received via mailing list)
Hi Sundae,

generate is a ruby command in the script folder of a Rails app. Unless
you are working in a Rails app, it won't be available.

If you *are* working in a Rails app, but on a Windows machine, then
trying running "ir script/generate rspec". I think that's right. I know
in Ruby it would be "ruby script/generate rspec". You are telling the
interpreter to execute the file "generate" in the folder called "script"
passing the argument "rspec" to it.

Have you installed rspec in your gems?

Cory
Posted by Sundae Oliseh (oliseh)
on 2010-11-26 23:19
Thanks for the replies guys.

Indeed I'm *not* testing a rails application.

I have installed rspec.

here's the output from the installation:

C:\IronRuby\bin>igem install rspec
**************************************************

  Thank you for installing rspec-core-2.1.0

  Please be sure to look at the upgrade instructions to see what might 
have
  changed since the last release:

  http://github.com/rspec/rspec-core/blob/master/Upg...

**************************************************
Successfully installed rspec-core-2.1.0
Successfully installed diff-lcs-1.1.2
Successfully installed rspec-expectations-2.1.0
Successfully installed rspec-mocks-2.1.0
Successfully installed rspec-2.1.0
5 gems installed
Installing ri documentation for rspec-core-2.1.0...
Installing ri documentation for diff-lcs-1.1.2...
Installing ri documentation for rspec-expectations-2.1.0...
Installing ri documentation for rspec-mocks-2.1.0...
Installing ri documentation for rspec-2.1.0...
Installing RDoc documentation for rspec-core-2.1.0...
Installing RDoc documentation for diff-lcs-1.1.2...
Installing RDoc documentation for rspec-expectations-2.1.0...
Installing RDoc documentation for rspec-mocks-2.1.0...
Installing RDoc documentation for rspec-2.1.0...
Posted by Cory Foy (Guest)
on 2010-11-27 01:49
(Received via mailing list)
Hi Sundae,

Are you running this from a tutorial? If I remember correctly,
spec/story was the old StoryRunner for RSpec, which was deprecated since
most everyone uses Cucumber for Story Writing. Do you have the link to
the tutorial you are using?

Cory
Posted by Sundae Oliseh (oliseh)
on 2010-11-27 02:04
Hi Cory,

That's an excellent question.
As I am an absolute newbie in Ironruby, I'm using these two articles as 
starting point

http://msdn.microsoft.com/en-us/magazine/dd434651.aspx
http://msdn.microsoft.com/en-us/magazine/dd453038.aspx

Maybe they're outdated.



Cory Foy wrote in post #964185:
> Hi Sundae,
>
> Are you running this from a tutorial? If I remember correctly,
> spec/story was the old StoryRunner for RSpec, which was deprecated since
> most everyone uses Cucumber for Story Writing. Do you have the link to
> the tutorial you are using?
>
> Cory
Posted by Cory Foy (Guest)
on 2010-11-27 05:19
(Received via mailing list)
Hi Sundae,

Indeed they are. You want to be looking at Cucumber instead of RSpec for
Story support.

I'd highly recommend David's book (which I believe has finally shipped!)
http://www.pragprog.com/titles/achbd/the-rspec-book. It's not about
using BDD with IronRuby, but the concepts are still important.

I'm not sure what the latest scoop is for Cucumber and IronRuby, but it
looks like Shay recently answered a question around it on the Ruby list
(http://www.ruby-forum.com/topic/216286) so he might chime in soon with
more info for that. But they pointed to the following article
(http://blog.webintellix.com/2009/10/how-to-use-cuc...)
which is over a year old now, but I'm assuming still works.

Cory
Posted by Mike Hatfield (Guest)
on 2010-11-27 12:41
(Received via mailing list)
Hi Sundae,

The articles in MSDN magazine are a little out dated.  What versions on
IronRuby are you running?  You can type in ir -v to get the version.  I
remember struggling with these articles when I first started out.  I'd 
be
happy to give you a hand.

Mike
Posted by Sundae Oliseh (oliseh)
on 2010-11-29 16:38
Hi Cory,

I was suspecting that something was not quite right with RSPEC. I Will 
take a look at Cucumber instead.
I will definitely pick up a copy of that book.

Thanks for the recommendation.



Cory Foy wrote in post #964205:
> Hi Sundae,
>
> Indeed they are. You want to be looking at Cucumber instead of RSpec for
> Story support.
>
> I'd highly recommend David's book (which I believe has finally shipped!)
> http://www.pragprog.com/titles/achbd/the-rspec-book. It's not about
> using BDD with IronRuby, but the concepts are still important.
>
> I'm not sure what the latest scoop is for Cucumber and IronRuby, but it
> looks like Shay recently answered a question around it on the Ruby list
> (http://www.ruby-forum.com/topic/216286) so he might chime in soon with
> more info for that. But they pointed to the following article
> (http://blog.webintellix.com/2009/10/how-to-use-cuc...)
> which is over a year old now, but I'm assuming still works.
>
> Cory
Posted by Sundae Oliseh (oliseh)
on 2010-11-29 16:45
I'm running  IronRuby 1.0.0.0 on .NET 2.0.50727.3615 Mike.

Mike Hatfield wrote in post #964264:
> Hi Sundae,
>
> The articles in MSDN magazine are a little out dated.  What versions on
> IronRuby are you running?  You can type in ir -v to get the version.  I
> remember struggling with these articles when I first started out.  I'd
> be
> happy to give you a hand.
>
> Mike
Posted by Sundae Oliseh (oliseh)
on 2010-11-29 17:59
I am currently following this tutorial:

http://blog.webintellix.com/2009/10/how-to-use-cuc...

and I'm stuck on step 4 with the following error:

C:\Ruby192\bin>icucumber -help
c:/Ruby192/lib/ruby/gems/1.9.1/gems/gherkin-2.2.9-x86-mingw32/lib/gherkin/native
/ikvm.rb:16:in `load_assembly': Assembly 'gherkin' not found\nTry this: 
SET MONO
_PATH=c:/Ruby192/lib/ruby/gems/1.9.1/gems/gherkin-2.2.9-x86-mingw32/lib 
(or expo
rt MONO_PATH=...) (LoadError)
        from 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/gherkin-2.2.9-x86-mingw32/lib/g
herkin/native/ikvm.rb:16:in `native_impl'
        from 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/gherkin-2.2.9-x86-mingw32/lib/g
herkin/i18n.rb:7
        from 
C:/IronRuby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
 `require'
        from 
C:/IronRuby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
 `require'
        from 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/gherkin-2.2.9-x86-mingw32/lib/g
herkin/lexer/i18n_lexer.rb:1
        from 
C:/IronRuby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
 `require'
        from 
C:/IronRuby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
 `require'
        from 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/gherkin-2.2.9-x86-mingw32/lib/g
herkin.rb:1
        from 
C:/IronRuby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
 `require'
        from 
C:/IronRuby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
 `require'
        from 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/cucumber-0.9.4/bin/../lib/cucum
ber/cli/main.rb:5
        from 
C:/IronRuby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
 `require'
        from 
C:/IronRuby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
 `require'
        from 
c:/Ruby192/lib/ruby/gems/1.9.1/gems/cucumber-0.9.4/bin/cucumber:5
        from C:/Ruby192/bin/cucumber:19:in `load'
        from C:/Ruby192/bin/cucumber:19





Sundae Oliseh wrote in post #964772:
> I'm running  IronRuby 1.0.0.0 on .NET 2.0.50727.3615 Mike.
>
> Mike Hatfield wrote in post #964264:
>> Hi Sundae,
>>
>> The articles in MSDN magazine are a little out dated.  What versions on
>> IronRuby are you running?  You can type in ir -v to get the version.  I
>> remember struggling with these articles when I first started out.  I'd
>> be
>> happy to give you a hand.
>>
>> Mike
Posted by Mike Hatfield (Guest)
on 2010-11-29 20:51
(Received via mailing list)
It seems that Cucumber for IronRuby is a little broken at the moment.
 There's an issue with Gherkin (the bdd language used by Cucumber and
SpecFlow).

To get around this, I installed an older version of Cucumber that did 
not
have this dependency.

I installed Cucumber 1.6.4 with the command:
igem install cucumber -v=1.6.4

It needed iron-term-ansicolor, I installed that with:
igem install iron-term-ansicolor

To get Cucumber to run with IronRuby, I created a batch file in the 
IronRuby
bin folder called icucumber.bat.  My bat file looks like:
@ECHO OFF
REM This is to tell IronRuby where to find gems.
SET
GEM_PATH=C:\Users\mike.hatfield.NICOM\.pik\rubies\IronRuby-10v4\lib\ironruby\gems\1.8
@"C:\Users\mike.hatfield.NICOM\.pik\rubies\IronRuby-10v4\bin\ir.exe"
"C:\Users\mike.hatfield.NICOM\.pik\rubies\IronRuby-10v4\bin\cucumber" %*

Your batch file's GEM_PATH and executable paths are probably different 
than
mine, I'm running IronRuby with PIK (allows me to run multiple versions 
of
Ruby).

I then started the feature from the MSDN article.  I had to change 
"Story:"
to "Feature:".  My story is:
Feature: Pricing for New Product X
  As a sales administrator, I want to be able to view
  prices for product x so that I can provide customers
  with an accurate cost for their requirements.

  Scenario: Single User License for Product X without support
    Given Product X
    When user requests a 1 user license
    And this does not include support
    Then the price should be $250

I called this file story.feature and saved it in a folder called 
features.

If you run the following cucumber command, you should get the initial
cucumber story run.
icucumber features

This gives you a list of steps (When clauses) that need to be 
implemented in
your step definitions to make the story pass.

Inside the features folder I created another folder called 
step_definitons.
 Inside the step_definitons folder, I created a file called 
product_steps.rb

Now, for the .NET class library.  I created three class files:
*Product.cs*
namespace Bdd.Store
{
  public class Product
  {
    public string Name { get; set; }
    public double Price { get; set; }
  }
}

*Store.cs*
namespace Bdd.Store
{
  public class Store
  {
    public Product FindByProductName(string name)
    {
      Product product = new Product { Name = name };
      return product;
    }
  }
}

*Purchase.cs*
namespace Bdd.Store
{
  public class Purchase
  {
    public Product Product{ get; set; }
    public int Licenses { get; set; }
    public bool IncludesSupport { get; set; }
    public double GetTotalPurchasePrice()
    {
      double price = Product.Price * Licenses;
      double supportFees = 0.0;
      if(IncludesSupport)
      {
        supportFees = price * 0.10;
      }

      return price + supportFees;
    }
  }
}

I then compiled these into an assembly called Product.dll using the 
CSharp
compiler command (run from my Visual Studio Command window):
csc /out:Product.dll /target:library Product.cs Store.cs Purchase.cs

I then required my Product.dll into my step definitions file (
product_steps.rb)
require File.dirname(__FILE__) + "/Product.dll"

Just as a convenience, I "include" my Bdd.Store namespace:
include Bdd::Store

I also require RSepc
require "rspec"

Lastly, I begin implementing my steps:
Given /^Product (.*)$/ do |product|
  @store = Store.new
  @product = @store.find_by_product_name(product)
  @product.price = 250;
  @product.name.should == product
end

and so on and so forth.  You can download my files from
http://webcoding4fun.oakraven.net/downloads/BDD
Example with CSharp.zip I hope this helps a little.

Mike
Posted by Sundae Oliseh (oliseh)
on 2010-11-29 21:30
Thanks for your very detailled example Mike.
I've run into some issues while following it:

when I run the following statement: igem install cucumber -v=1.6.4
here's the error message I received:

C:\IronRuby\bin>igem install cucumber -v=1.6.4
ERROR:  could not find gem cucumber locally or in a repository

I searched around the net a little bit and found out that there is an 
alternative syntax:

C:\IronRuby\bin>igem install --source http://gems.rubyforge.org cucumber 
- v1.6.4

I ran it and got the follwing output

(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) 
(::)

Thank you for installing cucumber-0.9.4.
Please be sure to read 
http://wiki.github.com/aslakhellesoy/cucumber/upgrading
for important information about this release. Happy cuking!

(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) 
(::)

Successfully installed cucumber-0.9.4
ERROR:  could not find gem v1.6.4 locally or in a repository
1 gem installed
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rdoc-2.5.11/lib/rdoc/ruby_lex.rb:67: 
warning
: parenthesize argument(s) for future version
Installing ri documentation for cucumber-0.9.4...
Installing RDoc documentation for cucumber-0.9.4...


As you can see, there is an error message in there. It did not 
ultimately install the correct version
Posted by Tomas Matousek (Guest)
on 2010-11-29 22:12
(Received via mailing list)
Do these problems manifest when using IronRuby 1.1.2? (master from 
github). Could you file a bug with details if so?

Thanks,
Tomas

From: ironruby-core-bounces@rubyforge.org 
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Mike Hatfield
Sent: Monday, November 29, 2010 11:16 AM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] no such file to load -- spec/story 
(LoadError)

It seems that Cucumber for IronRuby is a little broken at the moment. 
There's an issue with Gherkin (the bdd language used by Cucumber and 
SpecFlow).

To get around this, I installed an older version of Cucumber that did 
not have this dependency.

I installed Cucumber 1.6.4 with the command:
igem install cucumber -v=1.6.4

It needed iron-term-ansicolor, I installed that with:
igem install iron-term-ansicolor

To get Cucumber to run with IronRuby, I created a batch file in the 
IronRuby bin folder called icucumber.bat.  My bat file looks like:
@ECHO OFF
REM This is to tell IronRuby where to find gems.
SET 
GEM_PATH=C:\Users\mike.hatfield.NICOM\.pik\rubies\IronRuby-10v4\lib\ironruby\gems\1.8
@"C:\Users\mike.hatfield.NICOM\.pik\rubies\IronRuby-10v4\bin\ir.exe" 
"C:\Users\mike.hatfield.NICOM\.pik\rubies\IronRuby-10v4\bin\cucumber" %*

Your batch file's GEM_PATH and executable paths are probably different 
than mine, I'm running IronRuby with PIK (allows me to run multiple 
versions of Ruby).

I then started the feature from the MSDN article.  I had to change 
"Story:" to "Feature:".  My story is:
Feature: Pricing for New Product X
  As a sales administrator, I want to be able to view
  prices for product x so that I can provide customers
  with an accurate cost for their requirements.

  Scenario: Single User License for Product X without support
    Given Product X
    When user requests a 1 user license
    And this does not include support
    Then the price should be $250

I called this file story.feature and saved it in a folder called 
features.

If you run the following cucumber command, you should get the initial 
cucumber story run.
icucumber features

This gives you a list of steps (When clauses) that need to be 
implemented in your step definitions to make the story pass.

Inside the features folder I created another folder called 
step_definitons.  Inside the step_definitons folder, I created a file 
called product_steps.rb

Now, for the .NET class library.  I created three class files:
Product.cs
namespace Bdd.Store
{
  public class Product
  {
    public string Name { get; set; }
    public double Price { get; set; }
  }
}

Store.cs
namespace Bdd.Store
{
  public class Store
  {
    public Product FindByProductName(string name)
    {
      Product product = new Product { Name = name };
      return product;
    }
  }
}

Purchase.cs
namespace Bdd.Store
{
  public class Purchase
  {
    public Product Product{ get; set; }
    public int Licenses { get; set; }
    public bool IncludesSupport { get; set; }
    public double GetTotalPurchasePrice()
    {
      double price = Product.Price * Licenses;
      double supportFees = 0.0;
      if(IncludesSupport)
      {
        supportFees = price * 0.10;
      }

      return price + supportFees;
    }
  }
}

I then compiled these into an assembly called Product.dll using the 
CSharp compiler command (run from my Visual Studio Command window):
csc /out:Product.dll /target:library Product.cs Store.cs Purchase.cs

I then required my Product.dll into my step definitions file 
(product_steps.rb)
require File.dirname(__FILE__) + "/Product.dll"

Just as a convenience, I "include" my Bdd.Store namespace:
include Bdd::Store

I also require RSepc
require "rspec"

Lastly, I begin implementing my steps:
Given /^Product (.*)$/ do |product|
  @store = Store.new
  @product = @store.find_by_product_name(product)
  @product.price = 250;
  @product.name.should == product
end

and so on and so forth.  You can download my files from 
http://webcoding4fun.oakraven.net/downloads/BDD Example with 
CSharp.zip<http://webcoding4fun.oakraven.net/downloads/BDD%20... 
I hope this helps a little.

Mike
Posted by Mike Hatfield (Guest)
on 2010-11-29 23:18
(Received via mailing list)
Sorry Sundae, I had a type-o on the Cucumber version.

try:

igem install cucumber -v=0.6.4

It's 0.6.4, not 1.6.4.  Again.  Apologies.
Posted by Sundae Oliseh (oliseh)
on 2010-11-30 17:50
No need to apologize at all Mike. In any case, I should apologize to you 
for taking so much of your time.

I have some good news to report...It's finally working. I was able to 
run your script without any problem.

Thank you so much for all the help and patience. Cory, Shay..thank you 
too. It took us 3 days but we did it. Cheers!
Posted by Mike Hatfield (Guest)
on 2010-11-30 19:49
(Received via mailing list)
That's great to hear Sundae.  Glad to help.  I learned a bit myself. :)
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.