Skip to content

Commit

Permalink
Update specs
Browse files Browse the repository at this point in the history
  • Loading branch information
spiceee committed Jun 15, 2022
1 parent 79121b9 commit b7876bf
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
2 changes: 1 addition & 1 deletion spec/fixtures/user_timeline.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"created_at": "Wed May 04 22:48:53 +0000 2022",
"id": 1521985240276819971,
"id_str": "1521985240276819971",
"text": "@MicaelSilva sim, tb d\u00e1 pra colocar um noise se tiver uma pausa. tudo muito b\u00e1sico pra quem opera r\u00e1dio, eu fico bobo",
"text": "@MicaelSilva sim, tb d\u00e1 pra colocar um noise se tiver uma pausa. tudo muito b\u00e1sico pra quem opera r\u00e1dio, eu fico bobo #sad",
"truncated": false,
"entities": {
"hashtags": [],
Expand Down
54 changes: 53 additions & 1 deletion spec/i_delete_my_tweets/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
IDeleteMyTweets::Config.new(screen_name: 'spiceee',
older_than: 1.hour.ago,
fave_threshold: 0,
rt_threshold: 0,)
rt_threshold: 0,
with_words: nil)
end

let(:match_all_delete_req) { %r{#{Twitter::REST::Request::BASE_URL}/1\.1/statuses/destroy/([0-9]+)\.json}o }
Expand Down Expand Up @@ -104,6 +105,57 @@
end
end

describe 'with words criteria' do
let(:rt_threshold) { 0 }
let(:fave_threshold) { 0 }
let(:with_words) { "#TBT, #drunktweets, trump" }
let(:with_words2) { "bozo, FedEx" }
let(:with_words3) { "bozo, fedex" }
let(:with_words4) { "something, #sad" }

it 'skips tweets that do not include the denylist' do
allow(config).to receive(:with_words).and_return(with_words)
allow(config).to receive(:rt_threshold).and_return(rt_threshold)
allow(config).to receive(:fave_threshold).and_return(fave_threshold)

capture_warning do
api.traverse_api!
expect(a_request(:post, match_all_delete_req))
.to have_been_made.times(7)
end
end

it 'deletes tweets with any of the words' do
allow(config).to receive(:with_words).and_return(with_words2)

capture_warning do
api.traverse_api!
expect(a_request(:post, match_all_delete_req))
.to have_been_made.times(5)
end
end

it 'deletes tweets with any of the case variations of words' do
allow(config).to receive(:with_words).and_return(with_words3)

capture_warning do
api.traverse_api!
expect(a_request(:post, match_all_delete_req))
.to have_been_made.times(5)
end
end

it 'deletes tweets with hashtags' do
allow(config).to receive(:with_words).and_return(with_words4)

capture_warning do
api.traverse_api!
expect(a_request(:post, match_all_delete_req))
.to have_been_made.times(6)
end
end
end

describe 'with --dry-run' do
it 'skips delete requests to the Twitter API' do
allow(api).to receive(:dry_run).and_return(true)
Expand Down

0 comments on commit b7876bf

Please sign in to comment.