|
59 | 59 | expect(tweets.first).to be_a Twitter::Tweet
|
60 | 60 | expect(tweets.first.text).to eq('Powerful cartoon by @BillBramhall: http://t.co/IOEbc5QoES')
|
61 | 61 | end
|
| 62 | + context 'not found' do |
| 63 | + before do |
| 64 | + stub_post('/1.1/favorites/destroy.json').with(body: {id: '540897316908331009'}).to_return(status: 404, body: fixture('not_found.json'), headers: {content_type: 'application/json; charset=utf-8'}) |
| 65 | + end |
| 66 | + it 'does not raise an error' do |
| 67 | + expect { @client.unfavorite(540_897_316_908_331_009) }.not_to raise_error |
| 68 | + end |
| 69 | + end |
62 | 70 | context 'with a URI object passed' do
|
63 | 71 | it 'requests the correct resource' do
|
64 | 72 | tweet = URI.parse('https://twitter.com/sferik/status/540897316908331009')
|
|
75 | 83 | end
|
76 | 84 | end
|
77 | 85 |
|
| 86 | + describe '#unfavorite!' do |
| 87 | + before do |
| 88 | + stub_post('/1.1/favorites/destroy.json').with(body: {id: '540897316908331009'}).to_return(body: fixture('status.json'), headers: {content_type: 'application/json; charset=utf-8'}) |
| 89 | + end |
| 90 | + it 'requests the correct resource' do |
| 91 | + @client.unfavorite!(540_897_316_908_331_009) |
| 92 | + expect(a_post('/1.1/favorites/destroy.json').with(body: {id: '540897316908331009'})).to have_been_made |
| 93 | + end |
| 94 | + it 'returns an array of un-favorited Tweets' do |
| 95 | + tweets = @client.unfavorite!(540_897_316_908_331_009) |
| 96 | + expect(tweets).to be_an Array |
| 97 | + expect(tweets.first).to be_a Twitter::Tweet |
| 98 | + expect(tweets.first.text).to eq('Powerful cartoon by @BillBramhall: http://t.co/IOEbc5QoES') |
| 99 | + end |
| 100 | + context 'does not exist' do |
| 101 | + before do |
| 102 | + stub_post('/1.1/favorites/destroy.json').with(body: {id: '540897316908331009'}).to_return(status: 404, body: fixture('not_found.json'), headers: {content_type: 'application/json; charset=utf-8'}) |
| 103 | + end |
| 104 | + it 'raises a NotFound error' do |
| 105 | + expect { @client.unfavorite!(540_897_316_908_331_009) }.to raise_error(Twitter::Error::NotFound) |
| 106 | + end |
| 107 | + end |
| 108 | + context 'with a URI object passed' do |
| 109 | + it 'requests the correct resource' do |
| 110 | + tweet = URI.parse('https://twitter.com/sferik/status/540897316908331009') |
| 111 | + @client.unfavorite!(tweet) |
| 112 | + expect(a_post('/1.1/favorites/destroy.json').with(body: {id: '540897316908331009'})).to have_been_made |
| 113 | + end |
| 114 | + end |
| 115 | + context 'with a Tweet passed' do |
| 116 | + it 'requests the correct resource' do |
| 117 | + tweet = Twitter::Tweet.new(id: 540_897_316_908_331_009) |
| 118 | + @client.unfavorite!(tweet) |
| 119 | + expect(a_post('/1.1/favorites/destroy.json').with(body: {id: '540897316908331009'})).to have_been_made |
| 120 | + end |
| 121 | + end |
| 122 | + end |
| 123 | + |
78 | 124 | describe '#favorite' do
|
79 | 125 | before do
|
80 | 126 | stub_post('/1.1/favorites/create.json').with(body: {id: '540897316908331009'}).to_return(body: fixture('status.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
|
0 commit comments