RichardOnRails
2008-Jun-29 21:18 UTC
Second question on using RSpec for a simple Rails 2.0 app
Hi, I’ve got a Rails 2.0 app “AIMS_1” with one model, “Portfolio”. (I’m following David Chelimsky’s 2007 tutorial at http://blog.davidchelimsky.net/articles/2007/05/14/an-introduction-to-rspec-part-i). Portfolio has two attributes: :symbol and :name. With great help from this NG, I’ve got a neat set of validations for :symbol. 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: # portfolio_spec.rb # K:\_Projects\Ruby\_Rails_Apps\AIMS_1\__QA require ''rubygems'' require ''spec'' require ''spec/story'' require ''K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/ activerecord-2.0.2/lib/ActiveRecord'' require ''../app/models/portfolio'' 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. Any ideas? Thanks in Advance, Richard --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Matthew Rudy Jacobs
2008-Jun-29 23:57 UTC
Re: Second question on using RSpec for a simple Rails 2.0 app
RichardOnRails wrote:> 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, > RichardAre 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... http://github.com/dchelimsky/rspec-rails/tree/master 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 you should have a basic spec_helper in place. then try creating a new model "ruby script/generate rspec_model Furbie name:string age:integer" 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... Regards Matthew Rudy (recommend me on WorkingWithRails http://workingwithrails.com/person/12394-matthew-rudy-jacobs) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
RichardOnRails
2008-Jun-30 15:32 UTC
Re: Second question on using RSpec for a simple Rails 2.0 app
Hi Matthew, Thank you very much for your excellent help. 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] [snip]\AIMS_1>ruby script/plugin source http://github.com/dchelimsky/ [OK] [snip]\AIMS_1>ruby script/plugin install rspec-rails Plugin not found: ["rspec-rails"] [snip]\AIMS_1>ruby script/plugin sources http://dev.rubyonrails.com/svn/rails/plugins/ http://github.com/dchelimsky/ http://svn.6brand.com/projects/plugins/ [snip]\ AIMS_1>ruby script/plugin install simple_pages + ./CHANGELOG + ./README + ./Rakefile + ./app/controllers/simple_pages_controller.rb + ./app/helpers/simple_pages_helper.rb + ./app/models/simple_page.rb [snip] On Jun 29, 7:57 pm, Matthew Rudy Jacobs <rails-mailing-l...@andreas- s.net> wrote:> RichardOnRails wrote: > > 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...http://github.com/dchelimsky/rspec-rails/tree/master > > 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 you should have a basic spec_helper in place. > > then try creating a new model > > "ruby script/generate rspec_model Furbie name:string age:integer" > > 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... > > Regards > Matthew Rudy > > (recommend me on WorkingWithRailshttp://workingwithrails.com/person/12394-matthew-rudy-jacobs) > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Matthew Rudy Jacobs
2008-Jun-30 15:37 UTC
Re: Second question on using RSpec for a simple Rails 2.0 app
I have Rspec frozen in the plugins folder, so I know its the exact same version as the Rspec-Rails I''m using. Thought you might be able to freeze it by doing a "script/plugin install", but clearly not. But if its working for you, then don''t worry. Enjoy some spec-ing. Matthew Rudy RichardOnRails wrote:> Hi Matthew, > > Thank you very much for your excellent help. > > 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.-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
David Chelimsky
2008-Jul-01 13:44 UTC
Re: Second question on using RSpec for a simple Rails 2.0 app
On Mon, Jun 30, 2008 at 10:32 AM, RichardOnRails <RichardDummyMailbox58407-gP6xRNRnnqSxhq/XJNNIW0EOCMrvLtNR@public.gmane.org> wrote:> > Hi Matthew, > > Thank you very much for your excellent help. > > 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.Check out http://github.com/dchelimsky/rspec-rails/wikis. Cheers, David --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
RichardOnRails
2008-Jul-03 16:31 UTC
Re: Second question on using RSpec for a simple Rails 2.0 app
Hi David, Thanks for that source. I''ll try your plug-ins after the Fourth. Best wishes, Richard On Jul 1, 9:44 am, "David Chelimsky" <dchelim...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Mon, Jun 30, 2008 at 10:32 AM, RichardOnRails > > <RichardDummyMailbox58...-gP6xRNRnnqSxhq/XJNNIW0EOCMrvLtNR@public.gmane.org> wrote: > > > Hi Matthew, > > > Thank you very much for your excellent help. > > > 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. > > Check outhttp://github.com/dchelimsky/rspec-rails/wikis. > > Cheers, > David--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---