Sha256: d59f8860d5be0aad774faceaa658943bb1c33f8f8526b0a683c66aad36579577

Contents?: true

Size: 1.81 KB

Versions: 1

Compression:

Stored size: 1.81 KB

Contents

require 'spec_helper'

describe ActsAsAmico do
  before :all do
    FakeWeb.allow_net_connect = false
    @all_resp = '<rest_objects type="array">
                  <rest_object><id>123</id><title>Blah</title><description>Some stuff</description></rest_object>
                  <rest_object><id>321</id><title>Blah</title><description>Some stuff</description></rest_object>
                </rest_objects>'
    @resp_123 = '<rest_object><id>123</id><title>Blah</title><description>Some stuff</description></rest_object>'
    @resp_321 = '<rest_object><id>321</id><title>Blah</title><description>Some stuff</description></rest_object>'

    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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
acts_as_amico-0.2.2 spec/active_resource_spec.rb