Hi all, I am trying to use rspec_on_rails in a Rails app that doesn''t have a database. so far I have just been faking it out by dumping in a sqlite3 database just to make Rails happy. I was using for test::unit a rake task that eliminated the calls to database prep: # Added this .rake file to keep Rake happy without a database. # Remove once a database is in the picture. ["test:units", "test:functionals", "test:integration", "recent"].each do |name| Rake::Task[name].prerequisites.clear end However, adding the spec:models etc doesn''t work, I get a "Don''t know how to build task ''spec:models''" error... What is the right way of faking out the database? Using one of the Mock frameworks? Eric ------------------------------------------------------- Principal OpenSource Connections Site: http://www.opensourceconnections.com Blog: http://blog.opensourceconnections.com Cell: 1-434-466-1467
On 7/24/07, Eric Pugh <epugh at opensourceconnections.com> wrote:> Hi all, > > I am trying to use rspec_on_rails in a Rails app that doesn''t have a > database. so far I have just been faking it out by dumping in a > sqlite3 database just to make Rails happy.Try deleting config/database.yml (or renaming it to something else) and then running: rake spec That should do it.
On 7/27/07, David Chelimsky <dchelimsky at gmail.com> wrote:> On 7/24/07, Eric Pugh <epugh at opensourceconnections.com> wrote: > > Hi all, > > > > I am trying to use rspec_on_rails in a Rails app that doesn''t have a > > database. so far I have just been faking it out by dumping in a > > sqlite3 database just to make Rails happy. > > Try deleting config/database.yml (or renaming it to something else) > and then running: > > rake spec > > That should do it.I take it back. It doesn''t work. There is an open RFE on making this work - perhaps it''s time to address it.
On 7/27/07, David Chelimsky <dchelimsky at gmail.com> wrote:> On 7/27/07, David Chelimsky <dchelimsky at gmail.com> wrote: > > On 7/24/07, Eric Pugh <epugh at opensourceconnections.com> wrote: > > > Hi all, > > > > > > I am trying to use rspec_on_rails in a Rails app that doesn''t have a > > > database. so far I have just been faking it out by dumping in a > > > sqlite3 database just to make Rails happy. > > > > Try deleting config/database.yml (or renaming it to something else) > > and then running: > > > > rake spec > > > > That should do it. > > I take it back. It doesn''t work. There is an open RFE on making this > work - perhaps it''s time to address it. >Ah - this worked using Rails 1.2.3 and RSpec''s trunk. In config/environments.rb: Rails::Initializer.run do |config| config.frameworks -= [ :active_record ] end Cheers, David
Quoting David Chelimsky <dchelimsky at gmail.com>:> On 7/27/07, David Chelimsky <dchelimsky at gmail.com> wrote: >> On 7/27/07, David Chelimsky <dchelimsky at gmail.com> wrote: >> > On 7/24/07, Eric Pugh <epugh at opensourceconnections.com> wrote: >> > > Hi all, >> > > >> > > I am trying to use rspec_on_rails in a Rails app that doesn''t have a >> > > database. so far I have just been faking it out by dumping in a >> > > sqlite3 database just to make Rails happy. >> > >> > Try deleting config/database.yml (or renaming it to something else) >> > and then running: >> > >> > rake spec >> > >> > That should do it. >> >> I take it back. It doesn''t work. There is an open RFE on making this >> work - perhaps it''s time to address it. >> > > Ah - this worked using Rails 1.2.3 and RSpec''s trunk. In > config/environments.rb: > > Rails::Initializer.run do |config| > config.frameworks -= [ :active_record ] > endDavid, I like this solution too, but then you don''t have access to some of the other nicities for a model, like validations. I found these links: http://www.realityforge.org/articles/2005/12/02/validations-for-non-activerecord-model-objects http://wiki.rubyonrails.com/rails/pages/HowToUseValidationsWithoutExtendingActiveRecord http://www.railsweenie.com/forums/2/topics/724 That talk about different ways to solve this. The last link seems like the best.> > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program.