diff --git a/spec/twitter/action/favorite_spec.rb b/spec/twitter/action/favorite_spec.rb index 00e7ab19f..a7c94f2df 100644 --- a/spec/twitter/action/favorite_spec.rb +++ b/spec/twitter/action/favorite_spec.rb @@ -5,24 +5,24 @@ describe "#sources" do it "returns a collection of users who favorited a Tweet" do sources = Twitter::Action::Favorite.new(:sources => [{:id => 7505382}]).sources - sources.should be_an Array - sources.first.should be_a Twitter::User + expect(sources).to be_an Array + expect(sources.first).to be_a Twitter::User end it "is empty when not set" do sources = Twitter::Action::Favorite.new.sources - sources.should be_empty + expect(sources).to be_empty end end describe "#targets" do it "returns a collection containing the favorited Tweet" do targets = Twitter::Action::Favorite.new(:targets => [{:id => 25938088801}]).targets - targets.should be_an Array - targets.first.should be_a Twitter::Tweet + expect(targets).to be_an Array + expect(targets.first).to be_a Twitter::Tweet end it "is empty when not set" do targets = Twitter::Action::Favorite.new.targets - targets.should be_empty + expect(targets).to be_empty end end diff --git a/spec/twitter/action/follow_spec.rb b/spec/twitter/action/follow_spec.rb index 328ee6d47..a3fe1b1ba 100644 --- a/spec/twitter/action/follow_spec.rb +++ b/spec/twitter/action/follow_spec.rb @@ -5,24 +5,24 @@ describe "#sources" do it "returns a collection of users who followed a user" do sources = Twitter::Action::Follow.new(:sources => [{:id => 7505382}]).sources - sources.should be_an Array - sources.first.should be_a Twitter::User + expect(sources).to be_an Array + expect(sources.first).to be_a Twitter::User end it "is empty when not set" do sources = Twitter::Action::Follow.new.sources - sources.should be_empty + expect(sources).to be_empty end end describe "#targets" do it "returns a collection containing the followed user" do targets = Twitter::Action::Follow.new(:targets => [{:id => 7505382}]).targets - targets.should be_an Array - targets.first.should be_a Twitter::User + expect(targets).to be_an Array + expect(targets.first).to be_a Twitter::User end it "is empty when not set" do targets = Twitter::Action::Follow.new.targets - targets.should be_empty + expect(targets).to be_empty end end diff --git a/spec/twitter/action/list_member_added_spec.rb b/spec/twitter/action/list_member_added_spec.rb index 72fc4e938..67dd03618 100644 --- a/spec/twitter/action/list_member_added_spec.rb +++ b/spec/twitter/action/list_member_added_spec.rb @@ -5,36 +5,36 @@ describe "#sources" do it "returns a collection of users who added a user to a list" do sources = Twitter::Action::ListMemberAdded.new(:sources => [{:id => 7505382}]).sources - sources.should be_an Array - sources.first.should be_a Twitter::User + expect(sources).to be_an Array + expect(sources.first).to be_a Twitter::User end it "is empty when not set" do sources = Twitter::Action::ListMemberAdded.new.sources - sources.should be_empty + expect(sources).to be_empty end end describe "#target_objects" do it "returns a collection of lists that were added to" do targets = Twitter::Action::ListMemberAdded.new(:target_objects => [{:id => 8863586}]).target_objects - targets.should be_an Array - targets.first.should be_a Twitter::List + expect(targets).to be_an Array + expect(targets.first).to be_a Twitter::List end it "is empty when not set" do targets = Twitter::Action::ListMemberAdded.new.target_objects - targets.should be_empty + expect(targets).to be_empty end end describe "#targets" do it "returns a collection of users who were added to a list" do targets = Twitter::Action::ListMemberAdded.new(:targets => [{:id => 7505382}]).targets - targets.should be_an Array - targets.first.should be_a Twitter::User + expect(targets).to be_an Array + expect(targets.first).to be_a Twitter::User end it "is empty when not set" do targets = Twitter::Action::ListMemberAdded.new.targets - targets.should be_empty + expect(targets).to be_empty end end diff --git a/spec/twitter/action/mention_spec.rb b/spec/twitter/action/mention_spec.rb index 54ea16404..f3c29b739 100644 --- a/spec/twitter/action/mention_spec.rb +++ b/spec/twitter/action/mention_spec.rb @@ -5,47 +5,47 @@ describe "#sources" do it "returns a collection of users who mentioned a user" do sources = Twitter::Action::Mention.new(:sources => [{:id => 7505382}]).sources - sources.should be_an Array - sources.first.should be_a Twitter::User + expect(sources).to be_an Array + expect(sources.first).to be_a Twitter::User end it "is empty when not set" do sources = Twitter::Action::Mention.new.sources - sources.should be_empty + expect(sources).to be_empty end end describe "#source" do it "returns the user who mentioned a user" do source = Twitter::Action::Mention.new(:sources => [{:id => 7505382}]).source - source.should be_a Twitter::User + expect(source).to be_a Twitter::User end it "returns nil when not set" do source = Twitter::Action::Mention.new.source - source.should be_nil + expect(source).to be_nil end end describe "#target_objects" do it "returns a collection of Tweets that mention a user" do targets = Twitter::Action::Mention.new(:target_objects => [{:id => 25938088801}]).target_objects - targets.should be_an Array - targets.first.should be_a Twitter::Tweet + expect(targets).to be_an Array + expect(targets.first).to be_a Twitter::Tweet end it "is empty when not set" do targets = Twitter::Action::Mention.new.target_objects - targets.should be_empty + expect(targets).to be_empty end end describe "#targets" do it "returns a collection containing the mentioned user" do targets = Twitter::Action::Mention.new(:targets => [{:id => 7505382}]).targets - targets.should be_an Array - targets.first.should be_a Twitter::User + expect(targets).to be_an Array + expect(targets.first).to be_a Twitter::User end it "is empty when not set" do targets = Twitter::Action::Mention.new.targets - targets.should be_empty + expect(targets).to be_empty end end diff --git a/spec/twitter/action/reply_spec.rb b/spec/twitter/action/reply_spec.rb index 54fd585d5..d6360cc83 100644 --- a/spec/twitter/action/reply_spec.rb +++ b/spec/twitter/action/reply_spec.rb @@ -5,36 +5,36 @@ describe "#sources" do it "returns a collection of users who replied to a user" do sources = Twitter::Action::Reply.new(:sources => [{:id => 7505382}]).sources - sources.should be_an Array - sources.first.should be_a Twitter::User + expect(sources).to be_an Array + expect(sources.first).to be_a Twitter::User end it "is empty when not set" do sources = Twitter::Action::Reply.new.sources - sources.should be_empty + expect(sources).to be_empty end end describe "#target_objects" do it "returns a collection of Tweets that reply to a user" do targets = Twitter::Action::Reply.new(:target_objects => [{:id => 25938088801}]).target_objects - targets.should be_an Array - targets.first.should be_a Twitter::Tweet + expect(targets).to be_an Array + expect(targets.first).to be_a Twitter::Tweet end it "is empty when not set" do targets = Twitter::Action::Reply.new.target_objects - targets.should be_empty + expect(targets).to be_empty end end describe "#targets" do it "returns a collection that contains the replied-to status" do targets = Twitter::Action::Reply.new(:targets => [{:id => 25938088801}]).targets - targets.should be_an Array - targets.first.should be_a Twitter::Tweet + expect(targets).to be_an Array + expect(targets.first).to be_a Twitter::Tweet end it "is empty when not set" do targets = Twitter::Action::Reply.new.targets - targets.should be_empty + expect(targets).to be_empty end end diff --git a/spec/twitter/action/retweet_spec.rb b/spec/twitter/action/retweet_spec.rb index 25aaeb0b5..bc2668310 100644 --- a/spec/twitter/action/retweet_spec.rb +++ b/spec/twitter/action/retweet_spec.rb @@ -5,36 +5,36 @@ describe "#sources" do it "returns a collection of users who retweeted a user" do sources = Twitter::Action::Retweet.new(:sources => [{:id => 7505382}]).sources - sources.should be_an Array - sources.first.should be_a Twitter::User + expect(sources).to be_an Array + expect(sources.first).to be_a Twitter::User end it "is empty when not set" do sources = Twitter::Action::Retweet.new.sources - sources.should be_empty + expect(sources).to be_empty end end describe "#target_objects" do it "returns a collection of retweets" do targets = Twitter::Action::Retweet.new(:target_objects => [{:id => 25938088801}]).target_objects - targets.should be_an Array - targets.first.should be_a Twitter::Tweet + expect(targets).to be_an Array + expect(targets.first).to be_a Twitter::Tweet end it "is empty when not set" do targets = Twitter::Action::Retweet.new.target_objects - targets.should be_empty + expect(targets).to be_empty end end describe "#targets" do it "returns a collection containing the retweeted user" do targets = Twitter::Action::Retweet.new(:targets => [{:id => 7505382}]).targets - targets.should be_an Array - targets.first.should be_a Twitter::User + expect(targets).to be_an Array + expect(targets.first).to be_a Twitter::User end it "is empty when not set" do targets = Twitter::Action::Retweet.new.targets - targets.should be_empty + expect(targets).to be_empty end end diff --git a/spec/twitter/action_factory_spec.rb b/spec/twitter/action_factory_spec.rb index fe6bc03e2..10f9e0467 100644 --- a/spec/twitter/action_factory_spec.rb +++ b/spec/twitter/action_factory_spec.rb @@ -5,32 +5,32 @@ describe ".new" do it "generates a Favorite" do action = Twitter::ActionFactory.fetch_or_new(:action => 'favorite') - action.should be_a Twitter::Action::Favorite + expect(action).to be_a Twitter::Action::Favorite end it "generates a Follow" do action = Twitter::ActionFactory.fetch_or_new(:action => 'follow') - action.should be_a Twitter::Action::Follow + expect(action).to be_a Twitter::Action::Follow end it "generates a ListMemberAdded" do action = Twitter::ActionFactory.fetch_or_new(:action => 'list_member_added') - action.should be_a Twitter::Action::ListMemberAdded + expect(action).to be_a Twitter::Action::ListMemberAdded end it "generates a Mention" do action = Twitter::ActionFactory.fetch_or_new(:action => 'mention') - action.should be_a Twitter::Action::Mention + expect(action).to be_a Twitter::Action::Mention end it "generates a Reply" do action = Twitter::ActionFactory.fetch_or_new(:action => 'reply') - action.should be_a Twitter::Action::Reply + expect(action).to be_a Twitter::Action::Reply end it "generates a Retweet" do action = Twitter::ActionFactory.fetch_or_new(:action => 'retweet') - action.should be_a Twitter::Action::Retweet + expect(action).to be_a Twitter::Action::Retweet end it "raises an ArgumentError when action is not specified" do - lambda do + expect do Twitter::ActionFactory.fetch_or_new - end.should raise_error(ArgumentError, "argument must have :action key") + end.to raise_error(ArgumentError, "argument must have :action key") end end diff --git a/spec/twitter/action_spec.rb b/spec/twitter/action_spec.rb index a95c138e0..f74bf85bf 100644 --- a/spec/twitter/action_spec.rb +++ b/spec/twitter/action_spec.rb @@ -5,11 +5,11 @@ describe "#created_at" do it "returns a Time when created_at is set" do user = Twitter::User.new(:id => 7505382, :created_at => "Mon Jul 16 12:59:01 +0000 2007") - user.created_at.should be_a Time + expect(user.created_at).to be_a Time end it "returns nil when created_at is not set" do user = Twitter::User.new(:id => 7505382) - user.created_at.should be_nil + expect(user.created_at).to be_nil end end diff --git a/spec/twitter/api/account_spec.rb b/spec/twitter/api/account_spec.rb index 3226a8dca..56d0569cf 100644 --- a/spec/twitter/api/account_spec.rb +++ b/spec/twitter/api/account_spec.rb @@ -13,13 +13,13 @@ end it "requests the correct resource" do @client.verify_credentials - a_get("/1.1/account/verify_credentials.json"). - should have_been_made + expect(a_get("/1.1/account/verify_credentials.json")). + to have_been_made end it "returns the requesting user" do user = @client.verify_credentials - user.should be_a Twitter::User - user.id.should eq 7505382 + expect(user).to be_a Twitter::User + expect(user.id).to eq 7505382 end end @@ -31,14 +31,14 @@ end it "requests the correct resource" do @client.update_delivery_device("sms") - a_post("/1.1/account/update_delivery_device.json"). - with(:body => {:device => "sms"}). - should have_been_made + expect(a_post("/1.1/account/update_delivery_device.json"). + with(:body => {:device => "sms"})). + to have_been_made end it "returns a user" do user = @client.update_delivery_device("sms") - user.should be_a Twitter::User - user.id.should eq 7505382 + expect(user).to be_a Twitter::User + expect(user.id).to eq 7505382 end end @@ -50,14 +50,14 @@ end it "requests the correct resource" do @client.update_profile(:url => "http://github.com/sferik/") - a_post("/1.1/account/update_profile.json"). - with(:body => {:url => "http://github.com/sferik/"}). - should have_been_made + expect(a_post("/1.1/account/update_profile.json"). + with(:body => {:url => "http://github.com/sferik/"})). + to have_been_made end it "returns a user" do user = @client.update_profile(:url => "http://github.com/sferik/") - user.should be_a Twitter::User - user.id.should eq 7505382 + expect(user).to be_a Twitter::User + expect(user.id).to eq 7505382 end end @@ -68,13 +68,13 @@ end it "requests the correct resource" do @client.update_profile_background_image(fixture("we_concept_bg2.png")) - a_post("/1.1/account/update_profile_background_image.json"). - should have_been_made + expect(a_post("/1.1/account/update_profile_background_image.json")). + to have_been_made end it "returns a user" do user = @client.update_profile_background_image(fixture("we_concept_bg2.png")) - user.should be_a Twitter::User - user.id.should eq 7505382 + expect(user).to be_a Twitter::User + expect(user.id).to eq 7505382 end end @@ -86,14 +86,14 @@ end it "requests the correct resource" do @client.update_profile_colors(:profile_background_color => "000000") - a_post("/1.1/account/update_profile_colors.json"). - with(:body => {:profile_background_color => "000000"}). - should have_been_made + expect(a_post("/1.1/account/update_profile_colors.json"). + with(:body => {:profile_background_color => "000000"})). + to have_been_made end it "returns a user" do user = @client.update_profile_colors(:profile_background_color => "000000") - user.should be_a Twitter::User - user.id.should eq 7505382 + expect(user).to be_a Twitter::User + expect(user.id).to eq 7505382 end end @@ -104,13 +104,13 @@ end it "requests the correct resource" do @client.update_profile_image(fixture("me.jpeg")) - a_post("/1.1/account/update_profile_image.json"). - should have_been_made + expect(a_post("/1.1/account/update_profile_image.json")). + to have_been_made end it "returns a user" do user = @client.update_profile_image(fixture("me.jpeg")) - user.should be_a Twitter::User - user.id.should eq 7505382 + expect(user).to be_a Twitter::User + expect(user.id).to eq 7505382 end end @@ -121,12 +121,12 @@ end it "requests the correct resource" do @client.update_profile_banner(fixture("me.jpeg")) - a_post("/1.1/account/update_profile_banner.json"). - should have_been_made + expect(a_post("/1.1/account/update_profile_banner.json")). + to have_been_made end it "returns a user" do user = @client.update_profile_banner(fixture("me.jpeg")) - user.should be_nil + expect(user).to be_nil end end @@ -137,12 +137,12 @@ end it "requests the correct resource" do @client.remove_profile_banner - a_post("/1.1/account/remove_profile_banner.json"). - should have_been_made + expect(a_post("/1.1/account/remove_profile_banner.json")). + to have_been_made end it "returns a user" do user = @client.remove_profile_banner - user.should be_nil + expect(user).to be_nil end end @@ -156,24 +156,24 @@ end it "requests the correct resource on GET" do @client.settings - a_get("/1.1/account/settings.json"). - should have_been_made + expect(a_get("/1.1/account/settings.json")). + to have_been_made end it "returns settings" do settings = @client.settings - settings.should be_a Twitter::Settings - settings.language.should eq 'en' + expect(settings).to be_a Twitter::Settings + expect(settings.language).to eq 'en' end it "requests the correct resource on POST" do @client.settings(:trend_location_woeid => "23424803") - a_post("/1.1/account/settings.json"). - with(:body => {:trend_location_woeid => "23424803"}). - should have_been_made + expect(a_post("/1.1/account/settings.json"). + with(:body => {:trend_location_woeid => "23424803"})). + to have_been_made end it "returns settings" do settings = @client.settings(:trend_location_woeid => "23424803") - settings.should be_a Twitter::Settings - settings.language.should eq 'en' + expect(settings).to be_a Twitter::Settings + expect(settings.language).to eq 'en' end end diff --git a/spec/twitter/api/activity_spec.rb b/spec/twitter/api/activity_spec.rb index 99ecb4a55..2c20ab2d4 100644 --- a/spec/twitter/api/activity_spec.rb +++ b/spec/twitter/api/activity_spec.rb @@ -13,12 +13,12 @@ end it "requests the correct resource" do @client.activity_about_me - a_get("/i/activity/about_me.json"). - should have_been_made + expect(a_get("/i/activity/about_me.json")). + to have_been_made end it "returns activity about me" do activity_about_me = @client.activity_about_me - activity_about_me.first.should be_a Twitter::Action::Mention + expect(activity_about_me.first).to be_a Twitter::Action::Mention end end @@ -29,12 +29,12 @@ end it "requests the correct resource" do @client.activity_by_friends - a_get("/i/activity/by_friends.json"). - should have_been_made + expect(a_get("/i/activity/by_friends.json")). + to have_been_made end it "returns activity by friends" do activity_by_friends = @client.activity_by_friends - activity_by_friends.first.should be_a Twitter::Action::Favorite + expect(activity_by_friends.first).to be_a Twitter::Action::Favorite end end diff --git a/spec/twitter/api/blocks_spec.rb b/spec/twitter/api/blocks_spec.rb index e0775e8b2..45679da1b 100644 --- a/spec/twitter/api/blocks_spec.rb +++ b/spec/twitter/api/blocks_spec.rb @@ -14,16 +14,16 @@ end it "requests the correct resource" do @client.blocking - a_get("/1.1/blocks/list.json"). - with(:query => {:cursor => "-1"}). - should have_been_made + expect(a_get("/1.1/blocks/list.json"). + with(:query => {:cursor => "-1"})). + to have_been_made end it "returns an array of user objects that the authenticating user is blocking" do blocking = @client.blocking - blocking.should be_a Twitter::Cursor - blocking.users.should be_an Array - blocking.users.first.should be_a Twitter::User - blocking.users.first.id.should eq 7505382 + expect(blocking).to be_a Twitter::Cursor + expect(blocking.users).to be_an Array + expect(blocking.users.first).to be_a Twitter::User + expect(blocking.users.first.id).to eq 7505382 end end @@ -35,15 +35,15 @@ end it "requests the correct resource" do @client.blocked_ids - a_get("/1.1/blocks/ids.json"). - with(:query => {:cursor => "-1"}). - should have_been_made + expect(a_get("/1.1/blocks/ids.json"). + with(:query => {:cursor => "-1"})). + to have_been_made end it "returns an array of numeric user IDs the authenticating user is blocking" do blocked_ids = @client.blocked_ids - blocked_ids.should be_a Twitter::Cursor - blocked_ids.ids.should be_an Array - blocked_ids.ids.first.should eq 14100886 + expect(blocked_ids).to be_a Twitter::Cursor + expect(blocked_ids.ids).to be_an Array + expect(blocked_ids.ids.first).to eq 14100886 end end @@ -65,23 +65,23 @@ end it "requests the correct resource" do @client.block?("sferik") - a_get("/1.1/blocks/ids.json"). - with(:query => {:cursor => "-1"}). - should have_been_made - a_get("/1.1/blocks/ids.json"). - with(:query => {:cursor => "1305102810874389703"}). - should have_been_made - a_get("/1.1/users/show.json"). - with(:query => {:screen_name => "sferik"}). - should have_been_made + expect(a_get("/1.1/blocks/ids.json"). + with(:query => {:cursor => "-1"})). + to have_been_made + expect(a_get("/1.1/blocks/ids.json"). + with(:query => {:cursor => "1305102810874389703"})). + to have_been_made + expect(a_get("/1.1/users/show.json"). + with(:query => {:screen_name => "sferik"})). + to have_been_made end it "returns true if block exists" do block = @client.block?("pengwynn") - block.should be_true + expect(block).to be_truthy end it "returns false if block does not exist" do block = @client.block?("sferik") - block.should be_false + expect(block).to be_falsey end end context "with a user ID passed" do @@ -95,12 +95,12 @@ end it "requests the correct resources" do @client.block?(7505382) - a_get("/1.1/blocks/ids.json"). - with(:query => {:cursor => "-1"}). - should have_been_made - a_get("/1.1/blocks/ids.json"). - with(:query => {:cursor => "1305102810874389703"}). - should have_been_made + expect(a_get("/1.1/blocks/ids.json"). + with(:query => {:cursor => "-1"})). + to have_been_made + expect(a_get("/1.1/blocks/ids.json"). + with(:query => {:cursor => "1305102810874389703"})). + to have_been_made end end context "with a user object passed" do @@ -115,12 +115,12 @@ it "requests the correct resources" do user = Twitter::User.new(:id => '7505382') @client.block?(user) - a_get("/1.1/blocks/ids.json"). - with(:query => {:cursor => "-1"}). - should have_been_made - a_get("/1.1/blocks/ids.json"). - with(:query => {:cursor => "1305102810874389703"}). - should have_been_made + expect(a_get("/1.1/blocks/ids.json"). + with(:query => {:cursor => "-1"})). + to have_been_made + expect(a_get("/1.1/blocks/ids.json"). + with(:query => {:cursor => "1305102810874389703"})). + to have_been_made end end end @@ -133,14 +133,14 @@ end it "requests the correct resource" do @client.block("sferik") - a_post("/1.1/blocks/create.json"). - should have_been_made + expect(a_post("/1.1/blocks/create.json")). + to have_been_made end it "returns an array of blocked users" do users = @client.block("sferik") - users.should be_an Array - users.first.should be_a Twitter::User - users.first.id.should eq 7505382 + expect(users).to be_an Array + expect(users.first).to be_a Twitter::User + expect(users.first.id).to eq 7505382 end end @@ -152,15 +152,15 @@ end it "requests the correct resource" do @client.unblock("sferik") - a_post("/1.1/blocks/destroy.json"). - with(:body => {:screen_name => "sferik"}). - should have_been_made + expect(a_post("/1.1/blocks/destroy.json"). + with(:body => {:screen_name => "sferik"})). + to have_been_made end it "returns an array of un-blocked users" do users = @client.unblock("sferik") - users.should be_an Array - users.first.should be_a Twitter::User - users.first.id.should eq 7505382 + expect(users).to be_an Array + expect(users.first).to be_a Twitter::User + expect(users.first.id).to eq 7505382 end end diff --git a/spec/twitter/api/direct_messages_spec.rb b/spec/twitter/api/direct_messages_spec.rb index e2a902a43..d559fa9ff 100644 --- a/spec/twitter/api/direct_messages_spec.rb +++ b/spec/twitter/api/direct_messages_spec.rb @@ -13,14 +13,14 @@ end it "requests the correct resource" do @client.direct_messages_received - a_get("/1.1/direct_messages.json"). - should have_been_made + expect(a_get("/1.1/direct_messages.json")). + to have_been_made end it "returns the 20 most recent direct messages sent to the authenticating user" do direct_messages = @client.direct_messages_received - direct_messages.should be_an Array - direct_messages.first.should be_a Twitter::DirectMessage - direct_messages.first.sender.id.should eq 7505382 + expect(direct_messages).to be_an Array + expect(direct_messages.first).to be_a Twitter::DirectMessage + expect(direct_messages.first.sender.id).to eq 7505382 end end @@ -31,14 +31,14 @@ end it "requests the correct resource" do @client.direct_messages_sent - a_get("/1.1/direct_messages/sent.json"). - should have_been_made + expect(a_get("/1.1/direct_messages/sent.json")). + to have_been_made end it "returns the 20 most recent direct messages sent by the authenticating user" do direct_messages = @client.direct_messages_sent - direct_messages.should be_an Array - direct_messages.first.should be_a Twitter::DirectMessage - direct_messages.first.sender.id.should eq 7505382 + expect(direct_messages).to be_an Array + expect(direct_messages.first).to be_a Twitter::DirectMessage + expect(direct_messages.first.sender.id).to eq 7505382 end end @@ -50,15 +50,15 @@ end it "requests the correct resource" do @client.direct_message_destroy(1825785544) - a_post("/1.1/direct_messages/destroy.json"). - with(:body => {:id => "1825785544"}). - should have_been_made + expect(a_post("/1.1/direct_messages/destroy.json"). + with(:body => {:id => "1825785544"})). + to have_been_made end it "returns an array of deleted messages" do direct_messages = @client.direct_message_destroy(1825785544) - direct_messages.should be_an Array - direct_messages.first.should be_a Twitter::DirectMessage - direct_messages.first.sender.id.should eq 7505382 + expect(direct_messages).to be_an Array + expect(direct_messages.first).to be_a Twitter::DirectMessage + expect(direct_messages.first.sender.id).to eq 7505382 end end @@ -70,14 +70,14 @@ end it "requests the correct resource" do @client.direct_message_create("pengwynn", "Creating a fixture for the Twitter gem") - a_post("/1.1/direct_messages/new.json"). - with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem"}). - should have_been_made + expect(a_post("/1.1/direct_messages/new.json"). + with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem"})). + to have_been_made end it "returns the sent message" do direct_message = @client.direct_message_create("pengwynn", "Creating a fixture for the Twitter gem") - direct_message.should be_a Twitter::DirectMessage - direct_message.text.should eq "Creating a fixture for the Twitter gem" + expect(direct_message).to be_a Twitter::DirectMessage + expect(direct_message.text).to eq "Creating a fixture for the Twitter gem" end end @@ -89,14 +89,14 @@ end it "requests the correct resource" do @client.direct_message(1825786345) - a_get("/1.1/direct_messages/show.json"). - with(:query => {:id => "1825786345"}). - should have_been_made + expect(a_get("/1.1/direct_messages/show.json"). + with(:query => {:id => "1825786345"})). + to have_been_made end it "returns the specified direct message" do direct_message = @client.direct_message(1825786345) - direct_message.should be_a Twitter::DirectMessage - direct_message.sender.id.should eq 7505382 + expect(direct_message).to be_a Twitter::DirectMessage + expect(direct_message.sender.id).to eq 7505382 end end @@ -109,15 +109,15 @@ end it "requests the correct resource" do @client.direct_messages(1825786345) - a_get("/1.1/direct_messages/show.json"). - with(:query => {:id => "1825786345"}). - should have_been_made + expect(a_get("/1.1/direct_messages/show.json"). + with(:query => {:id => "1825786345"})). + to have_been_made end it "returns an array of direct messages" do direct_messages = @client.direct_messages(1825786345) - direct_messages.should be_an Array - direct_messages.first.should be_a Twitter::DirectMessage - direct_messages.first.sender.id.should eq 7505382 + expect(direct_messages).to be_an Array + expect(direct_messages.first).to be_a Twitter::DirectMessage + expect(direct_messages.first.sender.id).to eq 7505382 end end context "without ids passed" do @@ -127,14 +127,14 @@ end it "requests the correct resource" do @client.direct_messages - a_get("/1.1/direct_messages.json"). - should have_been_made + expect(a_get("/1.1/direct_messages.json")). + to have_been_made end it "returns the 20 most recent direct messages sent to the authenticating user" do direct_messages = @client.direct_messages - direct_messages.should be_an Array - direct_messages.first.should be_a Twitter::DirectMessage - direct_messages.first.sender.id.should eq 7505382 + expect(direct_messages).to be_an Array + expect(direct_messages.first).to be_a Twitter::DirectMessage + expect(direct_messages.first.sender.id).to eq 7505382 end end end diff --git a/spec/twitter/api/friendships_spec.rb b/spec/twitter/api/friendships_spec.rb index 82c2c5730..d02b99eae 100644 --- a/spec/twitter/api/friendships_spec.rb +++ b/spec/twitter/api/friendships_spec.rb @@ -15,15 +15,15 @@ end it "requests the correct resource" do @client.follower_ids("sferik") - a_get("/1.1/followers/ids.json"). - with(:query => {:cursor => "-1", :screen_name => "sferik"}). - should have_been_made + expect(a_get("/1.1/followers/ids.json"). + with(:query => {:cursor => "-1", :screen_name => "sferik"})). + to have_been_made end it "returns an array of numeric IDs for every user following the specified user" do follower_ids = @client.follower_ids("sferik") - follower_ids.should be_a Twitter::Cursor - follower_ids.ids.should be_an Array - follower_ids.ids.first.should eq 14100886 + expect(follower_ids).to be_a Twitter::Cursor + expect(follower_ids.ids).to be_an Array + expect(follower_ids.ids.first).to eq 14100886 end end context "without arguments passed" do @@ -34,15 +34,15 @@ end it "requests the correct resource" do @client.follower_ids - a_get("/1.1/followers/ids.json"). - with(:query => {:cursor => "-1"}). - should have_been_made + expect(a_get("/1.1/followers/ids.json"). + with(:query => {:cursor => "-1"})). + to have_been_made end it "returns an array of numeric IDs for every user following the specified user" do follower_ids = @client.follower_ids - follower_ids.should be_a Twitter::Cursor - follower_ids.ids.should be_an Array - follower_ids.ids.first.should eq 14100886 + expect(follower_ids).to be_a Twitter::Cursor + expect(follower_ids.ids).to be_an Array + expect(follower_ids.ids.first).to eq 14100886 end end end @@ -56,15 +56,15 @@ end it "requests the correct resource" do @client.friend_ids("sferik") - a_get("/1.1/friends/ids.json"). - with(:query => {:cursor => "-1", :screen_name => "sferik"}). - should have_been_made + expect(a_get("/1.1/friends/ids.json"). + with(:query => {:cursor => "-1", :screen_name => "sferik"})). + to have_been_made end it "returns an array of numeric IDs for every user the specified user is following" do friend_ids = @client.friend_ids("sferik") - friend_ids.should be_a Twitter::Cursor - friend_ids.ids.should be_an Array - friend_ids.ids.first.should eq 14100886 + expect(friend_ids).to be_a Twitter::Cursor + expect(friend_ids.ids).to be_an Array + expect(friend_ids.ids.first).to eq 14100886 end end context "without arguments passed" do @@ -75,15 +75,15 @@ end it "requests the correct resource" do @client.friend_ids - a_get("/1.1/friends/ids.json"). - with(:query => {:cursor => "-1"}). - should have_been_made + expect(a_get("/1.1/friends/ids.json"). + with(:query => {:cursor => "-1"})). + to have_been_made end it "returns an array of numeric IDs for every user the specified user is following" do friend_ids = @client.friend_ids - friend_ids.should be_a Twitter::Cursor - friend_ids.ids.should be_an Array - friend_ids.ids.first.should eq 14100886 + expect(friend_ids).to be_a Twitter::Cursor + expect(friend_ids.ids).to be_an Array + expect(friend_ids.ids.first).to eq 14100886 end end end @@ -100,17 +100,17 @@ end it "requests the correct resource" do @client.friendship?("sferik", "pengwynn") - a_get("/1.1/friendships/show.json"). - with(:query => {:source_screen_name => "sferik", :target_screen_name => "pengwynn"}). - should have_been_made + expect(a_get("/1.1/friendships/show.json"). + with(:query => {:source_screen_name => "sferik", :target_screen_name => "pengwynn"})). + to have_been_made end it "returns true if user A follows user B" do friendship = @client.friendship?("sferik", "pengwynn") - friendship.should be_true + expect(friendship).to be_truthy end it "returns false if user A does not follow user B" do friendship = @client.friendship?("pengwynn", "sferik") - friendship.should be_false + expect(friendship).to be_falsey end end context "with user IDs passed" do @@ -121,9 +121,9 @@ end it "requests the correct resource" do @client.friendship?(7505382, 14100886) - a_get("/1.1/friendships/show.json"). - with(:query => {:source_id => "7505382", :target_id => "14100886"}). - should have_been_made + expect(a_get("/1.1/friendships/show.json"). + with(:query => {:source_id => "7505382", :target_id => "14100886"})). + to have_been_made end end context "with user objects passed" do @@ -136,9 +136,9 @@ user1 = Twitter::User.new(:id => '7505382') user2 = Twitter::User.new(:id => '14100886') @client.friendship?(user1, user2) - a_get("/1.1/friendships/show.json"). - with(:query => {:source_id => "7505382", :target_id => "14100886"}). - should have_been_made + expect(a_get("/1.1/friendships/show.json"). + with(:query => {:source_id => "7505382", :target_id => "14100886"})). + to have_been_made end end end @@ -151,15 +151,15 @@ end it "requests the correct resource" do @client.friendships_incoming - a_get("/1.1/friendships/incoming.json"). - with(:query => {:cursor => "-1"}). - should have_been_made + expect(a_get("/1.1/friendships/incoming.json"). + with(:query => {:cursor => "-1"})). + to have_been_made end it "returns an array of numeric IDs for every user who has a pending request to follow the authenticating user" do friendships_incoming = @client.friendships_incoming - friendships_incoming.should be_a Twitter::Cursor - friendships_incoming.ids.should be_an Array - friendships_incoming.ids.first.should eq 14100886 + expect(friendships_incoming).to be_a Twitter::Cursor + expect(friendships_incoming.ids).to be_an Array + expect(friendships_incoming.ids.first).to eq 14100886 end end @@ -171,15 +171,15 @@ end it "requests the correct resource" do @client.friendships_outgoing - a_get("/1.1/friendships/outgoing.json"). - with(:query => {:cursor => "-1"}). - should have_been_made + expect(a_get("/1.1/friendships/outgoing.json"). + with(:query => {:cursor => "-1"})). + to have_been_made end it "returns an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request" do friendships_outgoing = @client.friendships_outgoing - friendships_outgoing.should be_a Twitter::Cursor - friendships_outgoing.ids.should be_an Array - friendships_outgoing.ids.first.should eq 14100886 + expect(friendships_outgoing).to be_a Twitter::Cursor + expect(friendships_outgoing.ids).to be_an Array + expect(friendships_outgoing.ids.first).to eq 14100886 end end @@ -192,14 +192,14 @@ end it "requests the correct resource" do @client.friendship("sferik", "pengwynn") - a_get("/1.1/friendships/show.json"). - with(:query => {:source_screen_name => "sferik", :target_screen_name => "pengwynn"}). - should have_been_made + expect(a_get("/1.1/friendships/show.json"). + with(:query => {:source_screen_name => "sferik", :target_screen_name => "pengwynn"})). + to have_been_made end it "returns detailed information about the relationship between two users" do relationship = @client.friendship("sferik", "pengwynn") - relationship.should be_a Twitter::Relationship - relationship.source.id.should eq 7505382 + expect(relationship).to be_a Twitter::Relationship + expect(relationship.source.id).to eq 7505382 end end context "with numeric screen names passed" do @@ -210,9 +210,9 @@ end it "requests the correct resource" do @client.friendship("0", "311") - a_get("/1.1/friendships/show.json"). - with(:query => {:source_screen_name => "0", :target_screen_name => "311"}). - should have_been_made + expect(a_get("/1.1/friendships/show.json"). + with(:query => {:source_screen_name => "0", :target_screen_name => "311"})). + to have_been_made end end context "with user IDs passed" do @@ -223,9 +223,9 @@ end it "requests the correct resource" do @client.friendship(7505382, 14100886) - a_get("/1.1/friendships/show.json"). - with(:query => {:source_id => "7505382", :target_id => "14100886"}). - should have_been_made + expect(a_get("/1.1/friendships/show.json"). + with(:query => {:source_id => "7505382", :target_id => "14100886"})). + to have_been_made end end context "with user objects passed" do @@ -238,9 +238,9 @@ user1 = Twitter::User.new(:id => '7505382') user2 = Twitter::User.new(:id => '14100886') @client.friendship(user1, user2) - a_get("/1.1/friendships/show.json"). - with(:query => {:source_id => "7505382", :target_id => "14100886"}). - should have_been_made + expect(a_get("/1.1/friendships/show.json"). + with(:query => {:source_id => "7505382", :target_id => "14100886"})). + to have_been_made end end end @@ -260,21 +260,21 @@ end it "requests the correct resource" do @client.follow("sferik", "pengwynn", :follow => true) - a_get("/1.1/friends/ids.json"). - with(:query => {:cursor => "-1"}). - should have_been_made - a_post("/1.1/users/lookup.json"). - with(:body => {:screen_name => "sferik,pengwynn"}). - should have_been_made - a_post("/1.1/friendships/create.json"). - with(:body => {:user_id => "7505382", :follow => "true"}). - should have_been_made + expect(a_get("/1.1/friends/ids.json"). + with(:query => {:cursor => "-1"})). + to have_been_made + expect(a_post("/1.1/users/lookup.json"). + with(:body => {:screen_name => "sferik,pengwynn"})). + to have_been_made + expect(a_post("/1.1/friendships/create.json"). + with(:body => {:user_id => "7505382", :follow => "true"})). + to have_been_made end it "returns an array of befriended users" do users = @client.follow("sferik", "pengwynn", :follow => true) - users.should be_an Array - users.first.should be_a Twitter::User - users.first.id.should eq 7505382 + expect(users).to be_an Array + expect(users.first).to be_a Twitter::User + expect(users.first.id).to eq 7505382 end end context "with :follow => false passed" do @@ -291,21 +291,21 @@ end it "requests the correct resource" do @client.follow("sferik", "pengwynn", :follow => false) - a_get("/1.1/friends/ids.json"). - with(:query => {:cursor => "-1"}). - should have_been_made - a_post("/1.1/users/lookup.json"). - with(:body => {:screen_name => "sferik,pengwynn"}). - should have_been_made - a_post("/1.1/friendships/create.json"). - with(:body => {:user_id => "7505382"}). - should have_been_made + expect(a_get("/1.1/friends/ids.json"). + with(:query => {:cursor => "-1"})). + to have_been_made + expect(a_post("/1.1/users/lookup.json"). + with(:body => {:screen_name => "sferik,pengwynn"})). + to have_been_made + expect(a_post("/1.1/friendships/create.json"). + with(:body => {:user_id => "7505382"})). + to have_been_made end it "returns an array of befriended users" do users = @client.follow("sferik", "pengwynn", :follow => false) - users.should be_an Array - users.first.should be_a Twitter::User - users.first.id.should eq 7505382 + expect(users).to be_an Array + expect(users.first).to be_a Twitter::User + expect(users.first.id).to eq 7505382 end end context "without :follow passed" do @@ -322,21 +322,21 @@ end it "requests the correct resource" do @client.follow("sferik", "pengwynn") - a_get("/1.1/friends/ids.json"). - with(:query => {:cursor => "-1"}). - should have_been_made - a_post("/1.1/users/lookup.json"). - with(:body => {:screen_name => "sferik,pengwynn"}). - should have_been_made - a_post("/1.1/friendships/create.json"). - with(:body => {:user_id => "7505382"}). - should have_been_made + expect(a_get("/1.1/friends/ids.json"). + with(:query => {:cursor => "-1"})). + to have_been_made + expect(a_post("/1.1/users/lookup.json"). + with(:body => {:screen_name => "sferik,pengwynn"})). + to have_been_made + expect(a_post("/1.1/friendships/create.json"). + with(:body => {:user_id => "7505382"})). + to have_been_made end it "returns an array of befriended users" do users = @client.follow("sferik", "pengwynn") - users.should be_an Array - users.first.should be_a Twitter::User - users.first.id.should eq 7505382 + expect(users).to be_an Array + expect(users.first).to be_a Twitter::User + expect(users.first.id).to eq 7505382 end end end @@ -350,15 +350,15 @@ end it "requests the correct resource" do @client.follow!("sferik", :follow => true) - a_post("/1.1/friendships/create.json"). - with(:body => {:screen_name => "sferik", :follow => "true"}). - should have_been_made + expect(a_post("/1.1/friendships/create.json"). + with(:body => {:screen_name => "sferik", :follow => "true"})). + to have_been_made end it "returns an array of befriended users" do users = @client.follow!("sferik", :follow => true) - users.should be_an Array - users.first.should be_a Twitter::User - users.first.id.should eq 7505382 + expect(users).to be_an Array + expect(users.first).to be_a Twitter::User + expect(users.first.id).to eq 7505382 end end context "with :follow => false passed" do @@ -369,15 +369,15 @@ end it "requests the correct resource" do @client.follow!("sferik", :follow => false) - a_post("/1.1/friendships/create.json"). - with(:body => {:screen_name => "sferik"}). - should have_been_made + expect(a_post("/1.1/friendships/create.json"). + with(:body => {:screen_name => "sferik"})). + to have_been_made end it "returns an array of befriended users" do users = @client.follow!("sferik", :follow => false) - users.should be_an Array - users.first.should be_a Twitter::User - users.first.id.should eq 7505382 + expect(users).to be_an Array + expect(users.first).to be_a Twitter::User + expect(users.first.id).to eq 7505382 end end context "without :follow passed" do @@ -388,15 +388,15 @@ end it "requests the correct resource" do @client.follow!("sferik") - a_post("/1.1/friendships/create.json"). - with(:body => {:screen_name => "sferik"}). - should have_been_made + expect(a_post("/1.1/friendships/create.json"). + with(:body => {:screen_name => "sferik"})). + to have_been_made end it "returns an array of befriended users" do users = @client.follow!("sferik") - users.should be_an Array - users.first.should be_a Twitter::User - users.first.id.should eq 7505382 + expect(users).to be_an Array + expect(users.first).to be_a Twitter::User + expect(users.first.id).to eq 7505382 end end end @@ -409,15 +409,15 @@ end it "requests the correct resource" do @client.unfollow("sferik") - a_post("/1.1/friendships/destroy.json"). - with(:body => {:screen_name => "sferik"}). - should have_been_made + expect(a_post("/1.1/friendships/destroy.json"). + with(:body => {:screen_name => "sferik"})). + to have_been_made end it "returns an array of unfollowed users" do users = @client.friendship_destroy("sferik") - users.should be_an Array - users.first.should be_a Twitter::User - users.first.id.should eq 7505382 + expect(users).to be_an Array + expect(users.first).to be_a Twitter::User + expect(users.first.id).to eq 7505382 end end @@ -430,16 +430,16 @@ end it "requests the correct resource" do @client.friendships("sferik", "pengwynn") - a_get("/1.1/friendships/lookup.json"). - with(:query => {:screen_name => "sferik,pengwynn"}). - should have_been_made + expect(a_get("/1.1/friendships/lookup.json"). + with(:query => {:screen_name => "sferik,pengwynn"})). + to have_been_made end it "returns up to 100 users worth of extended information" do friendships = @client.friendships("sferik", "pengwynn") - friendships.should be_an Array - friendships.first.should be_a Twitter::User - friendships.first.id.should eq 7505382 - friendships.first.connections.should eq ["none"] + expect(friendships).to be_an Array + expect(friendships.first).to be_a Twitter::User + expect(friendships.first.id).to eq 7505382 + expect(friendships.first.connections).to eq ["none"] end end context "with numeric screen names passed" do @@ -450,9 +450,9 @@ end it "requests the correct resource" do @client.friendships("0", "311") - a_get("/1.1/friendships/lookup.json"). - with(:query => {:screen_name => "0,311"}). - should have_been_made + expect(a_get("/1.1/friendships/lookup.json"). + with(:query => {:screen_name => "0,311"})). + to have_been_made end end context "with user IDs passed" do @@ -463,9 +463,9 @@ end it "requests the correct resource" do @client.friendships(7505382, 14100886) - a_get("/1.1/friendships/lookup.json"). - with(:query => {:user_id => "7505382,14100886"}). - should have_been_made + expect(a_get("/1.1/friendships/lookup.json"). + with(:query => {:user_id => "7505382,14100886"})). + to have_been_made end end context "with both screen names and user IDs passed" do @@ -476,9 +476,9 @@ end it "requests the correct resource" do @client.friendships("sferik", 14100886) - a_get("/1.1/friendships/lookup.json"). - with(:query => {:screen_name => "sferik", :user_id => "14100886"}). - should have_been_made + expect(a_get("/1.1/friendships/lookup.json"). + with(:query => {:screen_name => "sferik", :user_id => "14100886"})). + to have_been_made end end end @@ -492,16 +492,16 @@ end it "requests the correct resource" do @client.friendships("sferik", "pengwynn") - a_get("/1.1/friendships/lookup.json"). - with(:query => {:screen_name => "sferik,pengwynn"}). - should have_been_made + expect(a_get("/1.1/friendships/lookup.json"). + with(:query => {:screen_name => "sferik,pengwynn"})). + to have_been_made end it "returns up to 100 users worth of extended information" do friendships = @client.friendships("sferik", "pengwynn") - friendships.should be_an Array - friendships.first.should be_a Twitter::User - friendships.first.id.should eq 7505382 - friendships.first.connections.should eq ["none"] + expect(friendships).to be_an Array + expect(friendships.first).to be_a Twitter::User + expect(friendships.first.id).to eq 7505382 + expect(friendships.first.connections).to eq ["none"] end end context "with numeric screen names passed" do @@ -512,9 +512,9 @@ end it "requests the correct resource" do @client.friendships("0", "311") - a_get("/1.1/friendships/lookup.json"). - with(:query => {:screen_name => "0,311"}). - should have_been_made + expect(a_get("/1.1/friendships/lookup.json"). + with(:query => {:screen_name => "0,311"})). + to have_been_made end end context "with user IDs passed" do @@ -525,9 +525,9 @@ end it "requests the correct resource" do @client.friendships(7505382, 14100886) - a_get("/1.1/friendships/lookup.json"). - with(:query => {:user_id => "7505382,14100886"}). - should have_been_made + expect(a_get("/1.1/friendships/lookup.json"). + with(:query => {:user_id => "7505382,14100886"})). + to have_been_made end end context "with both screen names and user IDs passed" do @@ -538,9 +538,9 @@ end it "requests the correct resource" do @client.friendships("sferik", 14100886) - a_get("/1.1/friendships/lookup.json"). - with(:query => {:screen_name => "sferik", :user_id => "14100886"}). - should have_been_made + expect(a_get("/1.1/friendships/lookup.json"). + with(:query => {:screen_name => "sferik", :user_id => "14100886"})). + to have_been_made end end end @@ -553,14 +553,14 @@ end it "requests the correct resource" do @client.friendship_update("sferik", :retweets => true) - a_post("/1.1/friendships/update.json"). - with(:body => {:screen_name => "sferik", :retweets => "true"}). - should have_been_made + expect(a_post("/1.1/friendships/update.json"). + with(:body => {:screen_name => "sferik", :retweets => "true"})). + to have_been_made end it "returns detailed information about the relationship between two users" do relationship = @client.friendship_update("sferik", :retweets => true) - relationship.should be_a Twitter::Relationship - relationship.source.id.should eq 7505382 + expect(relationship).to be_a Twitter::Relationship + expect(relationship.source.id).to eq 7505382 end end diff --git a/spec/twitter/api/geo_spec.rb b/spec/twitter/api/geo_spec.rb index 5bea92d31..14b021ac7 100644 --- a/spec/twitter/api/geo_spec.rb +++ b/spec/twitter/api/geo_spec.rb @@ -14,14 +14,14 @@ end it "requests the correct resource" do @client.places_nearby(:ip => "74.125.19.104") - a_get("/1.1/geo/search.json"). - with(:query => {:ip => "74.125.19.104"}). - should have_been_made + expect(a_get("/1.1/geo/search.json"). + with(:query => {:ip => "74.125.19.104"})). + to have_been_made end it "returns nearby places" do places = @client.places_nearby(:ip => "74.125.19.104") - places.should be_an Array - places.first.name.should eq "Bernal Heights" + expect(places).to be_an Array + expect(places.first.name).to eq "Bernal Heights" end end @@ -33,14 +33,14 @@ end it "requests the correct resource" do @client.places_similar(:lat => "37.7821120598956", :long => "-122.400612831116", :name => "Twitter HQ") - a_get("/1.1/geo/similar_places.json"). - with(:query => {:lat => "37.7821120598956", :long => "-122.400612831116", :name => "Twitter HQ"}). - should have_been_made + expect(a_get("/1.1/geo/similar_places.json"). + with(:query => {:lat => "37.7821120598956", :long => "-122.400612831116", :name => "Twitter HQ"})). + to have_been_made end it "returns similar places" do places = @client.places_similar(:lat => "37.7821120598956", :long => "-122.400612831116", :name => "Twitter HQ") - places.should be_an Array - places.first.name.should eq "Bernal Heights" + expect(places).to be_an Array + expect(places.first.name).to eq "Bernal Heights" end end @@ -52,14 +52,14 @@ end it "requests the correct resource" do @client.reverse_geocode(:lat => "37.7821120598956", :long => "-122.400612831116") - a_get("/1.1/geo/reverse_geocode.json"). - with(:query => {:lat => "37.7821120598956", :long => "-122.400612831116"}). - should have_been_made + expect(a_get("/1.1/geo/reverse_geocode.json"). + with(:query => {:lat => "37.7821120598956", :long => "-122.400612831116"})). + to have_been_made end it "returns places" do places = @client.reverse_geocode(:lat => "37.7821120598956", :long => "-122.400612831116") - places.should be_an Array - places.first.name.should eq "Bernal Heights" + expect(places).to be_an Array + expect(places.first.name).to eq "Bernal Heights" end end @@ -70,12 +70,12 @@ end it "requests the correct resource" do @client.place("247f43d441defc03") - a_get("/1.1/geo/id/247f43d441defc03.json"). - should have_been_made + expect(a_get("/1.1/geo/id/247f43d441defc03.json")). + to have_been_made end it "returns a place" do place = @client.place("247f43d441defc03") - place.name.should eq "Twitter HQ" + expect(place.name).to eq "Twitter HQ" end end @@ -87,13 +87,13 @@ end it "requests the correct resource" do @client.place_create(:name => "@sferik's Apartment", :token => "22ff5b1f7159032cf69218c4d8bb78bc", :contained_within => "41bcb736f84a799e", :lat => "37.783699", :long => "-122.393581") - a_post("/1.1/geo/place.json"). - with(:body => {:name => "@sferik's Apartment", :token => "22ff5b1f7159032cf69218c4d8bb78bc", :contained_within => "41bcb736f84a799e", :lat => "37.783699", :long => "-122.393581"}). - should have_been_made + expect(a_post("/1.1/geo/place.json"). + with(:body => {:name => "@sferik's Apartment", :token => "22ff5b1f7159032cf69218c4d8bb78bc", :contained_within => "41bcb736f84a799e", :lat => "37.783699", :long => "-122.393581"})). + to have_been_made end it "returns a place" do place = @client.place_create(:name => "@sferik's Apartment", :token => "22ff5b1f7159032cf69218c4d8bb78bc", :contained_within => "41bcb736f84a799e", :lat => "37.783699", :long => "-122.393581") - place.name.should eq "Twitter HQ" + expect(place.name).to eq "Twitter HQ" end end diff --git a/spec/twitter/api/help_spec.rb b/spec/twitter/api/help_spec.rb index 9a012de60..bad701276 100644 --- a/spec/twitter/api/help_spec.rb +++ b/spec/twitter/api/help_spec.rb @@ -13,13 +13,13 @@ end it "requests the correct resource" do @client.configuration - a_get("/1.1/help/configuration.json"). - should have_been_made + expect(a_get("/1.1/help/configuration.json")). + to have_been_made end it "returns Twitter's current configuration" do configuration = @client.configuration - configuration.should be_a Twitter::Configuration - configuration.characters_reserved_per_media.should eq 20 + expect(configuration).to be_a Twitter::Configuration + expect(configuration.characters_reserved_per_media).to eq 20 end end @@ -30,14 +30,14 @@ end it "requests the correct resource" do @client.languages - a_get("/1.1/help/languages.json"). - should have_been_made + expect(a_get("/1.1/help/languages.json")). + to have_been_made end it "returns the list of languages supported by Twitter" do languages = @client.languages - languages.should be_an Array - languages.first.should be_a Twitter::Language - languages.first.name.should eq "Portuguese" + expect(languages).to be_an Array + expect(languages.first).to be_a Twitter::Language + expect(languages.first.name).to eq "Portuguese" end end @@ -48,12 +48,12 @@ end it "requests the correct resource" do @client.privacy - a_get("/1.1/help/privacy.json"). - should have_been_made + expect(a_get("/1.1/help/privacy.json")). + to have_been_made end it "returns Twitter's Privacy Policy" do privacy = @client.privacy - privacy.split.first.should eq "Twitter" + expect(privacy.split.first).to eq "Twitter" end end @@ -64,12 +64,12 @@ end it "requests the correct resource" do @client.tos - a_get("/1.1/help/tos.json"). - should have_been_made + expect(a_get("/1.1/help/tos.json")). + to have_been_made end it "returns Twitter's Terms of Service" do tos = @client.tos - tos.split.first.should eq "Terms" + expect(tos.split.first).to eq "Terms" end end diff --git a/spec/twitter/api/lists_spec.rb b/spec/twitter/api/lists_spec.rb index 3069a1b2d..3620b8a0f 100644 --- a/spec/twitter/api/lists_spec.rb +++ b/spec/twitter/api/lists_spec.rb @@ -15,15 +15,15 @@ end it "requests the correct resource" do @client.list_timeline("sferik", "presidents") - a_get("/1.1/lists/statuses.json"). - with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}). - should have_been_made + expect(a_get("/1.1/lists/statuses.json"). + with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'})). + to have_been_made end it "returns the timeline for members of the specified list" do tweets = @client.list_timeline("sferik", "presidents") - tweets.should be_an Array - tweets.first.should be_a Twitter::Tweet - tweets.first.text.should eq "Happy Birthday @imdane. Watch out for those @rally pranksters!" + expect(tweets).to be_an Array + expect(tweets.first).to be_a Twitter::Tweet + expect(tweets.first.text).to eq "Happy Birthday @imdane. Watch out for those @rally pranksters!" end end context "without a screen name passed" do @@ -36,9 +36,9 @@ end it "requests the correct resource" do @client.list_timeline("presidents") - a_get("/1.1/lists/statuses.json"). - with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}). - should have_been_made + expect(a_get("/1.1/lists/statuses.json"). + with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'})). + to have_been_made end end end @@ -52,14 +52,14 @@ end it "requests the correct resource" do @client.list_remove_member("sferik", "presidents", 813286) - a_post("/1.1/lists/members/destroy.json"). - with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286"}). - should have_been_made + expect(a_post("/1.1/lists/members/destroy.json"). + with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286"})). + to have_been_made end it "returns the list" do list = @client.list_remove_member("sferik", "presidents", 813286) - list.should be_a Twitter::List - list.name.should eq "presidents" + expect(list).to be_a Twitter::List + expect(list.name).to eq "presidents" end end context "without a screen name passed" do @@ -72,9 +72,9 @@ end it "requests the correct resource" do @client.list_remove_member("presidents", 813286) - a_post("/1.1/lists/members/destroy.json"). - with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286"}). - should have_been_made + expect(a_post("/1.1/lists/members/destroy.json"). + with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286"})). + to have_been_made end end end @@ -88,16 +88,16 @@ end it "requests the correct resource" do @client.memberships("pengwynn") - a_get("/1.1/lists/memberships.json"). - with(:query => {:screen_name => 'pengwynn', :cursor => "-1"}). - should have_been_made + expect(a_get("/1.1/lists/memberships.json"). + with(:query => {:screen_name => 'pengwynn', :cursor => "-1"})). + to have_been_made end it "returns the lists the specified user has been added to" do memberships = @client.memberships("pengwynn") - memberships.should be_a Twitter::Cursor - memberships.lists.should be_an Array - memberships.lists.first.should be_a Twitter::List - memberships.lists.first.name.should eq "developer" + expect(memberships).to be_a Twitter::Cursor + expect(memberships.lists).to be_an Array + expect(memberships.lists.first).to be_a Twitter::List + expect(memberships.lists.first.name).to eq "developer" end end context "without a screen name passed" do @@ -110,9 +110,9 @@ end it "requests the correct resource" do @client.memberships - a_get("/1.1/lists/memberships.json"). - with(:query => {:cursor => "-1"}). - should have_been_made + expect(a_get("/1.1/lists/memberships.json"). + with(:query => {:cursor => "-1"})). + to have_been_made end end end @@ -126,16 +126,16 @@ end it "requests the correct resource" do @client.list_subscribers("sferik", "presidents") - a_get("/1.1/lists/subscribers.json"). - with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => "-1"}). - should have_been_made + expect(a_get("/1.1/lists/subscribers.json"). + with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => "-1"})). + to have_been_made end it "returns the subscribers of the specified list" do list_subscribers = @client.list_subscribers("sferik", "presidents") - list_subscribers.should be_a Twitter::Cursor - list_subscribers.users.should be_an Array - list_subscribers.users.first.should be_a Twitter::User - list_subscribers.users.first.id.should eq 7505382 + expect(list_subscribers).to be_a Twitter::Cursor + expect(list_subscribers.users).to be_an Array + expect(list_subscribers.users.first).to be_a Twitter::User + expect(list_subscribers.users.first.id).to eq 7505382 end end context "without a screen name passed" do @@ -148,9 +148,9 @@ end it "requests the correct resource" do @client.list_subscribers("presidents") - a_get("/1.1/lists/subscribers.json"). - with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => "-1"}). - should have_been_made + expect(a_get("/1.1/lists/subscribers.json"). + with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => "-1"})). + to have_been_made end end end @@ -164,16 +164,16 @@ end it "requests the correct resource" do @client.subscriptions("pengwynn") - a_get("/1.1/lists/subscriptions.json"). - with(:query => {:screen_name => 'pengwynn', :cursor => "-1"}). - should have_been_made + expect(a_get("/1.1/lists/subscriptions.json"). + with(:query => {:screen_name => 'pengwynn', :cursor => "-1"})). + to have_been_made end it "returns the lists the specified user follows" do subscriptions = @client.subscriptions("pengwynn") - subscriptions.should be_a Twitter::Cursor - subscriptions.lists.should be_an Array - subscriptions.lists.first.should be_a Twitter::List - subscriptions.lists.first.name.should eq "Rubyists" + expect(subscriptions).to be_a Twitter::Cursor + expect(subscriptions.lists).to be_an Array + expect(subscriptions.lists.first).to be_a Twitter::List + expect(subscriptions.lists.first.name).to eq "Rubyists" end end context "without a screen name passed" do @@ -186,9 +186,9 @@ end it "requests the correct resource" do @client.subscriptions - a_get("/1.1/lists/subscriptions.json"). - with(:query => {:cursor => "-1"}). - should have_been_made + expect(a_get("/1.1/lists/subscriptions.json"). + with(:query => {:cursor => "-1"})). + to have_been_made end end end @@ -202,14 +202,14 @@ end it "requests the correct resource" do @client.list_subscribe("sferik", "presidents") - a_post("/1.1/lists/subscribers/create.json"). - with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}). - should have_been_made + expect(a_post("/1.1/lists/subscribers/create.json"). + with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'})). + to have_been_made end it "returns the specified list" do list = @client.list_subscribe("sferik", "presidents") - list.should be_a Twitter::List - list.name.should eq "presidents" + expect(list).to be_a Twitter::List + expect(list.name).to eq "presidents" end end context "without a screen name passed" do @@ -222,9 +222,9 @@ end it "requests the correct resource" do @client.list_subscribe("presidents") - a_post("/1.1/lists/subscribers/create.json"). - with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}). - should have_been_made + expect(a_post("/1.1/lists/subscribers/create.json"). + with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'})). + to have_been_made end end end @@ -244,21 +244,21 @@ end it "requests the correct resource" do @client.list_subscriber?("sferik", "presidents", 813286) - a_get("/1.1/lists/subscribers/show.json"). - with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}). - should have_been_made + expect(a_get("/1.1/lists/subscribers/show.json"). + with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'})). + to have_been_made end it "returns true if the specified user subscribes to the specified list" do list_subscriber = @client.list_subscriber?("sferik", "presidents", 813286) - list_subscriber.should be_true + expect(list_subscriber).to be_truthy end it "returns false if the specified user does not subscribe to the specified list" do list_subscriber = @client.list_subscriber?("sferik", "presidents", 18755393) - list_subscriber.should be_false + expect(list_subscriber).to be_falsey end it "returns false if user does not exist" do list_subscriber = @client.list_subscriber?("sferik", "presidents", 12345678) - list_subscriber.should be_false + expect(list_subscriber).to be_falsey end end context "with a owner ID passed" do @@ -269,9 +269,9 @@ end it "requests the correct resource" do @client.list_subscriber?(12345678, "presidents", 813286) - a_get("/1.1/lists/subscribers/show.json"). - with(:query => {:owner_id => '12345678', :slug => 'presidents', :user_id => '813286'}). - should have_been_made + expect(a_get("/1.1/lists/subscribers/show.json"). + with(:query => {:owner_id => '12345678', :slug => 'presidents', :user_id => '813286'})). + to have_been_made end end context "with a list ID passed" do @@ -282,9 +282,9 @@ end it "requests the correct resource" do @client.list_subscriber?('sferik', 12345678, 813286) - a_get("/1.1/lists/subscribers/show.json"). - with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => '813286'}). - should have_been_made + expect(a_get("/1.1/lists/subscribers/show.json"). + with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => '813286'})). + to have_been_made end end context "with a list object passed" do @@ -296,9 +296,9 @@ it "requests the correct resource" do list = Twitter::List.new(:id => 12345678, :user => {:id => 7505382, :screen_name => 'sferik'}) @client.list_subscriber?(list, 813286) - a_get("/1.1/lists/subscribers/show.json"). - with(:query => {:owner_id => '7505382', :list_id => '12345678', :user_id => '813286'}). - should have_been_made + expect(a_get("/1.1/lists/subscribers/show.json"). + with(:query => {:owner_id => '7505382', :list_id => '12345678', :user_id => '813286'})). + to have_been_made end end context "with a screen name passed for user_to_check" do @@ -309,9 +309,9 @@ end it "requests the correct resource" do @client.list_subscriber?("sferik", "presidents", 'erebor') - a_get("/1.1/lists/subscribers/show.json"). - with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :screen_name => 'erebor'}). - should have_been_made + expect(a_get("/1.1/lists/subscribers/show.json"). + with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :screen_name => 'erebor'})). + to have_been_made end end context "without a screen name passed" do @@ -324,9 +324,9 @@ end it "requests the correct resource" do @client.list_subscriber?("presidents", 813286) - a_get("/1.1/lists/subscribers/show.json"). - with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}). - should have_been_made + expect(a_get("/1.1/lists/subscribers/show.json"). + with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'})). + to have_been_made end end end @@ -340,14 +340,14 @@ end it "requests the correct resource" do @client.list_unsubscribe("sferik", "presidents") - a_post("/1.1/lists/subscribers/destroy.json"). - with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}). - should have_been_made + expect(a_post("/1.1/lists/subscribers/destroy.json"). + with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'})). + to have_been_made end it "returns the specified list" do list = @client.list_unsubscribe("sferik", "presidents") - list.should be_a Twitter::List - list.name.should eq "presidents" + expect(list).to be_a Twitter::List + expect(list.name).to eq "presidents" end end context "without a screen name passed" do @@ -360,9 +360,9 @@ end it "requests the correct resource" do @client.list_unsubscribe("presidents") - a_post("/1.1/lists/subscribers/destroy.json"). - with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}). - should have_been_made + expect(a_post("/1.1/lists/subscribers/destroy.json"). + with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'})). + to have_been_made end end end @@ -376,14 +376,14 @@ end it "requests the correct resource" do @client.list_add_members("sferik", "presidents", [813286, 18755393]) - a_post("/1.1/lists/members/create_all.json"). - with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286,18755393"}). - should have_been_made + expect(a_post("/1.1/lists/members/create_all.json"). + with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286,18755393"})). + to have_been_made end it "returns the list" do list = @client.list_add_members("sferik", "presidents", [813286, 18755393]) - list.should be_a Twitter::List - list.name.should eq "presidents" + expect(list).to be_a Twitter::List + expect(list.name).to eq "presidents" end end context "with a combination of member IDs and member screen names to add" do @@ -394,9 +394,9 @@ end it "requests the correct resource" do @client.list_add_members('sferik', 'presidents', [813286, 'pengwynn', 18755393, 'erebor']) - a_post("/1.1/lists/members/create_all.json"). - with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286,18755393", :screen_name => "pengwynn,erebor"}). - should have_been_made + expect(a_post("/1.1/lists/members/create_all.json"). + with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286,18755393", :screen_name => "pengwynn,erebor"})). + to have_been_made end end context "without a screen name passed" do @@ -409,9 +409,9 @@ end it "requests the correct resource" do @client.list_add_members("presidents", [813286, 18755393]) - a_post("/1.1/lists/members/create_all.json"). - with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286,18755393"}). - should have_been_made + expect(a_post("/1.1/lists/members/create_all.json"). + with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286,18755393"})). + to have_been_made end end end @@ -425,14 +425,14 @@ end it "requests the correct resource" do @client.list_remove_members("sferik", "presidents", [813286, 18755393]) - a_post("/1.1/lists/members/destroy_all.json"). - with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286,18755393"}). - should have_been_made + expect(a_post("/1.1/lists/members/destroy_all.json"). + with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286,18755393"})). + to have_been_made end it "returns the list" do list = @client.list_remove_members("sferik", "presidents", [813286, 18755393]) - list.should be_a Twitter::List - list.name.should eq "presidents" + expect(list).to be_a Twitter::List + expect(list.name).to eq "presidents" end end context "with a combination of member IDs and member screen names to add" do @@ -443,9 +443,9 @@ end it "requests the correct resource" do @client.list_remove_members('sferik', 'presidents', [813286, 'pengwynn', 18755393, 'erebor']) - a_post("/1.1/lists/members/destroy_all.json"). - with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286,18755393", :screen_name => "pengwynn,erebor"}). - should have_been_made + expect(a_post("/1.1/lists/members/destroy_all.json"). + with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286,18755393", :screen_name => "pengwynn,erebor"})). + to have_been_made end end context "without a screen name passed" do @@ -458,9 +458,9 @@ end it "requests the correct resource" do @client.list_remove_members("presidents", [813286, 18755393]) - a_post("/1.1/lists/members/destroy_all.json"). - with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286,18755393"}). - should have_been_made + expect(a_post("/1.1/lists/members/destroy_all.json"). + with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286,18755393"})). + to have_been_made end end end @@ -480,21 +480,21 @@ end it "requests the correct resource" do @client.list_member?("sferik", "presidents", 813286) - a_get("/1.1/lists/members/show.json"). - with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}). - should have_been_made + expect(a_get("/1.1/lists/members/show.json"). + with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'})). + to have_been_made end it "returns true if user is a list member" do list_member = @client.list_member?("sferik", "presidents", 813286) - list_member.should be_true + expect(list_member).to be_truthy end it "returns false if user is not a list member" do list_member = @client.list_member?("sferik", "presidents", 65493023) - list_member.should be_false + expect(list_member).to be_falsey end it "returns false if user does not exist" do list_member = @client.list_member?("sferik", "presidents", 12345678) - list_member.should be_false + expect(list_member).to be_falsey end end context "with an owner ID passed" do @@ -505,9 +505,9 @@ end it "requests the correct resource" do @client.list_member?(12345678, "presidents", 813286) - a_get("/1.1/lists/members/show.json"). - with(:query => {:owner_id => '12345678', :slug => 'presidents', :user_id => '813286'}). - should have_been_made + expect(a_get("/1.1/lists/members/show.json"). + with(:query => {:owner_id => '12345678', :slug => 'presidents', :user_id => '813286'})). + to have_been_made end end context "with a list ID passed" do @@ -518,9 +518,9 @@ end it "requests the correct resource" do @client.list_member?('sferik', 12345678, 813286) - a_get("/1.1/lists/members/show.json"). - with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => '813286'}). - should have_been_made + expect(a_get("/1.1/lists/members/show.json"). + with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => '813286'})). + to have_been_made end end context "with a list object passed" do @@ -532,9 +532,9 @@ it "requests the correct resource" do list = Twitter::List.new(:id => 12345678, :user => {:id => 7505382, :screen_name => 'sferik'}) @client.list_member?(list, 813286) - a_get("/1.1/lists/members/show.json"). - with(:query => {:owner_id => '7505382', :list_id => '12345678', :user_id => '813286'}). - should have_been_made + expect(a_get("/1.1/lists/members/show.json"). + with(:query => {:owner_id => '7505382', :list_id => '12345678', :user_id => '813286'})). + to have_been_made end end context "with a screen name passed for user_to_check" do @@ -545,9 +545,9 @@ end it "requests the correct resource" do @client.list_member?("sferik", "presidents", 'erebor') - a_get("/1.1/lists/members/show.json"). - with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :screen_name => 'erebor'}). - should have_been_made + expect(a_get("/1.1/lists/members/show.json"). + with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :screen_name => 'erebor'})). + to have_been_made end end context "without a screen name passed" do @@ -560,9 +560,9 @@ end it "requests the correct resource" do @client.list_member?("presidents", 813286) - a_get("/1.1/lists/members/show.json"). - with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}). - should have_been_made + expect(a_get("/1.1/lists/members/show.json"). + with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'})). + to have_been_made end end end @@ -576,16 +576,16 @@ end it "requests the correct resource" do @client.list_members("sferik", "presidents") - a_get("/1.1/lists/members.json"). - with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => "-1"}). - should have_been_made + expect(a_get("/1.1/lists/members.json"). + with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => "-1"})). + to have_been_made end it "returns the members of the specified list" do list_members = @client.list_members("sferik", "presidents") - list_members.should be_a Twitter::Cursor - list_members.users.should be_an Array - list_members.users.first.should be_a Twitter::User - list_members.users.first.id.should eq 7505382 + expect(list_members).to be_a Twitter::Cursor + expect(list_members.users).to be_an Array + expect(list_members.users.first).to be_a Twitter::User + expect(list_members.users.first.id).to eq 7505382 end end context "without a screen name passed" do @@ -598,9 +598,9 @@ end it "requests the correct resource" do @client.list_members("presidents") - a_get("/1.1/lists/members.json"). - with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => "-1"}). - should have_been_made + expect(a_get("/1.1/lists/members.json"). + with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => "-1"})). + to have_been_made end end end @@ -614,14 +614,14 @@ end it "requests the correct resource" do @client.list_add_member("sferik", "presidents", 813286) - a_post("/1.1/lists/members/create.json"). - with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286"}). - should have_been_made + expect(a_post("/1.1/lists/members/create.json"). + with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286"})). + to have_been_made end it "returns the list" do list = @client.list_add_member("sferik", "presidents", 813286) - list.should be_a Twitter::List - list.name.should eq "presidents" + expect(list).to be_a Twitter::List + expect(list.name).to eq "presidents" end end context "without a screen name passed" do @@ -634,9 +634,9 @@ end it "requests the correct resource" do @client.list_add_member("presidents", 813286) - a_post("/1.1/lists/members/create.json"). - with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286"}). - should have_been_made + expect(a_post("/1.1/lists/members/create.json"). + with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => "813286"})). + to have_been_made end end end @@ -650,14 +650,14 @@ end it "requests the correct resource" do @client.list_destroy("sferik", "presidents") - a_post("/1.1/lists/destroy.json"). - with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}). - should have_been_made + expect(a_post("/1.1/lists/destroy.json"). + with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'})). + to have_been_made end it "returns the deleted list" do list = @client.list_destroy("sferik", "presidents") - list.should be_a Twitter::List - list.name.should eq "presidents" + expect(list).to be_a Twitter::List + expect(list.name).to eq "presidents" end end context "without a screen name passed" do @@ -670,9 +670,9 @@ end it "requests the correct resource" do @client.list_destroy("presidents") - a_post("/1.1/lists/destroy.json"). - with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}). - should have_been_made + expect(a_post("/1.1/lists/destroy.json"). + with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'})). + to have_been_made end end context "with a list ID passed" do @@ -683,9 +683,9 @@ end it "requests the correct resource" do @client.list_destroy("sferik", 12345678) - a_post("/1.1/lists/destroy.json"). - with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678'}). - should have_been_made + expect(a_post("/1.1/lists/destroy.json"). + with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678'})). + to have_been_made end end context "with a list object passed" do @@ -697,9 +697,9 @@ it "requests the correct resource" do list = Twitter::List.new(:id => '12345678', :user => {:id => 7505382, :screen_name => 'sferik'}) @client.list_destroy(list) - a_post("/1.1/lists/destroy.json"). - with(:body => {:owner_id => '7505382', :list_id => '12345678'}). - should have_been_made + expect(a_post("/1.1/lists/destroy.json"). + with(:body => {:owner_id => '7505382', :list_id => '12345678'})). + to have_been_made end end end @@ -713,14 +713,14 @@ end it "requests the correct resource" do @client.list_update("sferik", "presidents", :description => "Presidents of the United States of America") - a_post("/1.1/lists/update.json"). - with(:body => {:owner_screen_name => 'sferik', :slug => "presidents", :description => "Presidents of the United States of America"}). - should have_been_made + expect(a_post("/1.1/lists/update.json"). + with(:body => {:owner_screen_name => 'sferik', :slug => "presidents", :description => "Presidents of the United States of America"})). + to have_been_made end it "returns the updated list" do list = @client.list_update("sferik", "presidents", :description => "Presidents of the United States of America") - list.should be_a Twitter::List - list.name.should eq "presidents" + expect(list).to be_a Twitter::List + expect(list.name).to eq "presidents" end end context "without a screen name passed" do @@ -733,9 +733,9 @@ end it "requests the correct resource" do @client.list_update("presidents", :description => "Presidents of the United States of America") - a_post("/1.1/lists/update.json"). - with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :description => "Presidents of the United States of America"}). - should have_been_made + expect(a_post("/1.1/lists/update.json"). + with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :description => "Presidents of the United States of America"})). + to have_been_made end end context "with a list ID passed" do @@ -746,9 +746,9 @@ end it "requests the correct resource" do @client.list_update("sferik", 12345678, :description => "Presidents of the United States of America") - a_post("/1.1/lists/update.json"). - with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678', :description => "Presidents of the United States of America"}). - should have_been_made + expect(a_post("/1.1/lists/update.json"). + with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678', :description => "Presidents of the United States of America"})). + to have_been_made end end context "with a list object passed" do @@ -760,9 +760,9 @@ it "requests the correct resource" do list = Twitter::List.new(:id => '12345678', :user => {:id => 7505382, :screen_name => 'sferik'}) @client.list_update(list, :description => "Presidents of the United States of America") - a_post("/1.1/lists/update.json"). - with(:body => {:owner_id => '7505382', :list_id => '12345678', :description => "Presidents of the United States of America"}). - should have_been_made + expect(a_post("/1.1/lists/update.json"). + with(:body => {:owner_id => '7505382', :list_id => '12345678', :description => "Presidents of the United States of America"})). + to have_been_made end end end @@ -775,14 +775,14 @@ end it "requests the correct resource" do @client.list_create("presidents") - a_post("/1.1/lists/create.json"). - with(:body => {:name => "presidents"}). - should have_been_made + expect(a_post("/1.1/lists/create.json"). + with(:body => {:name => "presidents"})). + to have_been_made end it "returns the created list" do list = @client.list_create("presidents") - list.should be_a Twitter::List - list.name.should eq "presidents" + expect(list).to be_a Twitter::List + expect(list.name).to eq "presidents" end end @@ -793,14 +793,14 @@ end it "requests the correct resource" do @client.lists - a_get("/1.1/lists/list.json"). - should have_been_made + expect(a_get("/1.1/lists/list.json")). + to have_been_made end it "returns the requested list" do lists = @client.lists - lists.should be_an Array - lists.first.should be_a Twitter::List - lists.first.name.should eq "Rubyists" + expect(lists).to be_an Array + expect(lists.first).to be_a Twitter::List + expect(lists.first.name).to eq "Rubyists" end end @@ -813,14 +813,14 @@ end it "requests the correct resource" do @client.list("sferik", "presidents") - a_get("/1.1/lists/show.json"). - with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}). - should have_been_made + expect(a_get("/1.1/lists/show.json"). + with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'})). + to have_been_made end it "returns the updated list" do list = @client.list("sferik", "presidents") - list.should be_a Twitter::List - list.name.should eq "presidents" + expect(list).to be_a Twitter::List + expect(list.name).to eq "presidents" end end context "with a user ID passed" do @@ -831,9 +831,9 @@ end it "requests the correct resource" do @client.list(12345678, 'presidents') - a_get("/1.1/lists/show.json"). - with(:query => {:owner_id => '12345678', :slug => 'presidents'}). - should have_been_made + expect(a_get("/1.1/lists/show.json"). + with(:query => {:owner_id => '12345678', :slug => 'presidents'})). + to have_been_made end end context "with a user object passed" do @@ -845,9 +845,9 @@ it "requests the correct resource" do user = Twitter::User.new(:id => '12345678') @client.list(user, 'presidents') - a_get("/1.1/lists/show.json"). - with(:query => {:owner_id => '12345678', :slug => 'presidents'}). - should have_been_made + expect(a_get("/1.1/lists/show.json"). + with(:query => {:owner_id => '12345678', :slug => 'presidents'})). + to have_been_made end end context "without a screen name passed" do @@ -860,9 +860,9 @@ end it "requests the correct resource" do @client.list("presidents") - a_get("/1.1/lists/show.json"). - with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}). - should have_been_made + expect(a_get("/1.1/lists/show.json"). + with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'})). + to have_been_made end end context "with a list ID passed" do @@ -873,9 +873,9 @@ end it "requests the correct resource" do @client.list("sferik", 12345678) - a_get("/1.1/lists/show.json"). - with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678'}). - should have_been_made + expect(a_get("/1.1/lists/show.json"). + with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678'})). + to have_been_made end end context "with a list object passed" do @@ -887,9 +887,9 @@ it "requests the correct resource" do list = Twitter::List.new(:id => '12345678', :user => {:id => 7505382, :screen_name => 'sferik'}) @client.list(list) - a_get("/1.1/lists/show.json"). - with(:query => {:owner_id => '7505382', :list_id => '12345678'}). - should have_been_made + expect(a_get("/1.1/lists/show.json"). + with(:query => {:owner_id => '7505382', :list_id => '12345678'})). + to have_been_made end end end diff --git a/spec/twitter/api/report_spam_spec.rb b/spec/twitter/api/report_spam_spec.rb index e53d12d91..b58d91f93 100644 --- a/spec/twitter/api/report_spam_spec.rb +++ b/spec/twitter/api/report_spam_spec.rb @@ -14,15 +14,15 @@ end it "requests the correct resource" do @client.report_spam("sferik") - a_post("/1.1/report_spam.json"). - with(:body => {:screen_name => "sferik"}). - should have_been_made + expect(a_post("/1.1/report_spam.json"). + with(:body => {:screen_name => "sferik"})). + to have_been_made end it "returns an array of users" do users = @client.report_spam("sferik") - users.should be_an Array - users.first.should be_a Twitter::User - users.first.id.should eq 7505382 + expect(users).to be_an Array + expect(users.first).to be_a Twitter::User + expect(users.first.id).to eq 7505382 end end diff --git a/spec/twitter/api/saved_searches_spec.rb b/spec/twitter/api/saved_searches_spec.rb index f9b1584e7..68f8a412e 100644 --- a/spec/twitter/api/saved_searches_spec.rb +++ b/spec/twitter/api/saved_searches_spec.rb @@ -14,14 +14,14 @@ end it "requests the correct resource" do @client.saved_searches(16129012) - a_get("/1.1/saved_searches/show/16129012.json"). - should have_been_made + expect(a_get("/1.1/saved_searches/show/16129012.json")). + to have_been_made end it "returns an array of saved searches" do saved_searches = @client.saved_searches(16129012) - saved_searches.should be_an Array - saved_searches.first.should be_a Twitter::SavedSearch - saved_searches.first.name.should eq "twitter" + expect(saved_searches).to be_an Array + expect(saved_searches.first).to be_a Twitter::SavedSearch + expect(saved_searches.first.name).to eq "twitter" end end context "without ids passed" do @@ -31,14 +31,14 @@ end it "requests the correct resource" do @client.saved_searches - a_get("/1.1/saved_searches/list.json"). - should have_been_made + expect(a_get("/1.1/saved_searches/list.json")). + to have_been_made end it "returns the authenticated user's saved search queries" do saved_searches = @client.saved_searches - saved_searches.should be_an Array - saved_searches.first.should be_a Twitter::SavedSearch - saved_searches.first.name.should eq "twitter" + expect(saved_searches).to be_an Array + expect(saved_searches.first).to be_a Twitter::SavedSearch + expect(saved_searches.first.name).to eq "twitter" end end end @@ -50,13 +50,13 @@ end it "requests the correct resource" do @client.saved_search(16129012) - a_get("/1.1/saved_searches/show/16129012.json"). - should have_been_made + expect(a_get("/1.1/saved_searches/show/16129012.json")). + to have_been_made end it "returns a saved search" do saved_search = @client.saved_search(16129012) - saved_search.should be_a Twitter::SavedSearch - saved_search.name.should eq "twitter" + expect(saved_search).to be_a Twitter::SavedSearch + expect(saved_search.name).to eq "twitter" end end @@ -68,14 +68,14 @@ end it "requests the correct resource" do @client.saved_search_create("twitter") - a_post("/1.1/saved_searches/create.json"). - with(:body => {:query => "twitter"}). - should have_been_made + expect(a_post("/1.1/saved_searches/create.json"). + with(:body => {:query => "twitter"})). + to have_been_made end it "returns the created saved search" do saved_search = @client.saved_search_create("twitter") - saved_search.should be_a Twitter::SavedSearch - saved_search.name.should eq "twitter" + expect(saved_search).to be_a Twitter::SavedSearch + expect(saved_search.name).to eq "twitter" end end @@ -86,14 +86,14 @@ end it "requests the correct resource" do @client.saved_search_destroy(16129012) - a_post("/1.1/saved_searches/destroy/16129012.json"). - should have_been_made + expect(a_post("/1.1/saved_searches/destroy/16129012.json")). + to have_been_made end it "returns an array of deleted saved searches" do saved_searches = @client.saved_search_destroy(16129012) - saved_searches.should be_an Array - saved_searches.first.should be_a Twitter::SavedSearch - saved_searches.first.name.should eq "twitter" + expect(saved_searches).to be_an Array + expect(saved_searches.first).to be_a Twitter::SavedSearch + expect(saved_searches.first.name).to eq "twitter" end end diff --git a/spec/twitter/api/search_spec.rb b/spec/twitter/api/search_spec.rb index 85c945a40..1fa261ac0 100644 --- a/spec/twitter/api/search_spec.rb +++ b/spec/twitter/api/search_spec.rb @@ -14,20 +14,20 @@ end it "requests the correct resource" do @client.search('twitter') - a_get("/1.1/search/tweets.json"). - with(:query => {:q => "twitter"}). - should have_been_made + expect(a_get("/1.1/search/tweets.json"). + with(:query => {:q => "twitter"})). + to have_been_made end it "returns recent Tweets related to a query with images and videos embedded" do search = @client.search('twitter') - search.should be_a Twitter::SearchResults - search.results.should be_an Array - search.results.first.should be_a Twitter::Tweet - search.results.first.text.should eq "Bubble Mailer #freebandnames" + expect(search).to be_a Twitter::SearchResults + expect(search.results).to be_an Array + expect(search.results.first).to be_a Twitter::Tweet + expect(search.results.first.text).to eq "Bubble Mailer #freebandnames" end it "returns the max_id value for a search result" do search = @client.search('twitter') - search.max_id.should eq(250126199840518145) + expect(search.max_id).to eq(250126199840518145) end context "when search API responds a malformed result" do @@ -39,8 +39,8 @@ it "returns an empty array" do search = @client.search('twitter') - search.results.should be_an Array - search.results.should be_empty + expect(search.results).to be_an Array + expect(search.results).to be_empty end end end @@ -53,15 +53,15 @@ end it "requests the correct resource" do @client.phoenix_search('twitter') - a_get("/phoenix_search.phoenix"). - with(:query => {:q => "twitter"}). - should have_been_made + expect(a_get("/phoenix_search.phoenix"). + with(:query => {:q => "twitter"})). + to have_been_made end it "returns recent Tweets related to a query with images and videos embedded" do search = @client.phoenix_search('twitter') - search.should be_an Array - search.first.should be_a Twitter::Tweet - search.first.text.should eq "looking at twitter trends just makes me realize how little i really understand about mankind." + expect(search).to be_an Array + expect(search.first).to be_a Twitter::Tweet + expect(search.first.text).to eq "looking at twitter trends just makes me realize how little i really understand about mankind." end end diff --git a/spec/twitter/api/statuses_spec.rb b/spec/twitter/api/statuses_spec.rb index ab40d5119..bd8aa764a 100644 --- a/spec/twitter/api/statuses_spec.rb +++ b/spec/twitter/api/statuses_spec.rb @@ -15,15 +15,15 @@ end it "requests the correct resource" do @client.favorites("sferik") - a_get("/1.1/favorites/list.json"). - with(:query => {:screen_name => "sferik"}). - should have_been_made + expect(a_get("/1.1/favorites/list.json"). + with(:query => {:screen_name => "sferik"})). + to have_been_made end it "returns the 20 most recent favorite Tweets for the authenticating user or user specified by the ID parameter" do favorites = @client.favorites("sferik") - favorites.should be_an Array - favorites.first.should be_a Twitter::Tweet - favorites.first.user.id.should eq 2404341 + expect(favorites).to be_an Array + expect(favorites.first).to be_a Twitter::Tweet + expect(favorites.first.user.id).to eq 2404341 end end context "without arguments passed" do @@ -33,14 +33,14 @@ end it "requests the correct resource" do @client.favorites - a_get("/1.1/favorites/list.json"). - should have_been_made + expect(a_get("/1.1/favorites/list.json")). + to have_been_made end it "returns the 20 most recent favorite Tweets for the authenticating user or user specified by the ID parameter" do favorites = @client.favorites - favorites.should be_an Array - favorites.first.should be_a Twitter::Tweet - favorites.first.user.id.should eq 2404341 + expect(favorites).to be_an Array + expect(favorites.first).to be_a Twitter::Tweet + expect(favorites.first.user.id).to eq 2404341 end end end @@ -53,15 +53,15 @@ end it "requests the correct resource" do @client.favorite(25938088801) - a_post("/1.1/favorites/create.json"). - with(:body => {:id => "25938088801"}). - should have_been_made + expect(a_post("/1.1/favorites/create.json"). + with(:body => {:id => "25938088801"})). + to have_been_made end it "returns an array of favorited Tweets" do tweets = @client.favorite(25938088801) - tweets.should be_an Array - tweets.first.should be_a Twitter::Tweet - tweets.first.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" + expect(tweets).to be_an Array + expect(tweets.first).to be_a Twitter::Tweet + expect(tweets.first.text).to eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" end end @@ -73,15 +73,15 @@ end it "requests the correct resource" do @client.unfavorite(25938088801) - a_post("/1.1/favorites/destroy.json"). - with(:body => {:id => "25938088801"}). - should have_been_made + expect(a_post("/1.1/favorites/destroy.json"). + with(:body => {:id => "25938088801"})). + to have_been_made end it "returns an array of un-favorited Tweets" do tweets = @client.unfavorite(25938088801) - tweets.should be_an Array - tweets.first.should be_a Twitter::Tweet - tweets.first.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" + expect(tweets).to be_an Array + expect(tweets.first).to be_a Twitter::Tweet + expect(tweets.first.text).to eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" end end @@ -92,14 +92,14 @@ end it "requests the correct resource" do @client.home_timeline - a_get("/1.1/statuses/home_timeline.json"). - should have_been_made + expect(a_get("/1.1/statuses/home_timeline.json")). + to have_been_made end it "returns the 20 most recent Tweets, including retweets if they exist, posted by the authenticating user and the user's they follow" do tweets = @client.home_timeline - tweets.should be_an Array - tweets.first.should be_a Twitter::Tweet - tweets.first.text.should eq "Happy Birthday @imdane. Watch out for those @rally pranksters!" + expect(tweets).to be_an Array + expect(tweets.first).to be_a Twitter::Tweet + expect(tweets.first.text).to eq "Happy Birthday @imdane. Watch out for those @rally pranksters!" end end @@ -110,14 +110,14 @@ end it "requests the correct resource" do @client.mentions_timeline - a_get("/1.1/statuses/mentions_timeline.json"). - should have_been_made + expect(a_get("/1.1/statuses/mentions_timeline.json")). + to have_been_made end it "returns the 20 most recent mentions (status containing @username) for the authenticating user" do tweets = @client.mentions_timeline - tweets.should be_an Array - tweets.first.should be_a Twitter::Tweet - tweets.first.text.should eq "Happy Birthday @imdane. Watch out for those @rally pranksters!" + expect(tweets).to be_an Array + expect(tweets.first).to be_a Twitter::Tweet + expect(tweets.first.text).to eq "Happy Birthday @imdane. Watch out for those @rally pranksters!" end end @@ -132,18 +132,18 @@ end it "requests the correct resource" do @client.retweeted_by_user("sferik") - a_get("/1.1/statuses/user_timeline.json"). - with(:query => {:include_rts => "true", :screen_name => "sferik", :count => "200"}). - should have_been_made - a_get("/1.1/statuses/user_timeline.json"). - with(:query => {:include_rts => "true", :screen_name => "sferik", :count => "200", :max_id => "244102729860009983"}). - should have_been_made.times(3) + expect(a_get("/1.1/statuses/user_timeline.json"). + with(:query => {:include_rts => "true", :screen_name => "sferik", :count => "200"})). + to have_been_made + expect(a_get("/1.1/statuses/user_timeline.json"). + with(:query => {:include_rts => "true", :screen_name => "sferik", :count => "200", :max_id => "244102729860009983"})). + to have_been_made.times(3) end it "returns the 20 most recent retweets posted by the authenticating user" do tweets = @client.retweeted_by_user("sferik") - tweets.should be_an Array - tweets.first.should be_a Twitter::Tweet - tweets.first.text.should eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k" + expect(tweets).to be_an Array + expect(tweets.first).to be_a Twitter::Tweet + expect(tweets.first.text).to eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k" end end @@ -158,18 +158,18 @@ end it "requests the correct resource" do @client.retweeted_by_me - a_get("/1.1/statuses/user_timeline.json"). - with(:query => {:include_rts => "true", :count => "200"}). - should have_been_made - a_get("/1.1/statuses/user_timeline.json"). - with(:query => {:include_rts => "true", :count => "200", :max_id => "244102729860009983"}). - should have_been_made.times(3) + expect(a_get("/1.1/statuses/user_timeline.json"). + with(:query => {:include_rts => "true", :count => "200"})). + to have_been_made + expect(a_get("/1.1/statuses/user_timeline.json"). + with(:query => {:include_rts => "true", :count => "200", :max_id => "244102729860009983"})). + to have_been_made.times(3) end it "returns the 20 most recent retweets posted by the authenticating user" do tweets = @client.retweeted_by_me - tweets.should be_an Array - tweets.first.should be_a Twitter::Tweet - tweets.first.text.should eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k" + expect(tweets).to be_an Array + expect(tweets.first).to be_a Twitter::Tweet + expect(tweets.first.text).to eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k" end end @@ -184,18 +184,18 @@ end it "requests the correct resource" do @client.retweeted_to_me - stub_get("/1.1/statuses/home_timeline.json"). - with(:query => {:include_rts => "true", :count => "200"}). - should have_been_made - stub_get("/1.1/statuses/home_timeline.json"). - with(:query => {:include_rts => "true", :count => "200", :max_id => "244102729860009983"}). - should have_been_made.times(3) + expect(stub_get("/1.1/statuses/home_timeline.json"). + with(:query => {:include_rts => "true", :count => "200"})). + to have_been_made + expect(stub_get("/1.1/statuses/home_timeline.json"). + with(:query => {:include_rts => "true", :count => "200", :max_id => "244102729860009983"})). + to have_been_made.times(3) end it "returns the 20 most recent retweets posted by users the authenticating user follow" do tweets = @client.retweeted_to_me - tweets.should be_an Array - tweets.first.should be_a Twitter::Tweet - tweets.first.text.should eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k" + expect(tweets).to be_an Array + expect(tweets.first).to be_a Twitter::Tweet + expect(tweets.first.text).to eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k" end end @@ -210,18 +210,18 @@ end it "requests the correct resource" do @client.retweets_of_me - a_get("/1.1/statuses/user_timeline.json"). - with(:query => {:include_rts => "false", :count => "200"}). - should have_been_made - a_get("/1.1/statuses/user_timeline.json"). - with(:query => {:include_rts => "false", :count => "200", :max_id => "244102490646278145"}). - should have_been_made + expect(a_get("/1.1/statuses/user_timeline.json"). + with(:query => {:include_rts => "false", :count => "200"})). + to have_been_made + expect(a_get("/1.1/statuses/user_timeline.json"). + with(:query => {:include_rts => "false", :count => "200", :max_id => "244102490646278145"})). + to have_been_made end it "returns the 20 most recent tweets of the authenticated user that have been retweeted by others" do tweets = @client.retweets_of_me - tweets.should be_an Array - tweets.first.should be_a Twitter::Tweet - tweets.first.text.should eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k" + expect(tweets).to be_an Array + expect(tweets.first).to be_a Twitter::Tweet + expect(tweets.first.text).to eq "RT @olivercameron: Mosaic looks cool: http://t.co/A8013C9k" end end @@ -234,15 +234,15 @@ end it "requests the correct resource" do @client.user_timeline("sferik") - a_get("/1.1/statuses/user_timeline.json"). - with(:query => {:screen_name => "sferik"}). - should have_been_made + expect(a_get("/1.1/statuses/user_timeline.json"). + with(:query => {:screen_name => "sferik"})). + to have_been_made end it "returns the 20 most recent Tweets posted by the user specified by screen name or user id" do tweets = @client.user_timeline("sferik") - tweets.should be_an Array - tweets.first.should be_a Twitter::Tweet - tweets.first.text.should eq "Happy Birthday @imdane. Watch out for those @rally pranksters!" + expect(tweets).to be_an Array + expect(tweets.first).to be_a Twitter::Tweet + expect(tweets.first.text).to eq "Happy Birthday @imdane. Watch out for those @rally pranksters!" end end context "without a screen name passed" do @@ -252,8 +252,8 @@ end it "requests the correct resource" do @client.user_timeline - a_get("/1.1/statuses/user_timeline.json"). - should have_been_made + expect(a_get("/1.1/statuses/user_timeline.json")). + to have_been_made end end end @@ -267,15 +267,15 @@ end it "requests the correct resource" do @client.media_timeline("sferik") - a_get("/1.1/statuses/media_timeline.json"). - with(:query => {:screen_name => "sferik"}). - should have_been_made + expect(a_get("/1.1/statuses/media_timeline.json"). + with(:query => {:screen_name => "sferik"})). + to have_been_made end it "returns the 20 most recent images posted by the user specified by screen name or user id" do tweets = @client.media_timeline("sferik") - tweets.should be_an Array - tweets.first.should be_a Twitter::Tweet - tweets.first.text.should eq "Google is throwing up a question mark for Sunday's weather in Boston. At least they're being honest. http://t.co/Jh7bAhS" + expect(tweets).to be_an Array + expect(tweets.first).to be_a Twitter::Tweet + expect(tweets.first.text).to eq "Google is throwing up a question mark for Sunday's weather in Boston. At least they're being honest. http://t.co/Jh7bAhS" end end context "without a screen name passed" do @@ -285,8 +285,8 @@ end it "requests the correct resource" do @client.media_timeline - a_get("/1.1/statuses/media_timeline.json"). - should have_been_made + expect(a_get("/1.1/statuses/media_timeline.json")). + to have_been_made end end end @@ -299,13 +299,13 @@ end it "requests the correct resource" do @client.retweeters_of(28561922516, :ids_only => true) - a_get("/1.1/statuses/retweets/28561922516.json"). - should have_been_made + expect(a_get("/1.1/statuses/retweets/28561922516.json")). + to have_been_made end it "returns an array of numeric user IDs of retweeters of a Tweet" do ids = @client.retweeters_of(28561922516, :ids_only => true) - ids.should be_an Array - ids.first.should eq 7505382 + expect(ids).to be_an Array + expect(ids.first).to eq 7505382 end end context "without ids_only passed" do @@ -315,14 +315,14 @@ end it "requests the correct resource" do @client.retweeters_of(28561922516) - a_get("/1.1/statuses/retweets/28561922516.json"). - should have_been_made + expect(a_get("/1.1/statuses/retweets/28561922516.json")). + to have_been_made end it "returns an array of user of retweeters of a Tweet" do users = @client.retweeters_of(28561922516) - users.should be_an Array - users.first.should be_a Twitter::User - users.first.id.should eq 7505382 + expect(users).to be_an Array + expect(users.first).to be_a Twitter::User + expect(users.first.id).to eq 7505382 end end end @@ -334,14 +334,14 @@ end it "requests the correct resource" do @client.retweets(28561922516) - a_get("/1.1/statuses/retweets/28561922516.json"). - should have_been_made + expect(a_get("/1.1/statuses/retweets/28561922516.json")). + to have_been_made end it "returns up to 100 of the first retweets of a given tweet" do tweets = @client.retweets(28561922516) - tweets.should be_an Array - tweets.first.should be_a Twitter::Tweet - tweets.first.text.should eq "RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush." + expect(tweets).to be_an Array + expect(tweets.first).to be_a Twitter::Tweet + expect(tweets.first.text).to eq "RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush." end end @@ -352,13 +352,13 @@ end it "requests the correct resource" do @client.status(25938088801) - a_get("/1.1/statuses/show/25938088801.json"). - should have_been_made + expect(a_get("/1.1/statuses/show/25938088801.json")). + to have_been_made end it "returns a Tweet" do tweet = @client.status(25938088801) - tweet.should be_a Twitter::Tweet - tweet.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" + expect(tweet).to be_a Twitter::Tweet + expect(tweet.text).to eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" end end @@ -369,14 +369,14 @@ end it "requests the correct resource" do @client.statuses(25938088801) - a_get("/1.1/statuses/show/25938088801.json"). - should have_been_made + expect(a_get("/1.1/statuses/show/25938088801.json")). + to have_been_made end it "returns an array of Tweets" do tweets = @client.statuses(25938088801) - tweets.should be_an Array - tweets.first.should be_a Twitter::Tweet - tweets.first.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" + expect(tweets).to be_an Array + expect(tweets.first).to be_a Twitter::Tweet + expect(tweets.first.text).to eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" end end @@ -387,13 +387,13 @@ end it "requests the correct resource" do @client.status_activity(25938088801) - a_get("/i/statuses/25938088801/activity/summary.json"). - should have_been_made + expect(a_get("/i/statuses/25938088801/activity/summary.json")). + to have_been_made end it "returns a Tweet" do tweet = @client.status_activity(25938088801) - tweet.should be_a Twitter::Tweet - tweet.retweeters_count.should eq 1 + expect(tweet).to be_a Twitter::Tweet + expect(tweet.retweeters_count).to eq 1 end end @@ -404,14 +404,14 @@ end it "requests the correct resource" do @client.statuses_activity(25938088801) - a_get("/i/statuses/25938088801/activity/summary.json"). - should have_been_made + expect(a_get("/i/statuses/25938088801/activity/summary.json")). + to have_been_made end it "returns an array of Tweets" do tweets = @client.statuses_activity(25938088801) - tweets.should be_an Array - tweets.first.should be_a Twitter::Tweet - tweets.first.retweeters_count.should eq 1 + expect(tweets).to be_an Array + expect(tweets.first).to be_a Twitter::Tweet + expect(tweets.first.retweeters_count).to eq 1 end end @@ -422,14 +422,14 @@ end it "requests the correct resource" do @client.status_destroy(25938088801) - a_post("/1.1/statuses/destroy/25938088801.json"). - should have_been_made + expect(a_post("/1.1/statuses/destroy/25938088801.json")). + to have_been_made end it "returns an array of Tweets" do tweets = @client.status_destroy(25938088801) - tweets.should be_an Array - tweets.first.should be_a Twitter::Tweet - tweets.first.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" + expect(tweets).to be_an Array + expect(tweets.first).to be_a Twitter::Tweet + expect(tweets.first.text).to eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" end end @@ -440,16 +440,16 @@ end it "requests the correct resource" do @client.retweet(28561922516) - a_post("/1.1/statuses/retweet/28561922516.json"). - should have_been_made + expect(a_post("/1.1/statuses/retweet/28561922516.json")). + to have_been_made end it "returns an array of Tweets with retweet details embedded" do tweets = @client.retweet(28561922516) - tweets.should be_an Array - tweets.first.should be_a Twitter::Tweet - tweets.first.text.should eq "As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush." - tweets.first.retweeted_tweet.text.should eq "RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush." - tweets.first.retweeted_tweet.id.should_not == tweets.first.id + expect(tweets).to be_an Array + expect(tweets.first).to be_a Twitter::Tweet + expect(tweets.first.text).to eq "As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush." + expect(tweets.first.retweeted_tweet.text).to eq "RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush." + expect(tweets.first.retweeted_tweet.id).not_to eq(tweets.first.id) end end @@ -461,14 +461,14 @@ end it "requests the correct resource" do @client.update("@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!") - a_post("/1.1/statuses/update.json"). - with(:body => {:status => "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"}). - should have_been_made + expect(a_post("/1.1/statuses/update.json"). + with(:body => {:status => "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"})). + to have_been_made end it "returns a Tweet" do tweet = @client.update("@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!") - tweet.should be_a Twitter::Tweet - tweet.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" + expect(tweet).to be_a Twitter::Tweet + expect(tweet.text).to eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" end end @@ -480,41 +480,41 @@ context "a gif image" do it "requests the correct resource" do @client.update_with_media("You always have options", fixture("pbjt.gif")) - a_post("/1.1/statuses/update_with_media.json"). - should have_been_made + expect(a_post("/1.1/statuses/update_with_media.json")). + to have_been_made end it "returns a Tweet" do tweet = @client.update_with_media("You always have options", fixture("pbjt.gif")) - tweet.should be_a Twitter::Tweet - tweet.text.should eq "You always have options http://t.co/CBYa7Ri" + expect(tweet).to be_a Twitter::Tweet + expect(tweet.text).to eq "You always have options http://t.co/CBYa7Ri" end end context "a jpe image" do it "requests the correct resource" do @client.update_with_media("You always have options", fixture("wildcomet2.jpe")) - a_post("/1.1/statuses/update_with_media.json"). - should have_been_made + expect(a_post("/1.1/statuses/update_with_media.json")). + to have_been_made end end context "a jpeg image" do it "requests the correct resource" do @client.update_with_media("You always have options", fixture("me.jpeg")) - a_post("/1.1/statuses/update_with_media.json"). - should have_been_made + expect(a_post("/1.1/statuses/update_with_media.json")). + to have_been_made end end context "a png image" do it "requests the correct resource" do @client.update_with_media("You always have options", fixture("we_concept_bg2.png")) - a_post("/1.1/statuses/update_with_media.json"). - should have_been_made + expect(a_post("/1.1/statuses/update_with_media.json")). + to have_been_made end end context "a Tempfile" do it "requests the correct resource" do @client.update_with_media("You always have options", Tempfile.new("tmp")) - a_post("/1.1/statuses/update_with_media.json"). - should have_been_made + expect(a_post("/1.1/statuses/update_with_media.json")). + to have_been_made end end end @@ -527,13 +527,13 @@ end it "requests the correct resource" do @client.oembed(25938088801) - a_get("/1.1/statuses/oembed.json"). - with(:query => {:id => "25938088801"}). - should have_been_made + expect(a_get("/1.1/statuses/oembed.json"). + with(:query => {:id => "25938088801"})). + to have_been_made end it "returns an array of OEmbed instances" do oembed = @client.oembed(25938088801) - oembed.should be_a Twitter::OEmbed + expect(oembed).to be_a Twitter::OEmbed end end @@ -545,14 +545,14 @@ end it "requests the correct resource" do @client.oembeds(25938088801) - a_get("/1.1/statuses/oembed.json"). - with(:query => {:id => "25938088801"}). - should have_been_made + expect(a_get("/1.1/statuses/oembed.json"). + with(:query => {:id => "25938088801"})). + to have_been_made end it "returns an array of OEmbed instances" do oembeds = @client.oembeds(25938088801) - oembeds.should be_an Array - oembeds.first.should be_a Twitter::OEmbed + expect(oembeds).to be_an Array + expect(oembeds.first).to be_a Twitter::OEmbed end end diff --git a/spec/twitter/api/trends_spec.rb b/spec/twitter/api/trends_spec.rb index 4898ab397..7ad343283 100644 --- a/spec/twitter/api/trends_spec.rb +++ b/spec/twitter/api/trends_spec.rb @@ -15,15 +15,15 @@ end it "requests the correct resource" do @client.trends(2487956) - a_get("/1.1/trends/place.json"). - with(:query => {:id => "2487956"}). - should have_been_made + expect(a_get("/1.1/trends/place.json"). + with(:query => {:id => "2487956"})). + to have_been_made end it "returns the top 10 trending topics for a specific WOEID" do matching_trends = @client.trends(2487956) - matching_trends.should be_an Array - matching_trends.first.should be_a Twitter::Trend - matching_trends.first.name.should eq "#sevenwordsaftersex" + expect(matching_trends).to be_an Array + expect(matching_trends.first).to be_a Twitter::Trend + expect(matching_trends.first.name).to eq "#sevenwordsaftersex" end end context "without arguments passed" do @@ -34,9 +34,9 @@ end it "requests the correct resource" do @client.trends - a_get("/1.1/trends/place.json"). - with(:query => {:id => "1"}). - should have_been_made + expect(a_get("/1.1/trends/place.json"). + with(:query => {:id => "1"})). + to have_been_made end end end @@ -48,14 +48,14 @@ end it "requests the correct resource" do @client.trends_available - a_get("/1.1/trends/available.json"). - should have_been_made + expect(a_get("/1.1/trends/available.json")). + to have_been_made end it "returns the locations that Twitter has trending topic information for" do locations = @client.trends_available - locations.should be_an Array - locations.first.should be_a Twitter::Place - locations.first.name.should eq "Ireland" + expect(locations).to be_an Array + expect(locations.first).to be_a Twitter::Place + expect(locations.first.name).to eq "Ireland" end end @@ -66,14 +66,14 @@ end it "requests the correct resource" do @client.trends_closest - a_get("/1.1/trends/closest.json"). - should have_been_made + expect(a_get("/1.1/trends/closest.json")). + to have_been_made end it "returns the locations that Twitter has trending topic information for" do locations = @client.trends_closest - locations.should be_an Array - locations.first.should be_a Twitter::Place - locations.first.name.should eq "Ireland" + expect(locations).to be_an Array + expect(locations.first).to be_a Twitter::Place + expect(locations.first.name).to eq "Ireland" end end diff --git a/spec/twitter/api/users_spec.rb b/spec/twitter/api/users_spec.rb index 026ca17bc..71f297a17 100644 --- a/spec/twitter/api/users_spec.rb +++ b/spec/twitter/api/users_spec.rb @@ -14,15 +14,15 @@ end it "requests the correct resource" do @client.suggestions("art-design") - a_get("/1.1/users/suggestions/art-design.json"). - should have_been_made + expect(a_get("/1.1/users/suggestions/art-design.json")). + to have_been_made end it "returns the users in a given category of the Twitter suggested user list" do suggestion = @client.suggestions("art-design") - suggestion.should be_a Twitter::Suggestion - suggestion.name.should eq "Art & Design" - suggestion.users.should be_an Array - suggestion.users.first.should be_a Twitter::User + expect(suggestion).to be_a Twitter::Suggestion + expect(suggestion.name).to eq "Art & Design" + expect(suggestion.users).to be_an Array + expect(suggestion.users.first).to be_a Twitter::User end end context "without arguments passed" do @@ -32,14 +32,14 @@ end it "requests the correct resource" do @client.suggestions - a_get("/1.1/users/suggestions.json"). - should have_been_made + expect(a_get("/1.1/users/suggestions.json")). + to have_been_made end it "returns the list of suggested user categories" do suggestions = @client.suggestions - suggestions.should be_an Array - suggestions.first.should be_a Twitter::Suggestion - suggestions.first.name.should eq "Art & Design" + expect(suggestions).to be_an Array + expect(suggestions.first).to be_a Twitter::Suggestion + expect(suggestions.first.name).to eq "Art & Design" end end end @@ -51,14 +51,14 @@ end it "requests the correct resource" do @client.suggest_users("art-design") - a_get("/1.1/users/suggestions/art-design/members.json"). - should have_been_made + expect(a_get("/1.1/users/suggestions/art-design/members.json")). + to have_been_made end it "returns users in a given category of the Twitter suggested user list and return their most recent status if they are not a protected user" do suggest_users = @client.suggest_users("art-design") - suggest_users.should be_an Array - suggest_users.first.should be_a Twitter::User - suggest_users.first.name.should eq "OMGFacts" + expect(suggest_users).to be_an Array + expect(suggest_users.first).to be_a Twitter::User + expect(suggest_users.first.name).to eq "OMGFacts" end end @@ -71,15 +71,15 @@ end it "requests the correct resource" do @client.users("sferik", "pengwynn") - a_post("/1.1/users/lookup.json"). - with(:body => {:screen_name => "sferik,pengwynn"}). - should have_been_made + expect(a_post("/1.1/users/lookup.json"). + with(:body => {:screen_name => "sferik,pengwynn"})). + to have_been_made end it "returns up to 100 users worth of extended information" do users = @client.users("sferik", "pengwynn") - users.should be_an Array - users.first.should be_a Twitter::User - users.first.id.should eq 7505382 + expect(users).to be_an Array + expect(users.first).to be_a Twitter::User + expect(users.first.id).to eq 7505382 end end context "with numeric screen names passed" do @@ -90,9 +90,9 @@ end it "requests the correct resource" do @client.users("0", "311") - a_post("/1.1/users/lookup.json"). - with(:body => {:screen_name => "0,311"}). - should have_been_made + expect(a_post("/1.1/users/lookup.json"). + with(:body => {:screen_name => "0,311"})). + to have_been_made end end context "with user IDs passed" do @@ -103,9 +103,9 @@ end it "requests the correct resource" do @client.users(7505382, 14100886) - a_post("/1.1/users/lookup.json"). - with(:body => {:user_id => "7505382,14100886"}). - should have_been_made + expect(a_post("/1.1/users/lookup.json"). + with(:body => {:user_id => "7505382,14100886"})). + to have_been_made end end context "with both screen names and user IDs passed" do @@ -116,9 +116,9 @@ end it "requests the correct resource" do @client.users("sferik", 14100886) - a_post("/1.1/users/lookup.json"). - with(:body => {:screen_name => "sferik", :user_id => "14100886"}). - should have_been_made + expect(a_post("/1.1/users/lookup.json"). + with(:body => {:screen_name => "sferik", :user_id => "14100886"})). + to have_been_made end end context "with user objects passed" do @@ -131,9 +131,9 @@ user1 = Twitter::User.new(:id => '7505382') user2 = Twitter::User.new(:id => '14100886') @client.users(user1, user2) - a_post("/1.1/users/lookup.json"). - with(:body => {:user_id => "7505382,14100886"}). - should have_been_made + expect(a_post("/1.1/users/lookup.json"). + with(:body => {:user_id => "7505382,14100886"})). + to have_been_made end end end @@ -146,15 +146,15 @@ end it "requests the correct resource" do @client.user_search("Erik Michaels-Ober") - a_get("/1.1/users/search.json"). - with(:query => {:q => "Erik Michaels-Ober"}). - should have_been_made + expect(a_get("/1.1/users/search.json"). + with(:query => {:q => "Erik Michaels-Ober"})). + to have_been_made end it "returns an array of user search results" do user_search = @client.user_search("Erik Michaels-Ober") - user_search.should be_an Array - user_search.first.should be_a Twitter::User - user_search.first.id.should eq 7505382 + expect(user_search).to be_an Array + expect(user_search.first).to be_a Twitter::User + expect(user_search.first.id).to eq 7505382 end end @@ -167,14 +167,14 @@ end it "requests the correct resource" do @client.user("sferik") - a_get("/1.1/users/show.json"). - with(:query => {:screen_name => "sferik"}). - should have_been_made + expect(a_get("/1.1/users/show.json"). + with(:query => {:screen_name => "sferik"})). + to have_been_made end it "returns extended information of a given user" do user = @client.user("sferik") - user.should be_a Twitter::User - user.id.should eq 7505382 + expect(user).to be_a Twitter::User + expect(user.id).to eq 7505382 end end context "with a screen name including '@' passed" do @@ -185,9 +185,9 @@ end it "requests the correct resource" do @client.user("@sferik") - a_get("/1.1/users/show.json"). - with(:query => {:screen_name => "@sferik"}). - should have_been_made + expect(a_get("/1.1/users/show.json"). + with(:query => {:screen_name => "@sferik"})). + to have_been_made end end context "with a numeric screen name passed" do @@ -198,9 +198,9 @@ end it "requests the correct resource" do @client.user("0") - a_get("/1.1/users/show.json"). - with(:query => {:screen_name => "0"}). - should have_been_made + expect(a_get("/1.1/users/show.json"). + with(:query => {:screen_name => "0"})). + to have_been_made end end context "with a user ID passed" do @@ -211,9 +211,9 @@ end it "requests the correct resource" do @client.user(7505382) - a_get("/1.1/users/show.json"). - with(:query => {:user_id => "7505382"}). - should have_been_made + expect(a_get("/1.1/users/show.json"). + with(:query => {:user_id => "7505382"})). + to have_been_made end end context "with a user object passed" do @@ -225,9 +225,9 @@ it "requests the correct resource" do user = Twitter::User.new(:id => 7505382) @client.user(user) - a_get("/1.1/users/show.json"). - with(:query => {:user_id => "7505382"}). - should have_been_made + expect(a_get("/1.1/users/show.json"). + with(:query => {:user_id => "7505382"})). + to have_been_made end end end @@ -239,8 +239,8 @@ end it "requests the correct resource" do @client.user - a_get("/1.1/account/verify_credentials.json"). - should have_been_made + expect(a_get("/1.1/account/verify_credentials.json")). + to have_been_made end end context "with options passed" do @@ -251,9 +251,9 @@ end it "requests the correct resource" do @client.user(:skip_status => true) - a_get("/1.1/account/verify_credentials.json"). - with(:query => {:skip_status => "true"}). - should have_been_made + expect(a_get("/1.1/account/verify_credentials.json"). + with(:query => {:skip_status => "true"})). + to have_been_made end end end @@ -269,17 +269,17 @@ end it "requests the correct resource" do @client.user?("sferik") - a_get("/1.1/users/show.json"). - with(:query => {:screen_name => "sferik"}). - should have_been_made + expect(a_get("/1.1/users/show.json"). + with(:query => {:screen_name => "sferik"})). + to have_been_made end it "returns true if user exists" do user = @client.user?("sferik") - user.should be_true + expect(user).to be_truthy end it "returns false if user does not exist" do user = @client.user?("pengwynn") - user.should be_false + expect(user).to be_falsey end end @@ -292,15 +292,15 @@ end it "requests the correct resource" do @client.contributees("sferik") - a_get("/1.1/users/contributees.json"). - with(:query => {:screen_name => "sferik"}). - should have_been_made + expect(a_get("/1.1/users/contributees.json"). + with(:query => {:screen_name => "sferik"})). + to have_been_made end it "returns a user's contributees" do contributees = @client.contributees("sferik") - contributees.should be_an Array - contributees.first.should be_a Twitter::User - contributees.first.name.should eq "Twitter API" + expect(contributees).to be_an Array + expect(contributees.first).to be_a Twitter::User + expect(contributees.first.name).to eq "Twitter API" end end context "without arguments passed" do @@ -313,15 +313,15 @@ end it "requests the correct resource" do @client.contributees - a_get("/1.1/users/contributees.json"). - with(:query => {:screen_name => "sferik"}). - should have_been_made + expect(a_get("/1.1/users/contributees.json"). + with(:query => {:screen_name => "sferik"})). + to have_been_made end it "returns a user's contributees" do contributees = @client.contributees - contributees.should be_an Array - contributees.first.should be_a Twitter::User - contributees.first.name.should eq "Twitter API" + expect(contributees).to be_an Array + expect(contributees.first).to be_a Twitter::User + expect(contributees.first.name).to eq "Twitter API" end end end @@ -337,15 +337,15 @@ end it "requests the correct resource" do @client.contributors("sferik") - a_get("/1.1/users/contributors.json"). - with(:query => {:screen_name => "sferik"}). - should have_been_made + expect(a_get("/1.1/users/contributors.json"). + with(:query => {:screen_name => "sferik"})). + to have_been_made end it "returns a user's contributors" do contributors = @client.contributors("sferik") - contributors.should be_an Array - contributors.first.should be_a Twitter::User - contributors.first.name.should eq "Biz Stone" + expect(contributors).to be_an Array + expect(contributors.first).to be_a Twitter::User + expect(contributors.first.name).to eq "Biz Stone" end end context "without arguments passed" do @@ -358,15 +358,15 @@ end it "requests the correct resource" do @client.contributors - a_get("/1.1/users/contributors.json"). - with(:query => {:screen_name => "sferik"}). - should have_been_made + expect(a_get("/1.1/users/contributors.json"). + with(:query => {:screen_name => "sferik"})). + to have_been_made end it "returns a user's contributors" do contributors = @client.contributors - contributors.should be_an Array - contributors.first.should be_a Twitter::User - contributors.first.name.should eq "Biz Stone" + expect(contributors).to be_an Array + expect(contributors.first).to be_a Twitter::User + expect(contributors.first.name).to eq "Biz Stone" end end end @@ -380,15 +380,15 @@ end it "requests the correct resource" do @client.following_followers_of("sferik") - a_get("/users/following_followers_of.json"). - with(:query => {:cursor => "-1", :screen_name => "sferik"}). - should have_been_made + expect(a_get("/users/following_followers_of.json"). + with(:query => {:cursor => "-1", :screen_name => "sferik"})). + to have_been_made end it "returns an array of numeric IDs for every user following the specified user" do following_followers_of = @client.following_followers_of("sferik") - following_followers_of.should be_a Twitter::Cursor - following_followers_of.users.should be_an Array - following_followers_of.users.first.should be_a Twitter::User + expect(following_followers_of).to be_a Twitter::Cursor + expect(following_followers_of.users).to be_an Array + expect(following_followers_of.users.first).to be_a Twitter::User end end context "without arguments passed" do @@ -401,17 +401,17 @@ end it "requests the correct resource" do @client.following_followers_of - a_get("/1.1/account/verify_credentials.json"). - should have_been_made - a_get("/users/following_followers_of.json"). - with(:query => {:cursor => "-1", :screen_name => "sferik"}). - should have_been_made + expect(a_get("/1.1/account/verify_credentials.json")). + to have_been_made + expect(a_get("/users/following_followers_of.json"). + with(:query => {:cursor => "-1", :screen_name => "sferik"})). + to have_been_made end it "returns an array of numeric IDs for every user following the specified user" do following_followers_of = @client.following_followers_of - following_followers_of.should be_a Twitter::Cursor - following_followers_of.users.should be_an Array - following_followers_of.users.first.should be_a Twitter::User + expect(following_followers_of).to be_a Twitter::Cursor + expect(following_followers_of.users).to be_an Array + expect(following_followers_of.users.first).to be_a Twitter::User end end end diff --git a/spec/twitter/base_spec.rb b/spec/twitter/base_spec.rb index 48bebe23b..a975ea034 100644 --- a/spec/twitter/base_spec.rb +++ b/spec/twitter/base_spec.rb @@ -15,62 +15,62 @@ describe '.identity_map' do it 'returns an instance of the identity map' do - Twitter::Base.identity_map.should be_a Twitter::IdentityMap + expect(Twitter::Base.identity_map).to be_a Twitter::IdentityMap end end describe '.fetch' do it 'returns existing objects' do - Twitter::Base.fetch(:id => 1).should be + expect(Twitter::Base.fetch(:id => 1)).to be end it "raises an error on objects that don't exist" do - lambda { + expect { Twitter::Base.fetch(:id => 6) - }.should raise_error(Twitter::Error::IdentityMapKeyError) + }.to raise_error(Twitter::Error::IdentityMapKeyError) end end describe '.store' do it 'stores Twitter::Base objects' do object = Twitter::Base.new(:id => 4) - Twitter::Base.store(object).should be_a Twitter::Base + expect(Twitter::Base.store(object)).to be_a Twitter::Base end end describe '.fetch_or_new' do it 'returns existing objects' do - Twitter::Base.fetch_or_new(:id => 1).should be + expect(Twitter::Base.fetch_or_new(:id => 1)).to be end it 'creates new objects and stores them' do - Twitter::Base.fetch_or_new(:id => 2).should be - Twitter::Base.fetch(:id => 2).should be + expect(Twitter::Base.fetch_or_new(:id => 2)).to be + expect(Twitter::Base.fetch(:id => 2)).to be end end describe "#[]" do it "calls methods using [] with symbol" do - @base[:object_id].should be_an Integer + expect(@base[:object_id]).to be_an Integer end it "calls methods using [] with string" do - @base['object_id'].should be_an Integer + expect(@base['object_id']).to be_an Integer end it "returns nil for missing method" do - @base[:foo].should be_nil - @base['foo'].should be_nil + expect(@base[:foo]).to be_nil + expect(@base['foo']).to be_nil end end describe "#to_hash" do it "returns a hash" do - @base.to_hash.should be_a Hash - @base.to_hash[:id].should eq 1 + expect(@base.to_hash).to be_a Hash + expect(@base.to_hash[:id]).to eq 1 end end describe "identical objects" do it "have the same object_id" do - @base.object_id.should eq Twitter::Base.fetch(:id => 1).object_id + expect(@base.object_id).to eq Twitter::Base.fetch(:id => 1).object_id end end @@ -86,26 +86,26 @@ describe '.identity_map' do it 'returns nil' do - Twitter::Base.identity_map.should be_nil + expect(Twitter::Base.identity_map).to be_nil end end describe '.fetch' do it 'returns nil' do - Twitter::Base.fetch(:id => 1).should be_nil + expect(Twitter::Base.fetch(:id => 1)).to be_nil end end describe '.store' do it 'returns an instance of the object' do - Twitter::Base.store(Twitter::Base.new(:id => 1)).should be_a Twitter::Base + expect(Twitter::Base.store(Twitter::Base.new(:id => 1))).to be_a Twitter::Base end end describe '.fetch_or_new' do it 'creates new objects' do - Twitter::Base.fetch_or_new(:id => 2).should be - Twitter.identity_map.should be_false + expect(Twitter::Base.fetch_or_new(:id => 2)).to be + expect(Twitter.identity_map).to be_falsey end end end diff --git a/spec/twitter/basic_user_spec.rb b/spec/twitter/basic_user_spec.rb index 8c1fba8f6..f02cddfaf 100644 --- a/spec/twitter/basic_user_spec.rb +++ b/spec/twitter/basic_user_spec.rb @@ -6,17 +6,17 @@ it "returns true when objects IDs are the same" do saved_search = Twitter::BasicUser.new(:id => 1, :name => "foo") other = Twitter::BasicUser.new(:id => 1, :name => "bar") - (saved_search == other).should be_true + expect(saved_search == other).to be_truthy end it "returns false when objects IDs are different" do saved_search = Twitter::BasicUser.new(:id => 1) other = Twitter::BasicUser.new(:id => 2) - (saved_search == other).should be_false + expect(saved_search == other).to be_falsey end it "returns false when classes are different" do saved_search = Twitter::BasicUser.new(:id => 1) other = Twitter::Identity.new(:id => 1) - (saved_search == other).should be_false + expect(saved_search == other).to be_falsey end end diff --git a/spec/twitter/client_spec.rb b/spec/twitter/client_spec.rb index 1b37eb26d..58eaebcd6 100644 --- a/spec/twitter/client_spec.rb +++ b/spec/twitter/client_spec.rb @@ -25,7 +25,7 @@ it "inherits the module configuration" do client = Twitter::Client.new Twitter::Configurable.keys.each do |key| - client.instance_variable_get(:"@#{key}").should eq key + expect(client.instance_variable_get(:"@#{key}")).to eq key end end @@ -48,7 +48,7 @@ it "overrides the module configuration" do client = Twitter::Client.new(@configuration) Twitter::Configurable.keys.each do |key| - client.instance_variable_get(:"@#{key}").should eq @configuration[key] + expect(client.instance_variable_get(:"@#{key}")).to eq @configuration[key] end end end @@ -62,7 +62,7 @@ end end Twitter::Configurable.keys.each do |key| - client.instance_variable_get(:"@#{key}").should eq @configuration[key] + expect(client.instance_variable_get(:"@#{key}")).to eq @configuration[key] end end end @@ -74,11 +74,11 @@ stub_get("/1.1/account/verify_credentials.json"). to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"}) client1 = Twitter::Client.new - client1.verify_credentials.id.should eq 7505382 + expect(client1.verify_credentials.id).to eq 7505382 stub_get("/1.1/account/verify_credentials.json"). to_return(:body => fixture("pengwynn.json"), :headers => {:content_type => "application/json; charset=utf-8"}) client2 = Twitter::Client.new - client2.verify_credentials.id.should eq 14100886 + expect(client2.verify_credentials.id).to eq 14100886 end describe "#delete" do @@ -88,9 +88,9 @@ end it "allows custom put requests" do subject.delete("/custom/delete", {:deleted => "object"}) - a_delete("/custom/delete"). - with(:query => {:deleted => "object"}). - should have_been_made + expect(a_delete("/custom/delete"). + with(:query => {:deleted => "object"})). + to have_been_made end end @@ -101,30 +101,30 @@ end it "allows custom put requests" do subject.put("/custom/put", {:updated => "object"}) - a_put("/custom/put"). - with(:body => {:updated => "object"}). - should have_been_made + expect(a_put("/custom/put"). + with(:body => {:updated => "object"})). + to have_been_made end end describe "#credentials?" do it "returns true if all credentials are present" do client = Twitter::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :oauth_token => 'OT', :oauth_token_secret => 'OS') - client.credentials?.should be_true + expect(client.credentials?).to be_truthy end it "returns false if any credentials are missing" do client = Twitter::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :oauth_token => 'OT') - client.credentials?.should be_false + expect(client.credentials?).to be_falsey end end describe "#connection" do it "looks like Faraday connection" do - subject.connection.should respond_to(:run_request) + expect(subject.connection).to respond_to(:run_request) end it "memoizes the connection" do c1, c2 = subject.connection, subject.connection - c1.object_id.should eq c2.object_id + expect(c1.object_id).to eq c2.object_id end end @@ -134,28 +134,28 @@ with(:body => {:status => "Update"}). to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"}) subject.update("Update") - a_post("/1.1/statuses/update.json"). - with(:body => {:status => "Update"}). - should have_been_made + expect(a_post("/1.1/statuses/update.json"). + with(:body => {:status => "Update"})). + to have_been_made end it "encodes none of the body when uploaded media is present" do stub_post("/1.1/statuses/update_with_media.json"). to_return(:body => fixture("status_with_media.json"), :headers => {:content_type => "application/json; charset=utf-8"}) subject.update_with_media("Update", fixture("pbjt.gif")) - a_post("/1.1/statuses/update_with_media.json"). - should have_been_made + expect(a_post("/1.1/statuses/update_with_media.json")). + to have_been_made end it "catches Faraday errors" do - subject.stub!(:connection).and_raise(Faraday::Error::ClientError.new("Oups")) - lambda do + allow(subject).to receive(:connection).and_raise(Faraday::Error::ClientError.new("Oups")) + expect do subject.request(:get, "/path") - end.should raise_error(Twitter::Error::ClientError, "Oups") + end.to raise_error(Twitter::Error::ClientError, "Oups") end it "catches MultiJson::DecodeError errors" do - subject.stub!(:connection).and_raise(MultiJson::DecodeError.build(Exception.new("unexpected token"), "")) - lambda do + allow(subject).to receive(:connection).and_raise(MultiJson::DecodeError.build(Exception.new("unexpected token"), "")) + expect do subject.request(:get, "/path") - end.should raise_error(Twitter::Error::DecodeError, "unexpected token") + end.to raise_error(Twitter::Error::DecodeError, "unexpected token") end end @@ -163,12 +163,12 @@ it "creates the correct auth headers" do uri = URI("https://api.twitter.com/1.1/direct_messages.json") authorization = subject.auth_header(:get, uri) - authorization.options[:signature_method].should eq "HMAC-SHA1" - authorization.options[:version].should eq "1.0" - authorization.options[:consumer_key].should eq "CK" - authorization.options[:consumer_secret].should eq "CS" - authorization.options[:token].should eq "OT" - authorization.options[:token_secret].should eq "OS" + expect(authorization.options[:signature_method]).to eq "HMAC-SHA1" + expect(authorization.options[:version]).to eq "1.0" + expect(authorization.options[:consumer_key]).to eq "CK" + expect(authorization.options[:consumer_secret]).to eq "CS" + expect(authorization.options[:token]).to eq "OT" + expect(authorization.options[:token_secret]).to eq "OS" end end diff --git a/spec/twitter/configuration_spec.rb b/spec/twitter/configuration_spec.rb index 5638b4434..16fd5feac 100644 --- a/spec/twitter/configuration_spec.rb +++ b/spec/twitter/configuration_spec.rb @@ -5,12 +5,12 @@ describe "#photo_sizes" do it "returns a hash of sizes when photo_sizes is set" do photo_sizes = Twitter::Configuration.new(:photo_sizes => {:small => {:h => 226, :w => 340, :resize => 'fit'}, :large => {:h => 466, :w => 700, :resize => 'fit'}, :medium => {:h => 399, :w => 600, :resize => 'fit'}, :thumb => {:h => 150, :w => 150, :resize => 'crop'}}).photo_sizes - photo_sizes.should be_a Hash - photo_sizes[:small].should be_a Twitter::Size + expect(photo_sizes).to be_a Hash + expect(photo_sizes[:small]).to be_a Twitter::Size end it "is empty when photo_sizes is not set" do photo_sizes = Twitter::Configuration.new.photo_sizes - photo_sizes.should be_empty + expect(photo_sizes).to be_empty end end diff --git a/spec/twitter/cursor_spec.rb b/spec/twitter/cursor_spec.rb index 36f54474e..93b52b1b0 100644 --- a/spec/twitter/cursor_spec.rb +++ b/spec/twitter/cursor_spec.rb @@ -5,8 +5,8 @@ describe "#collection" do it "returns a collection" do collection = Twitter::Cursor.new({:ids => [1, 2, 3, 4, 5]}, :ids, nil, Twitter::Client.new, :follower_ids, {}).collection - collection.should be_an Array - collection.first.should be_a Fixnum + expect(collection).to be_an Array + expect(collection.first).to be_a Fixnum end end @@ -22,16 +22,16 @@ end it "requests the correct resources" do @client.follower_ids("sferik").all - a_get("/1.1/followers/ids.json"). - with(:query => {:cursor => "-1", :screen_name => "sferik"}). - should have_been_made - a_get("/1.1/followers/ids.json"). - with(:query => {:cursor => "1305102810874389703", :screen_name => "sferik"}). - should have_been_made + expect(a_get("/1.1/followers/ids.json"). + with(:query => {:cursor => "-1", :screen_name => "sferik"})). + to have_been_made + expect(a_get("/1.1/followers/ids.json"). + with(:query => {:cursor => "1305102810874389703", :screen_name => "sferik"})). + to have_been_made end it "fetches all" do follower_ids = @client.follower_ids("sferik").all - follower_ids.size.should == 5993 + expect(follower_ids.size).to eq(5993) end end @@ -47,17 +47,17 @@ end it "requests the correct resources" do @client.follower_ids("sferik").each{} - a_get("/1.1/followers/ids.json"). - with(:query => {:cursor => "-1", :screen_name => "sferik"}). - should have_been_made - a_get("/1.1/followers/ids.json"). - with(:query => {:cursor => "1305102810874389703", :screen_name => "sferik"}). - should have_been_made + expect(a_get("/1.1/followers/ids.json"). + with(:query => {:cursor => "-1", :screen_name => "sferik"})). + to have_been_made + expect(a_get("/1.1/followers/ids.json"). + with(:query => {:cursor => "1305102810874389703", :screen_name => "sferik"})). + to have_been_made end it "iterates" do count = 0 @client.follower_ids("sferik").each{count += 1} - count.should == 5993 + expect(count).to eq(5993) end end @@ -67,7 +67,7 @@ @cursor = Twitter::Cursor.new({:previous_cursor => 0}, :ids, nil, Twitter::Client.new, :follower_ids, {}) end it "returns true" do - @cursor.first?.should be_true + expect(@cursor.first?).to be_truthy end end context "when previous cursor does not equal zero" do @@ -75,7 +75,7 @@ @cursor = Twitter::Cursor.new({:previous_cursor => 1}, :ids, nil, Twitter::Client.new, :follower_ids, {}) end it "returns true" do - @cursor.first?.should be_false + expect(@cursor.first?).to be_falsey end end end @@ -86,7 +86,7 @@ @cursor = Twitter::Cursor.new({:next_cursor => 0}, :ids, nil, Twitter::Client.new, :follower_ids, {}) end it "returns true" do - @cursor.last?.should be_true + expect(@cursor.last?).to be_truthy end end context "when next cursor does not equal zero" do @@ -94,7 +94,7 @@ @cursor = Twitter::Cursor.new({:next_cursor => 1}, :ids, nil, Twitter::Client.new, :follower_ids, {}) end it "returns false" do - @cursor.last?.should be_false + expect(@cursor.last?).to be_falsey end end end diff --git a/spec/twitter/direct_message_spec.rb b/spec/twitter/direct_message_spec.rb index 79d67ead4..64e063584 100644 --- a/spec/twitter/direct_message_spec.rb +++ b/spec/twitter/direct_message_spec.rb @@ -6,50 +6,50 @@ it "returns true when objects IDs are the same" do direct_message = Twitter::DirectMessage.new(:id => 1, :text => "foo") other = Twitter::DirectMessage.new(:id => 1, :text => "bar") - (direct_message == other).should be_true + expect(direct_message == other).to be_truthy end it "returns false when objects IDs are different" do direct_message = Twitter::DirectMessage.new(:id => 1) other = Twitter::DirectMessage.new(:id => 2) - (direct_message == other).should be_false + expect(direct_message == other).to be_falsey end it "returns false when classes are different" do direct_message = Twitter::DirectMessage.new(:id => 1) other = Twitter::Identity.new(:id => 1) - (direct_message == other).should be_false + expect(direct_message == other).to be_falsey end end describe "#created_at" do it "returns a Time when created_at is set" do direct_message = Twitter::DirectMessage.new(:id => 1825786345, :created_at => "Mon Jul 16 12:59:01 +0000 2007") - direct_message.created_at.should be_a Time + expect(direct_message.created_at).to be_a Time end it "returns nil when created_at is not set" do direct_message = Twitter::DirectMessage.new(:id => 1825786345) - direct_message.created_at.should be_nil + expect(direct_message.created_at).to be_nil end end describe "#recipient" do it "returns a User when recipient is set" do recipient = Twitter::DirectMessage.new(:id => 1825786345, :recipient => {:id => 7505382}).recipient - recipient.should be_a Twitter::User + expect(recipient).to be_a Twitter::User end it "returns nil when recipient is not set" do recipient = Twitter::DirectMessage.new(:id => 1825786345).recipient - recipient.should be_nil + expect(recipient).to be_nil end end describe "#sender" do it "returns a User when sender is set" do sender = Twitter::DirectMessage.new(:id => 1825786345, :sender => {:id => 7505382}).sender - sender.should be_a Twitter::User + expect(sender).to be_a Twitter::User end it "returns nil when sender is not set" do sender = Twitter::DirectMessage.new(:id => 1825786345).sender - sender.should be_nil + expect(sender).to be_nil end end diff --git a/spec/twitter/error/client_error_spec.rb b/spec/twitter/error/client_error_spec.rb index db0d29f7b..e6934ee38 100644 --- a/spec/twitter/error/client_error_spec.rb +++ b/spec/twitter/error/client_error_spec.rb @@ -16,9 +16,9 @@ to_return(:status => status, :body => body_message) end it "raises #{exception.name}" do - lambda do + expect do @client.user_timeline('sferik') - end.should raise_error(exception) + end.to raise_error(exception) end end end @@ -31,9 +31,9 @@ to_return(:status => 404, :body => fixture('no_user_matches.json')) end it "raises Twitter::Error::NotFound" do - lambda do + expect do @client.users('not_on_twitter') - end.should raise_error(Twitter::Error::NotFound) + end.to raise_error(Twitter::Error::NotFound) end end diff --git a/spec/twitter/error/server_error_spec.rb b/spec/twitter/error/server_error_spec.rb index df5d75b8f..e6a368bd4 100644 --- a/spec/twitter/error/server_error_spec.rb +++ b/spec/twitter/error/server_error_spec.rb @@ -14,9 +14,9 @@ to_return(:status => status) end it "raises #{exception.name}" do - lambda do + expect do @client.user_timeline('sferik') - end.should raise_error(exception) + end.to raise_error(exception) end end end diff --git a/spec/twitter/error_spec.rb b/spec/twitter/error_spec.rb index 13bc23a68..d3d15f1f7 100644 --- a/spec/twitter/error_spec.rb +++ b/spec/twitter/error_spec.rb @@ -10,8 +10,8 @@ begin raise Twitter::Error rescue Twitter::Error => error - error.message.should eq "Oups" - error.wrapped_exception.class.should eq Faraday::Error::ClientError + expect(error.message).to eq "Oups" + expect(error.wrapped_exception.class).to eq Faraday::Error::ClientError end end end diff --git a/spec/twitter/geo/point_spec.rb b/spec/twitter/geo/point_spec.rb index 32a33ffb9..d92b479a5 100644 --- a/spec/twitter/geo/point_spec.rb +++ b/spec/twitter/geo/point_spec.rb @@ -10,31 +10,31 @@ it "returns false for empty objects" do point = Twitter::Geo::Point.new other = Twitter::Geo::Point.new - (point == other).should be_false + expect(point == other).to be_falsey end it "returns true when objects coordinates are the same" do other = Twitter::Geo::Point.new(:coordinates => [-122.399983, 37.788299]) - (@point == other).should be_true + expect(@point == other).to be_truthy end it "returns false when objects coordinates are different" do other = Twitter::Geo::Point.new(:coordinates => [37.788299, -122.399983]) - (@point == other).should be_false + expect(@point == other).to be_falsey end it "returns false when classes are different" do other = Twitter::Geo.new(:coordinates => [-122.399983, 37.788299]) - (@point == other).should be_false + expect(@point == other).to be_falsey end end describe "#latitude" do it "returns the latitude" do - @point.latitude.should eq(-122.399983) + expect(@point.latitude).to eq(-122.399983) end end describe "#longitude" do it "returns the longitude" do - @point.longitude.should eq 37.788299 + expect(@point.longitude).to eq 37.788299 end end diff --git a/spec/twitter/geo/polygon_spec.rb b/spec/twitter/geo/polygon_spec.rb index 0a3b30a7c..70a92fc25 100644 --- a/spec/twitter/geo/polygon_spec.rb +++ b/spec/twitter/geo/polygon_spec.rb @@ -10,19 +10,19 @@ it "returns false for empty objects" do polygon = Twitter::Geo::Polygon.new other = Twitter::Geo::Polygon.new - (polygon == other).should be_false + expect(polygon == other).to be_falsey end it "returns true when objects coordinates are the same" do other = Twitter::Geo::Polygon.new(:coordinates => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]]) - (@polygon == other).should be_true + expect(@polygon == other).to be_truthy end it "returns false when objects coordinates are different" do other = Twitter::Geo::Polygon.new(:coordinates => [[[37.77752898, -122.40348192], [37.77752898, -122.387436], [37.79448597, -122.387436], [37.79448597, -122.40348192]]]) - (@polygon == other).should be_false + expect(@polygon == other).to be_falsey end it "returns false when classes are different" do other = Twitter::Geo.new(:coordinates => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]]) - (@polygon == other).should be_false + expect(@polygon == other).to be_falsey end end diff --git a/spec/twitter/geo_factory_spec.rb b/spec/twitter/geo_factory_spec.rb index 0bf19a0ab..a40685d9d 100644 --- a/spec/twitter/geo_factory_spec.rb +++ b/spec/twitter/geo_factory_spec.rb @@ -5,16 +5,16 @@ describe ".new" do it "generates a Point" do geo = Twitter::GeoFactory.fetch_or_new(:type => 'Point') - geo.should be_a Twitter::Geo::Point + expect(geo).to be_a Twitter::Geo::Point end it "generates a Polygon" do geo = Twitter::GeoFactory.fetch_or_new(:type => 'Polygon') - geo.should be_a Twitter::Geo::Polygon + expect(geo).to be_a Twitter::Geo::Polygon end it "raises an ArgumentError when type is not specified" do - lambda do + expect do Twitter::GeoFactory.fetch_or_new - end.should raise_error(ArgumentError, "argument must have :type key") + end.to raise_error(ArgumentError, "argument must have :type key") end end diff --git a/spec/twitter/geo_spec.rb b/spec/twitter/geo_spec.rb index 1dfd06597..5f7c7447d 100644 --- a/spec/twitter/geo_spec.rb +++ b/spec/twitter/geo_spec.rb @@ -10,19 +10,19 @@ it "returns false for empty objects" do geo = Twitter::Geo.new other = Twitter::Geo.new - (geo == other).should be_false + expect(geo == other).to be_falsey end it "returns true when objects coordinates are the same" do other = Twitter::Geo.new(:coordinates => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]]) - (@geo == other).should be_true + expect(@geo == other).to be_truthy end it "returns false when objects coordinates are different" do other = Twitter::Geo.new(:coordinates => [[[37.77752898, -122.40348192], [37.77752898, -122.387436], [37.79448597, -122.387436], [37.79448597, -122.40348192]]]) - (@geo == other).should be_false + expect(@geo == other).to be_falsey end it "returns false when classes are different" do other = Twitter::Geo::Polygon.new(:coordinates => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]]) - (@geo == other).should be_false + expect(@geo == other).to be_falsey end end diff --git a/spec/twitter/identifiable_spec.rb b/spec/twitter/identifiable_spec.rb index 09e5fccda..257feedad 100644 --- a/spec/twitter/identifiable_spec.rb +++ b/spec/twitter/identifiable_spec.rb @@ -4,9 +4,9 @@ describe "#initialize" do it "raises an ArgumentError when type is not specified" do - lambda do + expect do Twitter::Identity.new - end.should raise_error(ArgumentError, "argument must have an :id key") + end.to raise_error(ArgumentError, "argument must have an :id key") end end @@ -22,13 +22,13 @@ describe '.fetch' do it 'returns existing objects' do Twitter::Identity.store(Twitter::Identity.new(:id => 1)) - Twitter::Identity.fetch(:id => 1).should be + expect(Twitter::Identity.fetch(:id => 1)).to be end it "raises an error on objects that don't exist" do - lambda { + expect { Twitter::Identity.fetch(:id => 6) - }.should raise_error(Twitter::Error::IdentityMapKeyError) + }.to raise_error(Twitter::Error::IdentityMapKeyError) end end end @@ -37,17 +37,17 @@ it "returns true when objects IDs are the same" do one = Twitter::Identity.new(:id => 1, :screen_name => "sferik") two = Twitter::Identity.new(:id => 1, :screen_name => "garybernhardt") - (one == two).should be_true + expect(one == two).to be_truthy end it "returns false when objects IDs are different" do one = Twitter::Identity.new(:id => 1) two = Twitter::Identity.new(:id => 2) - (one == two).should be_false + expect(one == two).to be_falsey end it "returns false when classes are different" do one = Twitter::Identity.new(:id => 1) two = Twitter::Base.new(:id => 1) - (one == two).should be_false + expect(one == two).to be_falsey end end diff --git a/spec/twitter/list_spec.rb b/spec/twitter/list_spec.rb index 63cca50f6..f34f0c47d 100644 --- a/spec/twitter/list_spec.rb +++ b/spec/twitter/list_spec.rb @@ -6,39 +6,39 @@ it "returns true when objects IDs are the same" do list = Twitter::List.new(:id => 1, :slug => "foo") other = Twitter::List.new(:id => 1, :slug => "bar") - (list == other).should be_true + expect(list == other).to be_truthy end it "returns false when objects IDs are different" do list = Twitter::List.new(:id => 1) other = Twitter::List.new(:id => 2) - (list == other).should be_false + expect(list == other).to be_falsey end it "returns false when classes are different" do list = Twitter::List.new(:id => 1) other = Twitter::Identity.new(:id => 1) - (list == other).should be_false + expect(list == other).to be_falsey end end describe "#created_at" do it "returns a Time when created_at is set" do user = Twitter::List.new(:id => 8863586, :created_at => "Mon Jul 16 12:59:01 +0000 2007") - user.created_at.should be_a Time + expect(user.created_at).to be_a Time end it "returns nil when created_at is not set" do user = Twitter::List.new(:id => 8863586) - user.created_at.should be_nil + expect(user.created_at).to be_nil end end describe "#user" do it "returns a User when user is set" do user = Twitter::List.new(:id => 8863586, :user => {:id => 7505382}).user - user.should be_a Twitter::User + expect(user).to be_a Twitter::User end it "returns nil when status is not set" do user = Twitter::List.new(:id => 8863586).user - user.should be_nil + expect(user).to be_nil end end diff --git a/spec/twitter/media/photo_spec.rb b/spec/twitter/media/photo_spec.rb index 3482a93b9..ca2367b79 100644 --- a/spec/twitter/media/photo_spec.rb +++ b/spec/twitter/media/photo_spec.rb @@ -6,29 +6,29 @@ it "returns true when objects IDs are the same" do photo = Twitter::Media::Photo.new(:id => 1, :url => "foo") other = Twitter::Media::Photo.new(:id => 1, :url => "bar") - (photo == other).should be_true + expect(photo == other).to be_truthy end it "returns false when objects IDs are different" do photo = Twitter::Media::Photo.new(:id => 1) other = Twitter::Media::Photo.new(:id => 2) - (photo == other).should be_false + expect(photo == other).to be_falsey end it "returns false when classes are different" do photo = Twitter::Media::Photo.new(:id => 1) other = Twitter::Identity.new(:id => 1) - (photo == other).should be_false + expect(photo == other).to be_falsey end end describe "#sizes" do it "returns a hash of Sizes when sizes is set" do sizes = Twitter::Media::Photo.new(:id => 110102452988157952, :sizes => {:small => {:h => 226, :w => 340, :resize => 'fit'}, :large => {:h => 466, :w => 700, :resize => 'fit'}, :medium => {:h => 399, :w => 600, :resize => 'fit'}, :thumb => {:h => 150, :w => 150, :resize => 'crop'}}).sizes - sizes.should be_a Hash - sizes[:small].should be_a Twitter::Size + expect(sizes).to be_a Hash + expect(sizes[:small]).to be_a Twitter::Size end it "is empty when sizes is not set" do sizes = Twitter::Media::Photo.new(:id => 110102452988157952).sizes - sizes.should be_empty + expect(sizes).to be_empty end end diff --git a/spec/twitter/media_factory_spec.rb b/spec/twitter/media_factory_spec.rb index cefd625c0..8f120aad0 100644 --- a/spec/twitter/media_factory_spec.rb +++ b/spec/twitter/media_factory_spec.rb @@ -5,12 +5,12 @@ describe ".new" do it "generates a Photo" do media = Twitter::MediaFactory.fetch_or_new(:id => 1, :type => 'photo') - media.should be_a Twitter::Media::Photo + expect(media).to be_a Twitter::Media::Photo end it "raises an ArgumentError when type is not specified" do - lambda do + expect do Twitter::MediaFactory.fetch_or_new - end.should raise_error(ArgumentError, "argument must have :type key") + end.to raise_error(ArgumentError, "argument must have :type key") end end diff --git a/spec/twitter/oembed_spec.rb b/spec/twitter/oembed_spec.rb index 3869c8670..15122ecf7 100644 --- a/spec/twitter/oembed_spec.rb +++ b/spec/twitter/oembed_spec.rb @@ -5,142 +5,142 @@ describe "#author_url" do it "returns the author's url" do oembed = Twitter::OEmbed.new(:author_url => 'https://twitter.com/sferik') - oembed.author_url.should eq "https://twitter.com/sferik" + expect(oembed.author_url).to eq "https://twitter.com/sferik" end it "returns nil when not set" do author_url = Twitter::OEmbed.new.author_url - author_url.should be_nil + expect(author_url).to be_nil end end describe "#author_name" do it "returns the author's name" do oembed = Twitter::OEmbed.new(:author_name => 'Erik Michaels-Ober') - oembed.author_name.should eq "Erik Michaels-Ober" + expect(oembed.author_name).to eq "Erik Michaels-Ober" end it "returns nil when not set" do author_name = Twitter::OEmbed.new.author_name - author_name.should be_nil + expect(author_name).to be_nil end end describe "#cache_age" do it "returns the cache_age" do oembed = Twitter::OEmbed.new(:cache_age => '31536000000') - oembed.cache_age.should eq "31536000000" + expect(oembed.cache_age).to eq "31536000000" end it "returns nil when not set" do cache_age = Twitter::OEmbed.new.cache_age - cache_age.should be_nil + expect(cache_age).to be_nil end end describe "#height" do it "returns the height" do oembed = Twitter::OEmbed.new(:height => 200) - oembed.height.should eq 200 + expect(oembed.height).to eq 200 end it "returns it as an Integer" do oembed = Twitter::OEmbed.new(:height => 200) - oembed.height.should be_an Integer + expect(oembed.height).to be_an Integer end it "returns nil when not set" do height = Twitter::OEmbed.new.height - height.should be_nil + expect(height).to be_nil end end describe "#html" do it "returns the html" do oembed = Twitter::OEmbed.new(:html => '
all my witty tweet stuff here') - oembed.html.should eq "
all my witty tweet stuff here" + expect(oembed.html).to eq "
all my witty tweet stuff here" end it "returns nil when not set" do html = Twitter::OEmbed.new.html - html.should be_nil + expect(html).to be_nil end end describe "#provider_name" do it "returns the provider_name" do oembed = Twitter::OEmbed.new(:provider_name => 'Twitter') - oembed.provider_name.should eq "Twitter" + expect(oembed.provider_name).to eq "Twitter" end it "returns nil when not set" do provider_name = Twitter::OEmbed.new.provider_name - provider_name.should be_nil + expect(provider_name).to be_nil end end describe "#provider_url" do it "returns the provider_url" do oembed = Twitter::OEmbed.new(:provider_url => 'http://twitter.com') - oembed.provider_url.should eq "http://twitter.com" + expect(oembed.provider_url).to eq "http://twitter.com" end it "returns nil when not set" do provider_url = Twitter::OEmbed.new.provider_url - provider_url.should be_nil + expect(provider_url).to be_nil end end describe "#type" do it "returns the type" do oembed = Twitter::OEmbed.new(:type => 'rich') - oembed.type.should eq "rich" + expect(oembed.type).to eq "rich" end it "returns nil when not set" do type = Twitter::OEmbed.new.type - type.should be_nil + expect(type).to be_nil end end describe "#width" do it "returns the width" do oembed = Twitter::OEmbed.new(:width => 550) - oembed.width.should eq 550 + expect(oembed.width).to eq 550 end it "returns it as an Integer" do oembed = Twitter::OEmbed.new(:width => 550) - oembed.width.should be_an Integer + expect(oembed.width).to be_an Integer end it "returns nil when not set" do width = Twitter::OEmbed.new.width - width.should be_nil + expect(width).to be_nil end end describe "#url" do it "returns the url" do oembed = Twitter::OEmbed.new(:url => 'https://twitter.com/twitterapi/status/133640144317198338') - oembed.url.should eq "https://twitter.com/twitterapi/status/133640144317198338" + expect(oembed.url).to eq "https://twitter.com/twitterapi/status/133640144317198338" end it "returns nil when not set" do url = Twitter::OEmbed.new.url - url.should be_nil + expect(url).to be_nil end end describe "#version" do it "returns the version" do oembed = Twitter::OEmbed.new(:version => '1.0') - oembed.version.should eq "1.0" + expect(oembed.version).to eq "1.0" end it "returns nil when not set" do version = Twitter::OEmbed.new.version - version.should be_nil + expect(version).to be_nil end end end diff --git a/spec/twitter/place_spec.rb b/spec/twitter/place_spec.rb index fa6cd4b17..6e6e9158f 100644 --- a/spec/twitter/place_spec.rb +++ b/spec/twitter/place_spec.rb @@ -6,69 +6,69 @@ it "returns true when objects IDs are the same" do place = Twitter::Place.new(:id => 1, :name => "foo") other = Twitter::Place.new(:id => 1, :name => "bar") - (place == other).should be_true + expect(place == other).to be_truthy end it "returns false when objects IDs are different" do place = Twitter::Place.new(:id => 1) other = Twitter::Place.new(:id => 2) - (place == other).should be_false + expect(place == other).to be_falsey end it "returns false when classes are different" do place = Twitter::Place.new(:id => 1) other = Twitter::Identity.new(:id => 1) - (place == other).should be_false + expect(place == other).to be_falsey end end describe "#bounding_box" do it "returns a Twitter::Place when set" do place = Twitter::Place.new(:id => "247f43d441defc03", :bounding_box => {:type => 'Polygon', :coordinates => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]]}) - place.bounding_box.should be_a Twitter::Geo::Polygon + expect(place.bounding_box).to be_a Twitter::Geo::Polygon end it "returns nil when not set" do place = Twitter::Place.new(:id => "247f43d441defc03") - place.bounding_box.should be_nil + expect(place.bounding_box).to be_nil end end describe "#country_code" do it "returns a country code when set with country_code" do place = Twitter::Place.new(:id => "247f43d441defc03", :country_code => 'US') - place.country_code.should eq 'US' + expect(place.country_code).to eq 'US' end it "returns a country code when set with countryCode" do place = Twitter::Place.new(:id => "247f43d441defc03", :countryCode => 'US') - place.country_code.should eq 'US' + expect(place.country_code).to eq 'US' end it "returns nil when not set" do place = Twitter::Place.new(:id => "247f43d441defc03") - place.country_code.should be_nil + expect(place.country_code).to be_nil end end describe "#parent_id" do it "returns a parent ID when set with parentid" do place = Twitter::Place.new(:id => "247f43d441defc03", :parentid => 1) - place.parent_id.should eq 1 + expect(place.parent_id).to eq 1 end it "returns nil when not set" do place = Twitter::Place.new(:id => "247f43d441defc03") - place.parent_id.should be_nil + expect(place.parent_id).to be_nil end end describe "#place_type" do it "returns a place type when set with place_type" do place = Twitter::Place.new(:id => "247f43d441defc03", :place_type => 'city') - place.place_type.should eq 'city' + expect(place.place_type).to eq 'city' end it "returns a place type when set with placeType[name]" do place = Twitter::Place.new(:id => "247f43d441defc03", :placeType => {:name => 'Town'}) - place.place_type.should eq 'Town' + expect(place.place_type).to eq 'Town' end it "returns nil when not set" do place = Twitter::Place.new(:id => "247f43d441defc03") - place.place_type.should be_nil + expect(place.place_type).to be_nil end end diff --git a/spec/twitter/rate_limit_spec.rb b/spec/twitter/rate_limit_spec.rb index 7fac6154f..7ddaeb4b2 100644 --- a/spec/twitter/rate_limit_spec.rb +++ b/spec/twitter/rate_limit_spec.rb @@ -5,36 +5,36 @@ describe "#limit" do it "returns an Integer when x-rate-limit-limit header is set" do rate_limit = Twitter::RateLimit.new('x-rate-limit-limit' => "150") - rate_limit.limit.should be_an Integer - rate_limit.limit.should eq 150 + expect(rate_limit.limit).to be_an Integer + expect(rate_limit.limit).to eq 150 end it "returns nil when x-rate-limit-limit header is not set" do rate_limit = Twitter::RateLimit.new - rate_limit.limit.should be_nil + expect(rate_limit.limit).to be_nil end end describe "#remaining" do it "returns an Integer when x-rate-limit-remaining header is set" do rate_limit = Twitter::RateLimit.new('x-rate-limit-remaining' => "149") - rate_limit.remaining.should be_an Integer - rate_limit.remaining.should eq 149 + expect(rate_limit.remaining).to be_an Integer + expect(rate_limit.remaining).to eq 149 end it "returns nil when x-rate-limit-remaining header is not set" do rate_limit = Twitter::RateLimit.new - rate_limit.remaining.should be_nil + expect(rate_limit.remaining).to be_nil end end describe "#reset_at" do it "returns a Time when x-rate-limit-reset header is set" do rate_limit = Twitter::RateLimit.new('x-rate-limit-reset' => "1339019097") - rate_limit.reset_at.should be_a Time - rate_limit.reset_at.should eq Time.at(1339019097) + expect(rate_limit.reset_at).to be_a Time + expect(rate_limit.reset_at).to eq Time.at(1339019097) end it "returns nil when x-rate-limit-reset header is not set" do rate_limit = Twitter::RateLimit.new - rate_limit.reset_at.should be_nil + expect(rate_limit.reset_at).to be_nil end end @@ -47,12 +47,12 @@ end it "returns an Integer when x-rate-limit-reset header is set" do rate_limit = Twitter::RateLimit.new('x-rate-limit-reset' => "1339019097") - rate_limit.reset_in.should be_an Integer - rate_limit.reset_in.should eq 15777 + expect(rate_limit.reset_in).to be_an Integer + expect(rate_limit.reset_in).to eq 15777 end it "returns nil when x-rate-limit-reset header is not set" do rate_limit = Twitter::RateLimit.new - rate_limit.reset_in.should be_nil + expect(rate_limit.reset_in).to be_nil end end @@ -65,11 +65,11 @@ end it "updates a rate limit" do rate_limit = Twitter::RateLimit.new('x-rate-limit-reset' => "1339019097") - rate_limit.reset_in.should be_an Integer - rate_limit.reset_in.should eq 15777 + expect(rate_limit.reset_in).to be_an Integer + expect(rate_limit.reset_in).to eq 15777 rate_limit.update({'x-rate-limit-reset' => "1339019098"}) - rate_limit.reset_in.should be_an Integer - rate_limit.reset_in.should eq 15778 + expect(rate_limit.reset_in).to be_an Integer + expect(rate_limit.reset_in).to eq 15778 end end diff --git a/spec/twitter/relationship_spec.rb b/spec/twitter/relationship_spec.rb index fa12f9f9b..e0e50ed8c 100644 --- a/spec/twitter/relationship_spec.rb +++ b/spec/twitter/relationship_spec.rb @@ -5,22 +5,22 @@ describe "#source" do it "returns a User when source is set" do source = Twitter::Relationship.new(:relationship => {:source => {:id => 7505382}}).source - source.should be_a Twitter::SourceUser + expect(source).to be_a Twitter::SourceUser end it "returns nil when source is not set" do source = Twitter::Relationship.new(:relationship => {}).source - source.should be_nil + expect(source).to be_nil end end describe "#target" do it "returns a User when target is set" do target = Twitter::Relationship.new(:relationship => {:target => {:id => 7505382}}).target - target.should be_a Twitter::TargetUser + expect(target).to be_a Twitter::TargetUser end it "returns nil when target is not set" do target = Twitter::Relationship.new(:relationship => {}).target - target.should be_nil + expect(target).to be_nil end end @@ -28,7 +28,7 @@ it "updates a relationship" do relationship = Twitter::Relationship.new(:relationship => {:target => {:id => 7505382}}) relationship.update(:relationship => {:target => {:id => 14100886}}) - relationship.target.id.should eq 14100886 + expect(relationship.target.id).to eq 14100886 end end diff --git a/spec/twitter/saved_search_spec.rb b/spec/twitter/saved_search_spec.rb index b16fad9e9..b864ad927 100644 --- a/spec/twitter/saved_search_spec.rb +++ b/spec/twitter/saved_search_spec.rb @@ -6,28 +6,28 @@ it "returns true when objects IDs are the same" do saved_search = Twitter::SavedSearch.new(:id => 1, :name => "foo") other = Twitter::SavedSearch.new(:id => 1, :name => "bar") - (saved_search == other).should be_true + expect(saved_search == other).to be_truthy end it "returns false when objects IDs are different" do saved_search = Twitter::SavedSearch.new(:id => 1) other = Twitter::SavedSearch.new(:id => 2) - (saved_search == other).should be_false + expect(saved_search == other).to be_falsey end it "returns false when classes are different" do saved_search = Twitter::SavedSearch.new(:id => 1) other = Twitter::Identity.new(:id => 1) - (saved_search == other).should be_false + expect(saved_search == other).to be_falsey end end describe "#created_at" do it "returns a Time when created_at is set" do saved_search = Twitter::SavedSearch.new(:id => 16129012, :created_at => "Mon Jul 16 12:59:01 +0000 2007") - saved_search.created_at.should be_a Time + expect(saved_search.created_at).to be_a Time end it "returns nil when created_at is not set" do saved_search = Twitter::SavedSearch.new(:id => 16129012) - saved_search.created_at.should be_nil + expect(saved_search.created_at).to be_nil end end diff --git a/spec/twitter/search_results_spec.rb b/spec/twitter/search_results_spec.rb index 3b9290bdc..b6a2f42ad 100644 --- a/spec/twitter/search_results_spec.rb +++ b/spec/twitter/search_results_spec.rb @@ -5,84 +5,84 @@ describe "#statuses" do it "returns an array of Tweets" do statuses = Twitter::SearchResults.new(:statuses => [{:id => 25938088801, :text => 'tweet!'}]).statuses - statuses.should be_an Array - statuses.first.should be_a Twitter::Tweet + expect(statuses).to be_an Array + expect(statuses.first).to be_a Twitter::Tweet end it "is empty when not set" do statuses = Twitter::SearchResults.new.statuses - statuses.should be_empty + expect(statuses).to be_empty end end describe "#completed_in" do it "returns a number of seconds" do completed_in = Twitter::SearchResults.new(:search_metadata => {:completed_in => 0.029}).completed_in - completed_in.should be_a Float - completed_in.should eq 0.029 + expect(completed_in).to be_a Float + expect(completed_in).to eq 0.029 end it "is nil when not set" do completed_in = Twitter::SearchResults.new.completed_in - completed_in.should be_nil + expect(completed_in).to be_nil end end describe "#max_id" do it "returns an ID" do max_id = Twitter::SearchResults.new(:search_metadata => {:max_id => 250126199840518145}).max_id - max_id.should be_an Integer - max_id.should eq 250126199840518145 + expect(max_id).to be_an Integer + expect(max_id).to eq 250126199840518145 end it "is nil when not set" do max_id = Twitter::SearchResults.new.max_id - max_id.should be_nil + expect(max_id).to be_nil end end describe "#page" do it "returns page number" do page = Twitter::SearchResults.new(:search_metadata => {:page => 1}).page - page.should be_an Integer - page.should eq 1 + expect(page).to be_an Integer + expect(page).to eq 1 end it "is nil when not set" do page = Twitter::SearchResults.new.page - page.should be_nil + expect(page).to be_nil end end describe "#query" do it "returns the query" do query = Twitter::SearchResults.new(:search_metadata => {:query => "%23freebandnames"}).query - query.should be_a String - query.should eq "%23freebandnames" + expect(query).to be_a String + expect(query).to eq "%23freebandnames" end it "is nil when not set" do query = Twitter::SearchResults.new.query - query.should be_nil + expect(query).to be_nil end end describe "#results_per_page" do it "returns the number of results per page" do results_per_page = Twitter::SearchResults.new(:search_metadata => {:results_per_page => 4}).results_per_page - results_per_page.should be_an Integer - results_per_page.should eq 4 + expect(results_per_page).to be_an Integer + expect(results_per_page).to eq 4 end it "is nil when not set" do results_per_page = Twitter::SearchResults.new.results_per_page - results_per_page.should be_nil + expect(results_per_page).to be_nil end end describe "#since_id" do it "returns an ID" do since_id = Twitter::SearchResults.new(:search_metadata => {:since_id => 250126199840518145}).since_id - since_id.should be_an Integer - since_id.should eq 250126199840518145 + expect(since_id).to be_an Integer + expect(since_id).to eq 250126199840518145 end it "is nil when not set" do since_id = Twitter::SearchResults.new.since_id - since_id.should be_nil + expect(since_id).to be_nil end end diff --git a/spec/twitter/settings_spec.rb b/spec/twitter/settings_spec.rb index 3acc82a69..b3e36d3ea 100644 --- a/spec/twitter/settings_spec.rb +++ b/spec/twitter/settings_spec.rb @@ -5,11 +5,11 @@ describe "#trend_location" do it "returns a Twitter::Place when set" do place = Twitter::Settings.new(:trend_location => [{:countryCode => 'US', :name => 'San Francisco', :country => 'United States', :placeType => {:name => 'Town', :code => 7}, :woeid => 2487956, :parentid => 23424977, :url => 'http://where.yahooapis.com/v1/place/2487956'}]) - place.trend_location.should be_a Twitter::Place + expect(place.trend_location).to be_a Twitter::Place end it "returns nil when not set" do place = Twitter::Settings.new - place.trend_location.should be_nil + expect(place.trend_location).to be_nil end end diff --git a/spec/twitter/size_spec.rb b/spec/twitter/size_spec.rb index f4d81789b..2729bdf32 100644 --- a/spec/twitter/size_spec.rb +++ b/spec/twitter/size_spec.rb @@ -6,32 +6,32 @@ it "returns false for empty objects" do size = Twitter::Size.new other = Twitter::Size.new - (size == other).should be_false + expect(size == other).to be_falsey end it "returns true when objects height and width are the same" do size = Twitter::Size.new(:h => 1, :w => 1, :resize => true) other = Twitter::Size.new(:h => 1, :w => 1, :resize => false) - (size == other).should be_true + expect(size == other).to be_truthy end it "returns false when objects height or width are different" do size = Twitter::Size.new(:h => 1, :w => 1) other = Twitter::Size.new(:h => 1, :w => 2) - (size == other).should be_false + expect(size == other).to be_falsey end it "returns false when classes are different" do size = Twitter::Size.new(:h => 1, :w => 1) other = Twitter::Base.new(:h => 1, :w => 1) - (size == other).should be_false + expect(size == other).to be_falsey end it "returns true when objects non-height and width attributes are the same" do size = Twitter::Size.new(:resize => true) other = Twitter::Size.new(:resize => true) - (size == other).should be_true + expect(size == other).to be_truthy end it "returns false when objects non-height and width attributes are different" do size = Twitter::Size.new(:resize => true) other = Twitter::Size.new(:resize => false) - (size == other).should be_false + expect(size == other).to be_falsey end end diff --git a/spec/twitter/source_user_spec.rb b/spec/twitter/source_user_spec.rb index 0d41c3ade..d8c9de46c 100644 --- a/spec/twitter/source_user_spec.rb +++ b/spec/twitter/source_user_spec.rb @@ -6,17 +6,17 @@ it "returns true when objects IDs are the same" do saved_search = Twitter::SourceUser.new(:id => 1, :name => "foo") other = Twitter::SourceUser.new(:id => 1, :name => "bar") - (saved_search == other).should be_true + expect(saved_search == other).to be_truthy end it "returns false when objects IDs are different" do saved_search = Twitter::SourceUser.new(:id => 1) other = Twitter::SourceUser.new(:id => 2) - (saved_search == other).should be_false + expect(saved_search == other).to be_falsey end it "returns false when classes are different" do saved_search = Twitter::SourceUser.new(:id => 1) other = Twitter::Identity.new(:id => 1) - (saved_search == other).should be_false + expect(saved_search == other).to be_falsey end end diff --git a/spec/twitter/suggestion_spec.rb b/spec/twitter/suggestion_spec.rb index 93668dc93..4a076de1c 100644 --- a/spec/twitter/suggestion_spec.rb +++ b/spec/twitter/suggestion_spec.rb @@ -6,44 +6,44 @@ it "returns false for empty objects" do suggestion = Twitter::Suggestion.new other = Twitter::Suggestion.new - (suggestion == other).should be_false + expect(suggestion == other).to be_falsey end it "returns true when objects slugs are the same" do suggestion = Twitter::Suggestion.new(:slug => 1, :name => "foo") other = Twitter::Suggestion.new(:slug => 1, :name => "bar") - (suggestion == other).should be_true + expect(suggestion == other).to be_truthy end it "returns false when objects slugs are different" do suggestion = Twitter::Suggestion.new(:slug => 1) other = Twitter::Suggestion.new(:slug => 2) - (suggestion == other).should be_false + expect(suggestion == other).to be_falsey end it "returns false when classes are different" do suggestion = Twitter::Suggestion.new(:slug => 1) other = Twitter::Base.new(:slug => 1) - (suggestion == other).should be_false + expect(suggestion == other).to be_falsey end it "returns true when objects non-slug attributes are the same" do suggestion = Twitter::Suggestion.new(:name => "foo") other = Twitter::Suggestion.new(:name => "foo") - (suggestion == other).should be_true + expect(suggestion == other).to be_truthy end it "returns false when objects non-slug attributes are different" do suggestion = Twitter::Suggestion.new(:name => "foo") other = Twitter::Suggestion.new(:name => "bar") - (suggestion == other).should be_false + expect(suggestion == other).to be_falsey end end describe "#users" do it "returns a User when user is set" do users = Twitter::Suggestion.new(:users => [{:id => 7505382}]).users - users.should be_an Array - users.first.should be_a Twitter::User + expect(users).to be_an Array + expect(users.first).to be_a Twitter::User end it "is empty when not set" do users = Twitter::Suggestion.new.users - users.should be_empty + expect(users).to be_empty end end diff --git a/spec/twitter/target_user_spec.rb b/spec/twitter/target_user_spec.rb index 3202980e1..68cb51e96 100644 --- a/spec/twitter/target_user_spec.rb +++ b/spec/twitter/target_user_spec.rb @@ -6,17 +6,17 @@ it "returns true when objects IDs are the same" do saved_search = Twitter::TargetUser.new(:id => 1, :name => "foo") other = Twitter::TargetUser.new(:id => 1, :name => "bar") - (saved_search == other).should be_true + expect(saved_search == other).to be_truthy end it "returns false when objects IDs are different" do saved_search = Twitter::TargetUser.new(:id => 1) other = Twitter::TargetUser.new(:id => 2) - (saved_search == other).should be_false + expect(saved_search == other).to be_falsey end it "returns false when classes are different" do saved_search = Twitter::TargetUser.new(:id => 1) other = Twitter::Identity.new(:id => 1) - (saved_search == other).should be_false + expect(saved_search == other).to be_falsey end end diff --git a/spec/twitter/trend_spec.rb b/spec/twitter/trend_spec.rb index 8700568dc..d9c833e3c 100644 --- a/spec/twitter/trend_spec.rb +++ b/spec/twitter/trend_spec.rb @@ -6,32 +6,32 @@ it "returns false for empty objects" do trend = Twitter::Trend.new other = Twitter::Trend.new - (trend == other).should be_false + expect(trend == other).to be_falsey end it "returns true when objects names are the same" do trend = Twitter::Trend.new(:name => "#sevenwordsaftersex", :query => "foo") other = Twitter::Trend.new(:name => "#sevenwordsaftersex", :query => "bar") - (trend == other).should be_true + expect(trend == other).to be_truthy end it "returns false when objects names are different" do trend = Twitter::Trend.new(:name => "#sevenwordsaftersex") other = Twitter::Trend.new(:name => "#sixwordsaftersex") - (trend == other).should be_false + expect(trend == other).to be_falsey end it "returns false when classes are different" do trend = Twitter::Trend.new(:name => "#sevenwordsaftersex") other = Twitter::Base.new(:name => "#sevenwordsaftersex") - (trend == other).should be_false + expect(trend == other).to be_falsey end it "returns true when objects non-name attributes are the same" do trend = Twitter::Trend.new(:query => "foo") other = Twitter::Trend.new(:query => "foo") - (trend == other).should be_true + expect(trend == other).to be_truthy end it "returns false when objects non-name attributes are different" do trend = Twitter::Trend.new(:query => "foo") other = Twitter::Trend.new(:query => "bar") - (trend == other).should be_false + expect(trend == other).to be_falsey end end diff --git a/spec/twitter/tweet_spec.rb b/spec/twitter/tweet_spec.rb index 64f4948dc..7896a5e11 100644 --- a/spec/twitter/tweet_spec.rb +++ b/spec/twitter/tweet_spec.rb @@ -15,90 +15,90 @@ it "returns true when objects IDs are the same" do tweet = Twitter::Tweet.new(:id => 1, :text => "foo") other = Twitter::Tweet.new(:id => 1, :text => "bar") - (tweet == other).should be_true + expect(tweet == other).to be_truthy end it "returns false when objects IDs are different" do tweet = Twitter::Tweet.new(:id => 1) other = Twitter::Tweet.new(:id => 2) - (tweet == other).should be_false + expect(tweet == other).to be_falsey end it "returns false when classes are different" do tweet = Twitter::Tweet.new(:id => 1) other = Twitter::Identity.new(:id => 1) - (tweet == other).should be_false + expect(tweet == other).to be_falsey end end describe "#created_at" do it "returns a Time when set" do tweet = Twitter::Tweet.new(:id => 28669546014, :created_at => "Mon Jul 16 12:59:01 +0000 2007") - tweet.created_at.should be_a Time + expect(tweet.created_at).to be_a Time end it "returns nil when not set" do tweet = Twitter::Tweet.new(:id => 28669546014) - tweet.created_at.should be_nil + expect(tweet.created_at).to be_nil end end describe "#favoriters_count" do it "returns the count of favoriters when favoriters_count is set" do tweet = Twitter::Tweet.new(:id => 28669546014, :favoriters_count => '1') - tweet.favoriters_count.should be_an Integer - tweet.favoriters_count.should eq 1 + expect(tweet.favoriters_count).to be_an Integer + expect(tweet.favoriters_count).to eq 1 end it "returns nil when not set" do tweet = Twitter::Tweet.new(:id => 28669546014) - tweet.favoriters_count.should be_nil + expect(tweet.favoriters_count).to be_nil end end describe "#from_user" do it "returns a screen name when from_user is set" do tweet = Twitter::Tweet.new(:id => 28669546014, :from_user => 'sferik') - tweet.from_user.should be_a String - tweet.from_user.should eq "sferik" + expect(tweet.from_user).to be_a String + expect(tweet.from_user).to eq "sferik" end it "returns a screen name when screen_name is set" do tweet = Twitter::Tweet.new(:id => 28669546014, :user => {:id => 7505382, :screen_name => 'sferik'}) - tweet.from_user.should be_a String - tweet.from_user.should eq "sferik" + expect(tweet.from_user).to be_a String + expect(tweet.from_user).to eq "sferik" end it "returns nil when not set" do tweet = Twitter::Tweet.new(:id => 28669546014) - tweet.from_user.should be_nil + expect(tweet.from_user).to be_nil end end describe "#full_text" do it "returns the text of a Tweet" do tweet = Twitter::Tweet.new(:id => 28669546014, :text => 'BOOSH') - tweet.full_text.should be_a String - tweet.full_text.should eq "BOOSH" + expect(tweet.full_text).to be_a String + expect(tweet.full_text).to eq "BOOSH" end it "returns the text of a Tweet without a user" do tweet = Twitter::Tweet.new(:id => 28669546014, :text => 'BOOSH', :retweeted_status => {:id => 28561922517, :text => 'BOOSH'}) - tweet.full_text.should be_a String - tweet.full_text.should eq "BOOSH" + expect(tweet.full_text).to be_a String + expect(tweet.full_text).to eq "BOOSH" end it "returns the full text of a retweeted Tweet" do tweet = Twitter::Tweet.new(:id => 28669546014, :retweeted_status => {:id => 28561922516, :text => 'BOOSH', :user => {:id => 7505382, :screen_name => 'sferik'}}) - tweet.full_text.should be_a String - tweet.full_text.should eq "RT @sferik: BOOSH" + expect(tweet.full_text).to be_a String + expect(tweet.full_text).to eq "RT @sferik: BOOSH" end it "returns nil when retweeted_status is not set" do tweet = Twitter::Tweet.new(:id => 28669546014) - tweet.full_text.should be_nil + expect(tweet.full_text).to be_nil end end describe "#geo" do it "returns a Twitter::Geo::Point when set" do tweet = Twitter::Tweet.new(:id => 28669546014, :geo => {:id => 1, :type => 'Point'}) - tweet.geo.should be_a Twitter::Geo::Point + expect(tweet.geo).to be_a Twitter::Geo::Point end it "returns nil when not set" do tweet = Twitter::Tweet.new(:id => 28669546014) - tweet.geo.should be_nil + expect(tweet.geo).to be_nil end end @@ -111,126 +111,126 @@ } ] hashtags = Twitter::Tweet.new(:id => 28669546014, :entities => {:hashtags => hashtags_hash}).hashtags - hashtags.should be_an Array - hashtags.first.should be_a Twitter::Entity::Hashtag - hashtags.first.indices.should eq [10, 33] - hashtags.first.text.should eq 'twitter' + expect(hashtags).to be_an Array + expect(hashtags.first).to be_a Twitter::Entity::Hashtag + expect(hashtags.first.indices).to eq [10, 33] + expect(hashtags.first.text).to eq 'twitter' end it "is empty when not set" do hashtags = Twitter::Tweet.new(:id => 28669546014).hashtags - hashtags.should be_empty + expect(hashtags).to be_empty end it "warns when not set" do Twitter::Tweet.new(:id => 28669546014).hashtags - $stderr.string.should =~ /To get hashtags, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./ + expect($stderr.string).to match(/To get hashtags, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./) end end describe "#media" do it "returns media" do media = Twitter::Tweet.new(:id => 28669546014, :entities => {:media => [{:id => 1, :type => 'photo'}]}).media - media.should be_an Array - media.first.should be_a Twitter::Media::Photo + expect(media).to be_an Array + expect(media.first).to be_a Twitter::Media::Photo end it "is empty when not set" do media = Twitter::Tweet.new(:id => 28669546014).media - media.should be_empty + expect(media).to be_empty end it "warns when not set" do Twitter::Tweet.new(:id => 28669546014).media - $stderr.string.should =~ /To get media, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./ + expect($stderr.string).to match(/To get media, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./) end end describe "#metadata" do it "returns a User when user is set" do metadata = Twitter::Tweet.new(:id => 28669546014, :metadata => {}).metadata - metadata.should be_a Twitter::Metadata + expect(metadata).to be_a Twitter::Metadata end it "returns nil when user is not set" do metadata = Twitter::Tweet.new(:id => 28669546014).metadata - metadata.should be_nil + expect(metadata).to be_nil end end describe "#place" do it "returns a Twitter::Place when set" do tweet = Twitter::Tweet.new(:id => 28669546014, :place => {:id => "247f43d441defc03"}) - tweet.place.should be_a Twitter::Place + expect(tweet.place).to be_a Twitter::Place end it "returns nil when not set" do tweet = Twitter::Tweet.new(:id => 28669546014) - tweet.place.should be_nil + expect(tweet.place).to be_nil end end describe "#repliers_count" do it "returns the count of favoriters when repliers_count is set" do tweet = Twitter::Tweet.new(:id => 28669546014, :repliers_count => '1') - tweet.repliers_count.should be_an Integer - tweet.repliers_count.should eq 1 + expect(tweet.repliers_count).to be_an Integer + expect(tweet.repliers_count).to eq 1 end it "returns nil when not set" do tweet = Twitter::Tweet.new(:id => 28669546014) - tweet.repliers_count.should be_nil + expect(tweet.repliers_count).to be_nil end end describe "#reply?" do it "returns true when there is an in-reply-to status" do tweet = Twitter::Tweet.new(:id => 28669546014, :in_reply_to_status_id => 114749583439036416) - tweet.reply?.should be_true + expect(tweet.reply?).to be_truthy end it "returns false when in_reply_to_status_id is not set" do tweet = Twitter::Tweet.new(:id => 28669546014) - tweet.reply?.should be_false + expect(tweet.reply?).to be_falsey end end describe "#retweet?" do it "returns true when there is a retweeted status" do tweet = Twitter::Tweet.new(:id => 28669546014, :retweeted_status => {:id => 28561922516, :text => 'BOOSH'}) - tweet.retweet?.should be_true + expect(tweet.retweet?).to be_truthy end it "returns false when retweeted_status is not set" do tweet = Twitter::Tweet.new(:id => 28669546014) - tweet.retweet?.should be_false + expect(tweet.retweet?).to be_falsey end end describe "#retweeted_status" do it "has text when retweeted_status is set" do tweet = Twitter::Tweet.new(:id => 28669546014, :retweeted_status => {:id => 28561922516, :text => 'BOOSH'}) - tweet.retweeted_tweet.should be_a Twitter::Tweet - tweet.retweeted_tweet.text.should eq 'BOOSH' + expect(tweet.retweeted_tweet).to be_a Twitter::Tweet + expect(tweet.retweeted_tweet.text).to eq 'BOOSH' end it "returns nil when retweeted_status is not set" do tweet = Twitter::Tweet.new(:id => 28669546014) - tweet.retweeted_tweet.should be_nil + expect(tweet.retweeted_tweet).to be_nil end end describe "#retweeters_count" do it "returns the count of favoriters when retweet_count is set" do tweet = Twitter::Tweet.new(:id => 28669546014, :retweet_count => '1') - tweet.retweeters_count.should be_an Integer - tweet.retweeters_count.should eq 1 + expect(tweet.retweeters_count).to be_an Integer + expect(tweet.retweeters_count).to eq 1 end it "returns the count of favoriters when retweeters_count is set" do tweet = Twitter::Tweet.new(:id => 28669546014, :retweeters_count => '1') - tweet.retweeters_count.should be_an Integer - tweet.retweeters_count.should eq 1 + expect(tweet.retweeters_count).to be_an Integer + expect(tweet.retweeters_count).to eq 1 end it "returns nil when not set" do tweet = Twitter::Tweet.new(:id => 28669546014) - tweet.retweeters_count.should be_nil + expect(tweet.retweeters_count).to be_nil end end describe "#entities?" do it "returns false if there are no entities set" do tweet = Twitter::Tweet.new(:id => 28669546014) - tweet.entities?.should be_false + expect(tweet.entities?).to be_falsey end it "returns true if there are entities set" do @@ -243,7 +243,7 @@ } ] tweet = Twitter::Tweet.new(:id => 28669546014, :entities => {:urls => urls_hash}) - tweet.entities?.should be_true + expect(tweet.entities?).to be_truthy end end @@ -258,33 +258,33 @@ } ] urls = Twitter::Tweet.new(:id => 28669546014, :entities => {:urls => urls_hash}).urls - urls.should be_an Array - urls.first.should be_a Twitter::Entity::Url - urls.first.indices.should eq [10, 33] - urls.first.display_url.should eq 'example.com/expanded' + expect(urls).to be_an Array + expect(urls.first).to be_a Twitter::Entity::Url + expect(urls.first.indices).to eq [10, 33] + expect(urls.first.display_url).to eq 'example.com/expanded' end it "is empty when not set" do urls = Twitter::Tweet.new(:id => 28669546014).urls - urls.should be_empty + expect(urls).to be_empty end it "warns when not set" do Twitter::Tweet.new(:id => 28669546014).urls - $stderr.string.should =~ /To get urls, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./ + expect($stderr.string).to match(/To get urls, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./) end end describe "#user" do it "returns a User when user is set" do user = Twitter::Tweet.new(:id => 28669546014, :user => {:id => 7505382}).user - user.should be_a Twitter::User + expect(user).to be_a Twitter::User end it "returns nil when user is not set" do user = Twitter::Tweet.new(:id => 28669546014).user - user.should be_nil + expect(user).to be_nil end it "has a status when status is set" do user = Twitter::Tweet.new(:id => 28669546014, :text => 'Tweet text.', :user => {:id => 7505382}).user - user.status.should be_a Twitter::Tweet + expect(user.status).to be_a Twitter::Tweet end end @@ -300,18 +300,18 @@ } ] user_mentions = Twitter::Tweet.new(:id => 28669546014, :entities => {:user_mentions => user_mentions_hash}).user_mentions - user_mentions.should be_an Array - user_mentions.first.should be_a Twitter::Entity::UserMention - user_mentions.first.indices.should eq [0, 6] - user_mentions.first.id.should eq 7505382 + expect(user_mentions).to be_an Array + expect(user_mentions.first).to be_a Twitter::Entity::UserMention + expect(user_mentions.first.indices).to eq [0, 6] + expect(user_mentions.first.id).to eq 7505382 end it "is empty when not set" do user_mentions = Twitter::Tweet.new(:id => 28669546014).user_mentions - user_mentions.should be_empty + expect(user_mentions).to be_empty end it "warns when not set" do Twitter::Tweet.new(:id => 28669546014).user_mentions - $stderr.string.should =~ /To get user mentions, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./ + expect($stderr.string).to match(/To get user mentions, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./) end end diff --git a/spec/twitter/user_spec.rb b/spec/twitter/user_spec.rb index 41974ded4..d65751806 100644 --- a/spec/twitter/user_spec.rb +++ b/spec/twitter/user_spec.rb @@ -6,72 +6,72 @@ it "returns true when objects IDs are the same" do user = Twitter::User.new(:id => 1, :screen_name => "foo") other = Twitter::User.new(:id => 1, :screen_name => "bar") - (user == other).should be_true + expect(user == other).to be_truthy end it "returns false when objects IDs are different" do user = Twitter::User.new(:id => 1) other = Twitter::User.new(:id => 2) - (user == other).should be_false + expect(user == other).to be_falsey end it "returns false when classes are different" do user = Twitter::User.new(:id => 1) other = Twitter::Identity.new(:id => 1) - (user == other).should be_false + expect(user == other).to be_falsey end end describe "#created_at" do it "returns a Time when created_at is set" do user = Twitter::User.new(:id => 7505382, :created_at => "Mon Jul 16 12:59:01 +0000 2007") - user.created_at.should be_a Time + expect(user.created_at).to be_a Time end it "returns nil when created_at is not set" do user = Twitter::User.new(:id => 7505382) - user.created_at.should be_nil + expect(user.created_at).to be_nil end end describe "#profile_banner_url" do it "returns a String when profile_banner_url is set" do user = Twitter::User.new(:id => 7505382, :profile_banner_url => "https://si0.twimg.com/profile_banners/7505382/1348266581") - user.profile_banner_url.should be_a String + expect(user.profile_banner_url).to be_a String end it "returns nil when created_at is not set" do user = Twitter::User.new(:id => 7505382) - user.profile_banner_url.should be_nil + expect(user.profile_banner_url).to be_nil end it "returns the web-sized image" do user = Twitter::User.new(:id => 7505382, :profile_banner_url => "https://si0.twimg.com/profile_banners/7505382/1348266581") - user.profile_banner_url.should eq "http://si0.twimg.com/profile_banners/7505382/1348266581/web" + expect(user.profile_banner_url).to eq "http://si0.twimg.com/profile_banners/7505382/1348266581/web" end context "with :web_retina passed" do it "returns the web retina-sized image" do user = Twitter::User.new(:id => 7505382, :profile_banner_url => "https://si0.twimg.com/profile_banners/7505382/1348266581") - user.profile_banner_url(:web_retina).should eq "http://si0.twimg.com/profile_banners/7505382/1348266581/web_retina" + expect(user.profile_banner_url(:web_retina)).to eq "http://si0.twimg.com/profile_banners/7505382/1348266581/web_retina" end end context "with :mobile passed" do it "returns the mobile-sized image" do user = Twitter::User.new(:id => 7505382, :profile_banner_url => "https://si0.twimg.com/profile_banners/7505382/1348266581") - user.profile_banner_url(:mobile).should eq "http://si0.twimg.com/profile_banners/7505382/1348266581/mobile" + expect(user.profile_banner_url(:mobile)).to eq "http://si0.twimg.com/profile_banners/7505382/1348266581/mobile" end end context "with :mobile_retina passed" do it "returns the mobile retina-sized image" do user = Twitter::User.new(:id => 7505382, :profile_banner_url => "https://si0.twimg.com/profile_banners/7505382/1348266581") - user.profile_banner_url(:mobile_retina).should eq "http://si0.twimg.com/profile_banners/7505382/1348266581/mobile_retina" + expect(user.profile_banner_url(:mobile_retina)).to eq "http://si0.twimg.com/profile_banners/7505382/1348266581/mobile_retina" end end context "with :ipad passed" do it "returns the mobile-sized image" do user = Twitter::User.new(:id => 7505382, :profile_banner_url => "https://si0.twimg.com/profile_banners/7505382/1348266581") - user.profile_banner_url(:ipad).should eq "http://si0.twimg.com/profile_banners/7505382/1348266581/ipad" + expect(user.profile_banner_url(:ipad)).to eq "http://si0.twimg.com/profile_banners/7505382/1348266581/ipad" end end context "with :ipad_retina passed" do it "returns the mobile retina-sized image" do user = Twitter::User.new(:id => 7505382, :profile_banner_url => "https://si0.twimg.com/profile_banners/7505382/1348266581") - user.profile_banner_url(:ipad_retina).should eq "http://si0.twimg.com/profile_banners/7505382/1348266581/ipad_retina" + expect(user.profile_banner_url(:ipad_retina)).to eq "http://si0.twimg.com/profile_banners/7505382/1348266581/ipad_retina" end end end @@ -79,44 +79,44 @@ describe "#profile_banner_url_https" do it "returns a String when profile_banner_url is set" do user = Twitter::User.new(:id => 7505382, :profile_banner_url => "https://si0.twimg.com/profile_banners/7505382/1348266581") - user.profile_banner_url_https.should be_a String + expect(user.profile_banner_url_https).to be_a String end it "returns nil when created_at is not set" do user = Twitter::User.new(:id => 7505382) - user.profile_banner_url_https.should be_nil + expect(user.profile_banner_url_https).to be_nil end it "returns the web-sized image" do user = Twitter::User.new(:id => 7505382, :profile_banner_url => "https://si0.twimg.com/profile_banners/7505382/1348266581") - user.profile_banner_url_https.should eq "https://si0.twimg.com/profile_banners/7505382/1348266581/web" + expect(user.profile_banner_url_https).to eq "https://si0.twimg.com/profile_banners/7505382/1348266581/web" end context "with :web_retina passed" do it "returns the web retina-sized image" do user = Twitter::User.new(:id => 7505382, :profile_banner_url => "https://si0.twimg.com/profile_banners/7505382/1348266581") - user.profile_banner_url_https(:web_retina).should eq "https://si0.twimg.com/profile_banners/7505382/1348266581/web_retina" + expect(user.profile_banner_url_https(:web_retina)).to eq "https://si0.twimg.com/profile_banners/7505382/1348266581/web_retina" end end context "with :mobile passed" do it "returns the mobile-sized image" do user = Twitter::User.new(:id => 7505382, :profile_banner_url => "https://si0.twimg.com/profile_banners/7505382/1348266581") - user.profile_banner_url_https(:mobile).should eq "https://si0.twimg.com/profile_banners/7505382/1348266581/mobile" + expect(user.profile_banner_url_https(:mobile)).to eq "https://si0.twimg.com/profile_banners/7505382/1348266581/mobile" end end context "with :mobile_retina passed" do it "returns the mobile retina-sized image" do user = Twitter::User.new(:id => 7505382, :profile_banner_url => "https://si0.twimg.com/profile_banners/7505382/1348266581") - user.profile_banner_url_https(:mobile_retina).should eq "https://si0.twimg.com/profile_banners/7505382/1348266581/mobile_retina" + expect(user.profile_banner_url_https(:mobile_retina)).to eq "https://si0.twimg.com/profile_banners/7505382/1348266581/mobile_retina" end end context "with :ipad passed" do it "returns the mobile-sized image" do user = Twitter::User.new(:id => 7505382, :profile_banner_url => "https://si0.twimg.com/profile_banners/7505382/1348266581") - user.profile_banner_url_https(:ipad).should eq "https://si0.twimg.com/profile_banners/7505382/1348266581/ipad" + expect(user.profile_banner_url_https(:ipad)).to eq "https://si0.twimg.com/profile_banners/7505382/1348266581/ipad" end end context "with :ipad_retina passed" do it "returns the mobile retina-sized image" do user = Twitter::User.new(:id => 7505382, :profile_banner_url => "https://si0.twimg.com/profile_banners/7505382/1348266581") - user.profile_banner_url_https(:ipad_retina).should eq "https://si0.twimg.com/profile_banners/7505382/1348266581/ipad_retina" + expect(user.profile_banner_url_https(:ipad_retina)).to eq "https://si0.twimg.com/profile_banners/7505382/1348266581/ipad_retina" end end end @@ -124,43 +124,43 @@ describe "#profile_banner_url?" do it "returns true when profile_banner_url is set" do profile_banner_url = Twitter::User.new(:id => 7505382, :profile_banner_url => "https://si0.twimg.com/profile_banners/7505382/1348266581").profile_banner_url? - profile_banner_url.should be_true + expect(profile_banner_url).to be_truthy end it "returns false when status is not set" do profile_banner_url = Twitter::User.new(:id => 7505382).profile_banner_url? - profile_banner_url.should be_false + expect(profile_banner_url).to be_falsey end end describe "#profile_image_url" do it "returns a String when profile_image_url_https is set" do user = Twitter::User.new(:id => 7505382, :profile_image_url_https => "https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png") - user.profile_image_url.should be_a String + expect(user.profile_image_url).to be_a String end it "returns nil when created_at is not set" do user = Twitter::User.new(:id => 7505382) - user.profile_image_url.should be_nil + expect(user.profile_image_url).to be_nil end it "returns the normal-sized image" do user = Twitter::User.new(:id => 7505382, :profile_image_url_https => "https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png") - user.profile_image_url.should eq "http://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png" + expect(user.profile_image_url).to eq "http://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png" end context "with :original passed" do it "returns the original image" do user = Twitter::User.new(:id => 7505382, :profile_image_url_https => "https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png") - user.profile_image_url(:original).should eq "http://a0.twimg.com/profile_images/1759857427/image1326743606.png" + expect(user.profile_image_url(:original)).to eq "http://a0.twimg.com/profile_images/1759857427/image1326743606.png" end end context "with :bigger passed" do it "returns the bigger-sized image" do user = Twitter::User.new(:id => 7505382, :profile_image_url_https => "https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png") - user.profile_image_url(:bigger).should eq "http://a0.twimg.com/profile_images/1759857427/image1326743606_bigger.png" + expect(user.profile_image_url(:bigger)).to eq "http://a0.twimg.com/profile_images/1759857427/image1326743606_bigger.png" end end context "with :mini passed" do it "returns the mini-sized image" do user = Twitter::User.new(:id => 7505382, :profile_image_url_https => "https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png") - user.profile_image_url(:mini).should eq "http://a0.twimg.com/profile_images/1759857427/image1326743606_mini.png" + expect(user.profile_image_url(:mini)).to eq "http://a0.twimg.com/profile_images/1759857427/image1326743606_mini.png" end end end @@ -168,32 +168,32 @@ describe "#profile_image_url_https" do it "returns a String when profile_image_url_https is set" do user = Twitter::User.new(:id => 7505382, :profile_image_url_https => "https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png") - user.profile_image_url_https.should be_a String + expect(user.profile_image_url_https).to be_a String end it "returns nil when created_at is not set" do user = Twitter::User.new(:id => 7505382) - user.profile_image_url_https.should be_nil + expect(user.profile_image_url_https).to be_nil end it "returns the normal-sized image" do user = Twitter::User.new(:id => 7505382, :profile_image_url_https => "https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png") - user.profile_image_url_https.should eq "https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png" + expect(user.profile_image_url_https).to eq "https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png" end context "with :original passed" do it "returns the original image" do user = Twitter::User.new(:id => 7505382, :profile_image_url_https => "https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png") - user.profile_image_url_https(:original).should eq "https://a0.twimg.com/profile_images/1759857427/image1326743606.png" + expect(user.profile_image_url_https(:original)).to eq "https://a0.twimg.com/profile_images/1759857427/image1326743606.png" end end context "with :bigger passed" do it "returns the bigger-sized image" do user = Twitter::User.new(:id => 7505382, :profile_image_url_https => "https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png") - user.profile_image_url_https(:bigger).should eq "https://a0.twimg.com/profile_images/1759857427/image1326743606_bigger.png" + expect(user.profile_image_url_https(:bigger)).to eq "https://a0.twimg.com/profile_images/1759857427/image1326743606_bigger.png" end end context "with :mini passed" do it "returns the mini-sized image" do user = Twitter::User.new(:id => 7505382, :profile_image_url_https => "https://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png") - user.profile_image_url_https(:mini).should eq "https://a0.twimg.com/profile_images/1759857427/image1326743606_mini.png" + expect(user.profile_image_url_https(:mini)).to eq "https://a0.twimg.com/profile_images/1759857427/image1326743606_mini.png" end end end @@ -201,38 +201,38 @@ describe "#profile_image_url?" do it "returns true when profile_banner_url is set" do profile_image_url = Twitter::User.new(:id => 7505382, :profile_image_url_https => "https://si0.twimg.com/profile_banners/7505382/1348266581").profile_image_url? - profile_image_url.should be_true + expect(profile_image_url).to be_truthy end it "returns false when status is not set" do profile_image_url= Twitter::User.new(:id => 7505382).profile_image_url? - profile_image_url.should be_false + expect(profile_image_url).to be_falsey end end describe "#status" do it "returns a Status when status is set" do tweet = Twitter::User.new(:id => 7505382, :status => {:id => 25938088801}).status - tweet.should be_a Twitter::Tweet + expect(tweet).to be_a Twitter::Tweet end it "returns nil when status is not set" do tweet = Twitter::User.new(:id => 7505382).status - tweet.should be_nil + expect(tweet).to be_nil end it "includes a User when user is set" do tweet = Twitter::User.new(:id => 7505382, :screen_name => 'sferik', :status => {:id => 25938088801}).status - tweet.user.should be_a Twitter::User - tweet.user.id.should eq 7505382 + expect(tweet.user).to be_a Twitter::User + expect(tweet.user.id).to eq 7505382 end end describe "#status?" do it "returns true when status is set" do tweet = Twitter::User.new(:id => 7505382, :status => {:id => 25938088801}).status? - tweet.should be_true + expect(tweet).to be_truthy end it "returns false when status is not set" do tweet = Twitter::User.new(:id => 7505382).status? - tweet.should be_false + expect(tweet).to be_falsey end end diff --git a/spec/twitter_spec.rb b/spec/twitter_spec.rb index f69b258d2..c78aae561 100644 --- a/spec/twitter_spec.rb +++ b/spec/twitter_spec.rb @@ -16,34 +16,34 @@ it "requests the correct resource" do Twitter.user_timeline('sferik') - a_get("/1.1/statuses/user_timeline.json"). - with(:query => {:screen_name => "sferik"}). - should have_been_made + expect(a_get("/1.1/statuses/user_timeline.json"). + with(:query => {:screen_name => "sferik"})). + to have_been_made end it "returns the same results as a client" do - Twitter.user_timeline('sferik').should eq Twitter::Client.new.user_timeline('sferik') + expect(Twitter.user_timeline('sferik')).to eq Twitter::Client.new.user_timeline('sferik') end end describe '.respond_to?' do it "delegates to Twitter::Client" do - Twitter.respond_to?(:user).should be_true + expect(Twitter.respond_to?(:user)).to be_truthy end it "takes an optional argument" do - Twitter.respond_to?(:client, true).should be_true + expect(Twitter.respond_to?(:client, true)).to be_truthy end end describe ".client" do it "returns a Twitter::Client" do - Twitter.client.should be_a Twitter::Client + expect(Twitter.client).to be_a Twitter::Client end context "when the options don't change" do it "caches the client" do - Twitter.client.should eq Twitter.client + expect(Twitter.client).to eq Twitter.client end end context "when the options change" do @@ -54,7 +54,7 @@ config.consumer_secret = '123' end client2 = Twitter.client - client1.should_not eq client2 + expect(client1).not_to eq client2 end end end @@ -65,7 +65,7 @@ Twitter.configure do |config| config.send("#{key}=", key) end - Twitter.instance_variable_get(:"@#{key}").should eq key + expect(Twitter.instance_variable_get(:"@#{key}")).to eq key end end end @@ -78,7 +78,7 @@ config.oauth_token = 'OT' config.oauth_token_secret = 'OS' end - Twitter.credentials?.should be_true + expect(Twitter.credentials?).to be_truthy end it "returns false if any credentials are missing" do Twitter.configure do |config| @@ -86,7 +86,7 @@ config.consumer_secret = 'CS' config.oauth_token = 'OT' end - Twitter.credentials?.should be_false + expect(Twitter.credentials?).to be_falsey end end