[rspec-users] post authentication token

Zach Dennis zach.dennis at gmail.com
Tue Oct 7 13:56:01 EDT 2008


You may want to look into using seed data. I currently use seed_fu by mbleigh:
    http://github.com/mbleigh/seed-fu/tree/master

Here's the snippet I use to load them:

  ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
  ActiveRecord::Schema.verbose = false
  load "#{RAILS_ROOT}/db/schema.rb"
  Dir[File.join(RAILS_ROOT, "features/fixtures", '*.rb')].sort.each {
|fixture| load fixture }

I do this rather than a rake task because that takes forever (thx
Brandon Keepers for correcting my usage, you have saved me tons of
minutes)

Zach


On Tue, Oct 7, 2008 at 11:23 AM, Mark Thomson <mark.thomson at ieee.org> wrote:
> Hey thanks Zach. That was a good suggestion. What the log file showed me was
> that I had a nil object being accessed in my "new" action - and the reason
> is that it's an object that in my development code is read from a table of
> global variables in my db. I create that table, including the values of the
> global variable, in a migration. However, this doesn't exist in my test db.
> So I did a <Model>.create in my "given" step to instantiate the global
> variable and I'm now all good.
>
> Mark.
>
>
>
> Zach Dennis wrote:
>>
>> On Tue, Oct 7, 2008 at 8:36 AM, Mark Thomson <mark.thomson at ieee.org>
>> wrote:
>>
>>>
>>> Hmm, thanks. Still not sure if I'm diagnosing my problem correctly. Just
>>> to
>>> be clear, I don't have any user authentication going on, just a regular
>>> Rails button_to call. I tried installing webrat and put "visits '/' " in
>>> my
>>> "given" step and "clicks_button" in my "when" step. However I get an
>>> error
>>> from my_story.rb - "No such file or directory - open
>>> tmp/webrat-12233801950.html.
>>>
>>> Presumably my issue would also apply in posting a form in a regular Rails
>>> integration test. The example on pp207-208 of AWDR  doesn't suggest that
>>> anything needs to be done in a post call to achieve session
>>> authentication.
>>> And I see here -
>>>
>>> http://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection/ClassMethods.html#M000693
>>> that forgery protection is actually turned off in testing - which I've
>>> confirmed in my config/environments/test.rb. So maybe I have some other
>>> problem causing my response test to fail. Any other suggestions would be
>>> appreciated.
>>>
>>>
>>
>> Have you looked at your log/test.log file to see if there are any
>> exceptions being thrown? Or at least to see what is being rendered,
>> perhaps you're hitting a path you don't intend.
>>
>>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>



-- 
Zach Dennis
http://www.continuousthinking.com
http://www.mutuallyhuman.com


More information about the rspec-users mailing list