[rspec-users] How to test scripts in the lib directory of Rails?

1,969 views
Skip to first unread message

Volkan Unsal

unread,
Jan 7, 2011, 6:17:15 PM1/7/11
to rspec...@rubyforge.org
I have a script called query.rb inside my lib folder in Rails 3. I am
writing a spec test for it. Though I'm no sure how to reference the
Query class from my tests. Whenever I use Query, RSpec complain that
it's not able to find it.

This is how I wrote it:

before(:each) do
query = Query.new
end

How can I make sure that Query is accessible by the spec?
_______________________________________________
rspec-users mailing list
rspec...@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Nick

unread,
Jan 7, 2011, 7:13:10 PM1/7/11
to rs...@googlegroups.com, rspec...@rubyforge.org
Hey Volkan. Make sure to "require" the file that your Query class is in. Usually this is done at the top of query_spec.rb , or in spec_helper.rb .

Cheers,
Nick

Volkan Unsal

unread,
Jan 7, 2011, 7:44:05 PM1/7/11
to rspec...@rubyforge.org
D'oh! Thanks Nick!

> _______________________________________________
> rspec-users mailing list
> rspec-us...@rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users

Reply all
Reply to author
Forward
0 new messages