I want to put together a script that will test the validations as part
of a suite of tests to confirm the app’s validity as I expand it. For
this purpose, I added a Q&A directory (actually, “__QA”) under AIMS_1
and populated it with the following portfolio_spec.rb file:
describe Portfolio do
it "should report any invalid :stock entries" do
pf = Portfolio.new
end
end
When I run “spec portfolio_spec.rb” in a Command window I get the
diagnostic:
ActiveRecord::ConnectionNotEstablished in 'Portfolio should report any
invalid :stock entries'.
I expected some error because I’m creating a Portfolio instance
outside the AIMS_1 framework generated by Rails. I have no idea how
to address this issue.
I’m running ruby 1.8.6, Rails 2.0.2 and SciTE 1.74 over WinXP/SP2.
When I run spec portfolio_spec.rb in a Command window I get the
diagnostic:
ActiveRecord::ConnectionNotEstablished in 'Portfolio should report any
invalid :stock entries'.
I expected some error because I'm creating a Portfolio instance
outside the AIMS_1 framework generated by Rails. I have no idea how
to address this issue.
I'm running ruby 1.8.6, Rails 2.0.2 and SciTE 1.74 over WinXP/SP2.
Any ideas?
Thanks in Advance,
Richard
Are you using the Rspec-Rails plugin?
Cos that should absorb a lot of this capacity for error.
(looks like you just want to require "../../config/environment" or
something to fix it, so you load rails, rather than just active_record)
but...
install it as a plugin
(maybe install rspec as a plugin in the same way else it seems to choke
if your rspec and rspec-rails versions are different)
then run "ruby script/generate rspec"
(don't ask me why this isnt a rake task "spec:setup".. but it isn't)
and it should get you a new spec in spec/models/furbie_spec.rb
which should work,
and then make your existing code work the same way...
see what went wrong the first time...
First the good news: Your suggestion about requiring the configuration
was spot on! So I’m a happy camper and will indeed make the post you
requested at the end of your response.
While I plan to continue using the rspec gem for this current
project, I’m very interested in using the two plug-ins you
recommended on future projects. However, I wasn’t able to get rspec
plug-in to install. Below are the steps I took to:
1. Get the rspec-rails plug-in installed
2. When that failed, try a different plug-in to show plug-in
installation is working, generally.
I hope you can decipher my current error. Your unraveling my last
error was neat!
Best wishes,
Richard
[snip]\AIMS_1>gem uninstall rspec
[OK]
[snip]\AIMS_1>ruby script/plugin discover
[OK, but showed no dchelimsky]