Luke Galea-4 wrote: > > Could someone point me in the right direction? > > I thought the simplest way would be to either call the login action > from my other tests before(:all), but I can't seem to find how to > call another controller from within the spec for a different > controller. (Results in @controller is nil). >
This is what we do. I realize that according to the another poster this is the wrong way, but it is the best way we've found for use with Goldberg. def goldbergAuthAdmin() get 'goldberg/auth/login' #Goldberg::AuthController.set_user(session, Goldberg::User.find_by_name(:first, "admin").id) #Our Admin user has id 2. Goldberg::AuthController.set_user(session,2) end BTW, another important step is bootstrapping goldberg into your test database... To facilitate this we added two methods to the GoldbergMigration model: def self.clear_for_class(klass, dest) filename = "#{dest}/#{klass.to_s.sub(/^Goldberg::/, '')}.yml" records = klass.delete_all end def self.clear_bootstrap self.goldberg_classes.each do |klass| self.clear_for_class klass, "#{File.dirname(__FILE__)}/../db" end end Then add this to spec_helper.rb, or your own included spec_helper def goldbergReload() GoldbergMigration.clear_bootstrap GoldbergMigration.load_bootstrap end Then call this from a before(:all) in the first describe of each rspec needing goldberg. Of course you have to have dumped your goldberg bootstrap from dev/production first (You do this in the console: "GoldbergMigration.dump_bootstrap" to save all goldberg settings, controller/action perms, users roles, etc to some yaml files). Hope that helps! Peter Boling Sagebit, LLC -- View this message in context: http://www.nabble.com/Authenticating-before-tests-tf4435346.html#a12737465 Sent from the rspec-users mailing list archive at Nabble.com. _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users