I just switched our project over to Edge Rails, and I'm running into  
this problem with all of my helper methods that call _url methods:

NoMethodError in 'ApplicationHelper home_link should generate a valid  
home link when User.current and Profile.current is not set'
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.<<
./spec/helpers/application_helper_spec.rb:17

Here's the relevant spec:

describe ApplicationHelper, "home_link" do
        before(:each) do
                User.current = nil
                Profile.current = nil
        end

        it "should generate a valid home link when User.current and  
Profile.current is not set" do
                home_link.should =~ /#{new_profile_url}/
        end

        it "should generate a valid home link when User.current is set" do
                User.current = mock_model(User)
                home_link.should =~ /#{dashboard_url}/
        end

        it "should generate a valid home link when Profile.current is set" do
                Profile.current = mock_model(Profile)
                home_link.should =~ /#{profile_url(Profile.current)}/
        end
end

And the method in ApplicationHelper:

def home_link
     if User.current.blank?
       if Profile.current.blank?
         link_to 'Get Started', new_profile_url
       else
         link_to 'My Profile', profile_url(Profile.current)
       end
     else
       link_to 'Dashboard', dashboard_url
     end
end

I'm using RSpec 1.0.8 and Rails revision 7360. Any ideas where to  
start looking for a fix or workaround?

Regards,
J.D.

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to