views:

132

answers:

0

I am (finally) attempting to write some integration tests for my application (because every deploy is getting scarier). Since testing is a horribly documented feature of Rails, this was the best I could get going with shoulda.

class DeleteBusinessTest < ActionController::IntegrationTest
  context "log skydiver in and" do
    setup do
      @skydiver = Factory( :skydiver )
      @skydiver_session = SkydiverSession.create(@skydiver)
      @biz = Factory( :business, :ownership => Factory(:ownership, :skydiver => @skydiver ))
    end

    context "delete business" do
      setup do
        @skydiver_session = SkydiverSession.find
        post  '/businesses/destroy', :id => @biz.id
      end

      should_redirect_to('businesses_path()'){businesses_path()}
    end
  end
end

In theory, this test seems like it should pass. My factories seem like they are pushing the right data in:

Factory.define :skydiver do |s|
  s.sequence(:login) { |n| "test#{n}" }
  s.sequence(:email) { |n| "test#{n}@example.com" }
  s.crypted_password '1805986f044ced38691118acfb26a6d6d49be0d0'
  s.password 'secret'
  s.password_confirmation { |u| u.password }
  s.salt 'aowgeUne1R4-F6FFC1ad'
  s.firstname 'Test'
  s.lastname 'Salt'
  s.nickname 'Mr. Password Testy'
  s.facebook_user_id '507743444'
end

The problem I am getting seems to be from Facebooker only seems to happen on login attempts. When the test runs, I am getting the error: The error occurred while evaluating nil.set_facebook_session. I believe that error is to be expected in a certain sense since I am not using Facebook here for this session. Can anyone provide any insight as to how to either get around this or at least help me out with what is going wrong?

Note: This error didn't start happening in my unit and functional tests until I added the following into the class ActiveSupport::TestCase block. The unit and functional tests all work with the below block removed, but the below block is necessary for proper integration tests (I think).

include Authlogic::TestCase
def setup
  activate_authlogic
end