Hi! I''m still struggling with RSpec to get it working with a Rails application, that does not use a database. I removed all the db:* dependencies from the RSpec targets, but it still wants to connect to a database. Any ideas? bye, Tobias ** Execute spec:models /usr/bin/ruby1.8 -I"/var/lib/gems/1.8/gems/rspec-0.7.5/lib" "/var/lib/gems/1.8/gems/rspec-0.7.5/bin/spec" "spec/models/person_spec.rb" F 1) Mysql::Error in ''This sample spec should work without a database'' #28000Access denied for user ''root''@''localhost'' (using password: NO) Finished in 0.026762 seconds 1 specification, 1 failure rake aborted! Command failed with status (1): [/usr/bin/ruby1.8 -I"/var/lib/gems/1.8/gems...] /usr/lib/ruby/1.8/rake.rb:722:in `sh'' /usr/lib/ruby/1.8/rake.rb:729:in `call'' /usr/lib/ruby/1.8/rake.rb:729:in `sh'' /usr/lib/ruby/1.8/rake.rb:812:in `sh'' /usr/lib/ruby/1.8/rake.rb:747:in `ruby'' /usr/lib/ruby/1.8/rake.rb:812:in `ruby'' /var/lib/gems/1.8/gems/rspec-0.7.5/lib/spec/rake/spectask.rb:131:in `define'' /usr/lib/ruby/1.8/rake.rb:831:in `verbose'' /var/lib/gems/1.8/gems/rspec-0.7.5/lib/spec/rake/spectask.rb:110:in `define'' /usr/lib/ruby/1.8/rake.rb:387:in `call'' /usr/lib/ruby/1.8/rake.rb:387:in `execute'' /usr/lib/ruby/1.8/rake.rb:387:in `each'' /usr/lib/ruby/1.8/rake.rb:387:in `execute'' /usr/lib/ruby/1.8/rake.rb:357:in `invoke'' /usr/lib/ruby/1.8/thread.rb:135:in `synchronize'' /usr/lib/ruby/1.8/rake.rb:350:in `invoke'' /usr/lib/ruby/1.8/rake.rb:1906:in `run'' /usr/lib/ruby/1.8/rake.rb:1906:in `each'' /usr/lib/ruby/1.8/rake.rb:1906:in `run'' /usr/bin/rake:4
How do I reproduce this erratic behaviour? Detailed steps please. On 12/27/06, Tobias Grimm <listaccount at e-tobi.net> wrote:> Hi! > > I''m still struggling with RSpec to get it working with a Rails > application, that does not use a database. I removed all the db:* > dependencies from the RSpec targets, but it still wants to connect to a > database. > > Any ideas? > > bye, > > Tobias > > ** Execute spec:models > /usr/bin/ruby1.8 -I"/var/lib/gems/1.8/gems/rspec-0.7.5/lib" > "/var/lib/gems/1.8/gems/rspec-0.7.5/bin/spec" "spec/models/person_spec.rb" > > F > > 1) > Mysql::Error in ''This sample spec should work without a database'' > #28000Access denied for user ''root''@''localhost'' (using password: NO) > > > Finished in 0.026762 seconds > > 1 specification, 1 failure > rake aborted! > Command failed with status (1): [/usr/bin/ruby1.8 > -I"/var/lib/gems/1.8/gems...] > /usr/lib/ruby/1.8/rake.rb:722:in `sh'' > /usr/lib/ruby/1.8/rake.rb:729:in `call'' > /usr/lib/ruby/1.8/rake.rb:729:in `sh'' > /usr/lib/ruby/1.8/rake.rb:812:in `sh'' > /usr/lib/ruby/1.8/rake.rb:747:in `ruby'' > /usr/lib/ruby/1.8/rake.rb:812:in `ruby'' > /var/lib/gems/1.8/gems/rspec-0.7.5/lib/spec/rake/spectask.rb:131:in `define'' > /usr/lib/ruby/1.8/rake.rb:831:in `verbose'' > /var/lib/gems/1.8/gems/rspec-0.7.5/lib/spec/rake/spectask.rb:110:in `define'' > /usr/lib/ruby/1.8/rake.rb:387:in `call'' > /usr/lib/ruby/1.8/rake.rb:387:in `execute'' > /usr/lib/ruby/1.8/rake.rb:387:in `each'' > /usr/lib/ruby/1.8/rake.rb:387:in `execute'' > /usr/lib/ruby/1.8/rake.rb:357:in `invoke'' > /usr/lib/ruby/1.8/thread.rb:135:in `synchronize'' > /usr/lib/ruby/1.8/rake.rb:350:in `invoke'' > /usr/lib/ruby/1.8/rake.rb:1906:in `run'' > /usr/lib/ruby/1.8/rake.rb:1906:in `each'' > /usr/lib/ruby/1.8/rake.rb:1906:in `run'' > /usr/bin/rake:4 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Hello! aslak hellesoy wrote:> How do I reproduce this erratic behaviour? Detailed steps please. >Ok - I figured out, that I even get this problem without using rake: - Create a new rails app and install the rspec on rails plugin (I used version 0.7.5) - Create a new model test.rb, that not derives from AR: app/models/test.rb: class Test end - Create a spec for this model: spec/models/test_spec.rb: require File.dirname(__FILE__) + ''/../spec_helper'' context "A simple test" do specify "should not need a database" do 1.should.be == 1 end end Now run `ruby spec/models/test_spec.rb`. At this point I get: Mysql::Error in ''A simple test should not need a database'' Access denied for user ''root''@''localhost'' (using password: NO) spec/models/test_spec.rb:3: Now go into spec/models and run `ruby test_spec.rb`. This one seems to work, which makes it even more strange: . Finished in 0.001245 seconds 1 specification, 0 failures Test::Unit works fine, after replacing test_helper with: ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require ''application'' require ''test/unit'' require ''action_controller/test_process'' require ''action_web_service/test_invoke'' require ''breakpoint'' I tried the same with spec_helper.rb, but it didn''t work. What is different between running a spec from the application root and from the spec directory? For the moment I simply use a sqlite3 memory database to get RSpec working with my DB-less application. But I would prefer to not have this additional "build-time" -dependency. bye, Tobias