Matt Wynne wrote in post #976412: > On 20 Jan 2011, at 19:32, Brian Warner wrote: > >> I have a file in step_definitions that's giving me an error for an >> uninitialized constant. My guess is I need to 'require' the file where >> that class is defined. Said files is located in /lib/codebreaker. >> >> I am very new to Ruby so this is probably a really simple question but >> how do I 'require' a file in codebreaker from a file inside >> step_definitions? > > You could try asking on the RSpec Book's own forum: > http://forums.pragprog.com/forums/95 > > This question is really more Cucumber related so you could also ask on > the cukes google group. > > Your guess is right. The best place to put your require statement is in > features/support/env.rb > > I'm surprised that the book doesn't tell you to do that - did you maybe > miss a step? > > cheers, > Matt > > m...@mattwynne.net > 07974 430184
The require statement that the book says to put in env.rb is: $: << File.join(File.dirname(__FILE__), "/../lib/") require 'codebreaker' I ended up getting it to work after a co-worker pointed out that I need to add "./lib" to some thing in ruby's list of directories to look in. I don't remember what terminology he used but he did it through the terminal. The require statement I ended up using is require 'codebreaker/game' -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users