-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
twitter_user_agent_spec.rb
41 lines (33 loc) · 1.25 KB
/
twitter_user_agent_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require 'spec_helper'
describe Agents::TwitterUserAgent do
before do
# intercept the twitter API request for @tectonic's user profile
stub_request(:any, /tectonic/).to_return(:body => File.read(Rails.root.join("spec/data_fixtures/user_tweets.json")), :status => 200)
@opts = {
:username => "tectonic",
:expected_update_period_in_days => "2",
:starting_at => "Jan 01 00:00:01 +0000 2000",
:consumer_key => "---",
:consumer_secret => "---",
:oauth_token => "---",
:oauth_token_secret => "---"
}
@checker = Agents::TwitterUserAgent.new(:name => "tectonic", :options => @opts)
@checker.user = users(:bob)
@checker.save!
end
describe "#check" do
it "should check for changes" do
lambda { @checker.check }.should change { Event.count }.by(5)
end
end
describe "#check with starting_at=future date" do
it "should check for changes starting_at a future date, thus not find any" do
opts = @opts.merge({ :starting_at => "Jan 01 00:00:01 +0000 2999", })
checker = Agents::TwitterUserAgent.new(:name => "tectonic", :options => opts)
checker.user = users(:bob)
checker.save!
lambda { checker.check }.should change { Event.count }.by(0)
end
end
end