Forum: RSpec Uninitialized constant Spec:Story

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
07dd367bcc4ae602d640ec8c1b280df6?d=identicon&s=25 Mark Thomson (Guest)
on 2008-10-06 18:50
(Received via mailing list)
Hi, I'm fairly new to Rails and v. new to RSpec. Think it looks pretty
useful and so I'm trying it out for the first time. I have installed the
rspec-rails gem and created a simple plain text my_story file and
my_story.rb file along the lines described here -
http://www.tomtenthij.co.uk/2008/1/25/rspec-plain-....

When I run stories/my_story.rb it blows up and the thing that seems most
significant in the error messages is "uninitialized constant Spec::Story
(NameError)" which seems to originate from story_adapter.rb:66, where
the class Spec::Story::Runner::ScenarioRunner is defined.

Would appreciate any guidance towards a resolution of this issue.

Thanks,

Mark
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2008-10-06 19:32
(Received via mailing list)
On Mon, Oct 6, 2008 at 11:29 AM, Mark Thomson <mark.thomson@ieee.org>
wrote:
>
> Would appreciate any guidance towards a resolution of this issue.

Have you done this:

script/generate rspec
07dd367bcc4ae602d640ec8c1b280df6?d=identicon&s=25 Mark Thomson (Guest)
on 2008-10-06 19:47
(Received via mailing list)
Indeed I have. Just re-ran it to make sure. No change in behavior.

Mark.
07dd367bcc4ae602d640ec8c1b280df6?d=identicon&s=25 Mark Thomson (Guest)
on 2008-10-06 20:26
(Received via mailing list)
FWIW, I'm running Rails 2.1 on Windows. I have tried running RSpec on
two completely separate Rails installations on different machines and
get the same result.

Mark.
C694a032be7518a0d704318895f8fe1d?d=identicon&s=25 Ben Mabey (mabes)
on 2008-10-06 20:43
(Received via mailing list)
Mark Thomson wrote:
> FWIW, I'm running Rails 2.1 on Windows. I have tried running RSpec on
> two completely separate Rails installations on different machines and
> get the same result.
>
> Mark.

Please post your stories/helper.rb.

-Ben
07dd367bcc4ae602d640ec8c1b280df6?d=identicon&s=25 Mark Thomson (Guest)
on 2008-10-06 20:53
(Received via mailing list)
stories/helper.rb is as follows -


----
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) +
"/../config/environment")
require 'spec/rails/story_adapter'

dir = File.dirname(__FILE__)
Dir[File.expand_path("#{dir}/steps/*.rb")].uniq.each do |file|
  require file
end

##
# Run a story file relative to the stories directory.

def run_local_story(filename, options={})
  run File.join(File.dirname(__FILE__), filename), options
end
----


Mark.
C694a032be7518a0d704318895f8fe1d?d=identicon&s=25 Ben Mabey (mabes)
on 2008-10-06 20:59
(Received via mailing list)
Mark Thomson wrote:
> stories/helper.rb is as follows -
>
>
> ----
> ENV["RAILS_ENV"] = "test"
> require File.expand_path(File.dirname(__FILE__) +
> "/../config/environment")
> require 'spec/rails/story_adapter'

Hmm.. Shot in the dark, but try adding
require 'spec/story'

before the "require 'spec/rails/story_adapter'" line.

-Ben
07dd367bcc4ae602d640ec8c1b280df6?d=identicon&s=25 Mark Thomson (Guest)
on 2008-10-06 21:13
(Received via mailing list)
Good shot - that worked! :-)

Still, I'm curious as to why. Poking around with my very rudimentary
knowledge of how ruby gems work, it looks as if the files that define
Spec::Stories are in the rspec gem, not the rspec-rails gem, and as far
as I can see there is nothing in the skeleton files that get installed
in <app>/stories to require those files. Does this suggest that the line
you recommended should be added to the release? But am I the only person
to have this problem?

Mark.
C694a032be7518a0d704318895f8fe1d?d=identicon&s=25 Ben Mabey (mabes)
on 2008-10-06 21:29
(Received via mailing list)
Mark Thomson wrote:
> Mark.
Well, I lied- I have had that exact same problem before.  So it wasn't
really in the dark, but I wasn't 100% sure it was the same problem. :)
I think either the helper.rb generator changed and removed the
'spec/story' line or the rails adapter changed and removed the needed
require it may of once had.  So the problem should be fixed in one of
those places IMO.  We just had a series of rspec releases and I don't
know if this would qualify for another emergency fix.

WDYT David or Pat?

-Ben
Cdf378de2284d8acf137122e541caa28?d=identicon&s=25 Matt Wynne (mattwynne)
on 2008-10-06 23:08
(Received via mailing list)
Mark, what nobody seems to a have mentioned on this thread is that
you're using a branch of the story runner that's probably going to be
retired.

There's no reason why you should know - the rspec.info site is a bit
out of date in this regard.

I'd encourage you to read this:
http://blog.davidchelimsky.net/2008/9/22/cucumber
07dd367bcc4ae602d640ec8c1b280df6?d=identicon&s=25 Mark Thomson (Guest)
on 2008-10-06 23:22
(Received via mailing list)
Wow, more stuff to learn!  Thanks for the heads up.

Mark.
This topic is locked and can not be replied to.