Sha256: 01bfedd4d23443ee8237c200a0201f19edfc9abe96f979b7c62b589b168c5144

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

require File.dirname(__FILE__) + '/spec_helper.rb'

attrs = {:url => 'http://someurl.com', :created_at => Time.now.utc.to_s, :screen_name => 'somename'}

describe Tweetable::Link, 'when doing CRUD' do 
  before do 
    RedisSpecHelper.reset
    @link = Tweetable::Link.create(:url => attrs[:url], :created_at => attrs[:created_at])    
  end
  
  it "should find link by URL" do
    link = Tweetable::Link.find(:url => attrs[:url]).first
    link.url.should == attrs[:url]
  end
end

describe Tweetable::Link, 'when counting' do 
  before do 
    RedisSpecHelper.reset
    @link = Tweetable::Link.create(:url => attrs[:url], :created_at => attrs[:created_at])
    @user = Tweetable::User.create(:screen_name => attrs[:screen_name])
    @link.users.add(@user)
  end
  
  it "should not increment count for users already in set" do
    @link.should_not_receive(:incr).with(:count)
    @link.increment_usage_count(@user)
  end
  
  it "should increment count for users already in set" do
    user = Tweetable::User.create(:screen_name => attrs[:screen_name] + '_other')
    @link.should_receive(:incr).with(:count)
    @link.increment_usage_count(user)
  end  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tweetable-0.1.14 spec/link_spec.rb
tweetable-0.1.13 spec/link_spec.rb
tweetable-0.1.11 spec/link_spec.rb
tweetable-0.1.10 spec/link_spec.rb