require 'spec_helper'
describe ActsAsAmico do
before :all do
FakeWeb.allow_net_connect = false
@all_resp = '
123BlahSome stuff
321BlahSome stuff
'
@resp_123 = '123BlahSome stuff'
@resp_321 = '321BlahSome stuff'
FakeWeb.register_uri(:get, "http://api.sample.com/rest_objects/123.xml", :body => @resp_123, :status => ["200", "OK"])
FakeWeb.register_uri(:get, "http://api.sample.com/rest_objects/321.xml", :body => @resp_321, :status => ["200", "OK"])
end
after :all do
FakeWeb.allow_net_connect=true
end
before :each do
@usera = Factory :user
@admin = Factory :admin
@rest_object = RestObject.find(321)
end
it "Should respond to amico_key on the class" do
RestObject.respond_to?(:amico_key).should be_true
end
it "should set the amico_key on the class" do
RestObject.amico_key.should be(:title)
end
it "should hold an amico_key" do
@rest_object.amico_key.should eq("Blah")
end
it "should follow" do
@usera.follow! @admin, 'admin'
@usera.following?(@admin, 'admin').should be_true
@admin.followers(:scope => 'admin').include?(@usera.amico_key.to_s).should be_true
end
it "should allow following an ActiveResource object" do
@usera.follow! @rest_object, 'rest_object'
@usera.following?(@rest_object, 'rest_object').should be_true
@rest_object.followers(:scope => 'rest_object').include?(@usera.amico_key.to_s).should be_true
end
end