I'm building a activity stream feature in my app, all activities are created via controller methods.
When the controller method is successful the activity is recorder to activity table. Since my controller action is invoked via ajax, I tried posting directly from my rspec test.
I tried this :
Net::HTTP.post_form(URI.parse("http://localhost:5000#{inquiry_path}"), { :id=> @user.id, :type => 'Inquiry' })
This is what I see gets posted in my firebug, when making ajax call:
id:55
type:Inquiry
url:/user_inquiry
So I'm asserting whether the activity count has changed :
it "activity count should be changed" do
PublicActivity::Activity.count.should == 1
end
After I'm done with testing that count has changed, I wanted to see the user home page actually displaying the new notification.
But this test fails :
Failure/Error: PublicActivity::Activity.count.should == 1
expected: 1
got: 0 (using ==)
Just in case I put the puts statement in my controller, to check if the call actually reaches the controller :
puts "Hereeee"
I don't see the message getting printed so I guess the request never reaches the controller, why is that?
Am I doing something wrong here, how can I test this?