|
11 | 11 | require 'publish/twitter' |
12 | 12 |
|
13 | 13 | describe Automatic::Plugin::PublishTwitter do |
14 | | - subject { |
15 | | - Automatic::Plugin::PublishTwitter.new( |
16 | | - { 'consumer_key' => 'your_consumer_key', |
17 | | - 'consumer_secret' => 'your_consumer_secret', |
18 | | - 'oauth_token' => 'your_oauth_token', |
19 | | - 'oauth_token_secret' => 'your_oauth_token_secret', |
20 | | - 'interval' => 5, |
21 | | - 'retry' => 5 |
22 | | - }, |
23 | | - AutomaticSpec.generate_pipeline{ |
| 14 | + context 'when feed' do |
| 15 | + describe 'should post the link tweet' do |
| 16 | + subject { |
| 17 | + Automatic::Plugin::PublishTwitter.new( |
| 18 | + {}, |
| 19 | + AutomaticSpec.generate_pipeline{ |
24 | 20 | feed { item "http://github.com" } |
| 21 | + })} |
| 22 | + |
| 23 | + its (:run) { |
| 24 | + twitter = mock("twitter") |
| 25 | + twitter.should_receive(:update).with(" http://github.com") |
| 26 | + subject.instance_variable_set(:@twitter, twitter) |
| 27 | + subject.run.should have(1).feed |
| 28 | + } |
| 29 | + end |
| 30 | + |
| 31 | + describe 'should post the tweet_tmp' do |
| 32 | + subject { |
| 33 | + Automatic::Plugin::PublishTwitter.new( |
| 34 | + { 'tweet_tmp' => 'publish-twitter'}, |
| 35 | + AutomaticSpec.generate_pipeline{ |
| 36 | + feed { item "http://github.com" } |
| 37 | + })} |
| 38 | + |
| 39 | + its (:run) { |
| 40 | + twitter = mock("twitter") |
| 41 | + twitter.should_receive(:update).with("publish-twitter") |
| 42 | + subject.instance_variable_set(:@twitter, twitter) |
| 43 | + subject.run.should have(1).feed |
| 44 | + } |
| 45 | + end |
| 46 | + |
| 47 | + describe 'interval & retry was used error' do |
| 48 | + subject { |
| 49 | + Automatic::Plugin::PublishTwitter.new( |
| 50 | + { 'interval' => 1, 'retry' => 1 }, |
| 51 | + AutomaticSpec.generate_pipeline{ |
| 52 | + feed { item "http://github.com" } |
| 53 | + })} |
| 54 | + |
| 55 | + its (:run) { |
| 56 | + subject.run.should have(1).feed |
| 57 | + } |
| 58 | + end |
| 59 | + end |
| 60 | + |
| 61 | + context 'when feed is empty' do |
| 62 | + describe 'should not post' do |
| 63 | + subject { |
| 64 | + Automatic::Plugin::PublishTwitter.new( |
| 65 | + {}, |
| 66 | + )} |
| 67 | + |
| 68 | + its (:run) { |
| 69 | + subject.run.should have(0).feed |
25 | 70 | } |
26 | | - ) |
27 | | - } |
28 | | - |
29 | | - it "should post the link tweet" do |
30 | | - twitter = mock("twitter") |
31 | | - twitter.should_receive(:update).with(" http://github.com") |
32 | | - subject.instance_variable_set(:@twitter, twitter) |
33 | | - subject.run.should have(1).feed |
| 71 | + end |
34 | 72 | end |
35 | 73 | end |
0 commit comments