Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use a consistent expectation style in tests #273

Merged
merged 1 commit into from
Jun 15, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions spec/faraday/response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
to_return(:status => status)
end

it "should raise #{exception.name} error" do
it "raises #{exception.name}" do
lambda do
@client.user_timeline('sferik')
end.should raise_error(exception)
Expand All @@ -39,7 +39,7 @@
to_return(:status => status, :body => body_message)
end

it "should raise #{exception.name} error" do
it "raises #{exception.name}" do
lambda do
@client.user_timeline('sferik')
end.should raise_error(exception)
Expand All @@ -55,7 +55,7 @@
with(:query => {:screen_name => "not_on_twitter"}).
to_return(:status => 404, :body => fixture('no_user_matches.json'))
end
it "should raise Twitter::Error::NotFound" do
it "raises Twitter::Error::NotFound" do
lambda do
@client.users('not_on_twitter')
end.should raise_error(Twitter::Error::NotFound)
Expand Down
14 changes: 7 additions & 7 deletions spec/twitter/action_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@
describe Twitter::ActionFactory do

describe ".new" do
it "should generate a Favorite" do
it "generates a Favorite" do
action = Twitter::ActionFactory.new('action' => 'favorite')
action.should be_a Twitter::Favorite
end
it "should generate a Follow" do
it "generates a Follow" do
action = Twitter::ActionFactory.new('action' => 'follow')
action.should be_a Twitter::Follow
end
it "should generate a ListMemberAdded" do
it "generates a ListMemberAdded" do
action = Twitter::ActionFactory.new('action' => 'list_member_added')
action.should be_a Twitter::ListMemberAdded
end
it "should generate a Mention" do
it "generates a Mention" do
action = Twitter::ActionFactory.new('action' => 'mention')
action.should be_a Twitter::Mention
end
it "should generate a Reply" do
it "generates a Reply" do
action = Twitter::ActionFactory.new('action' => 'reply')
action.should be_a Twitter::Reply
end
it "should generate a Retweet" do
it "generates a Retweet" do
action = Twitter::ActionFactory.new('action' => 'retweet')
action.should be_a Twitter::Retweet
end
it "should raise an ArgumentError when action is not specified" do
it "raises an ArgumentError when action is not specified" do
lambda do
Twitter::ActionFactory.new({})
end.should raise_error(ArgumentError, "argument must have an 'action' key")
Expand Down
4 changes: 2 additions & 2 deletions spec/twitter/action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
describe Twitter::Action do

describe "#created_at" do
it "should return a Time when created_at is set" do
it "returns a Time when created_at is set" do
user = Twitter::User.new('created_at' => "Mon Jul 16 12:59:01 +0000 2007")
user.created_at.should be_a Time
end
it "should return nil when created_at is not set" do
it "returns nil when created_at is not set" do
user = Twitter::User.new
user.created_at.should be_nil
end
Expand Down
10 changes: 5 additions & 5 deletions spec/twitter/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@
end

describe "#[]" do
it "should be able to call methods using [] with symbol" do
it "calls methods using [] with symbol" do
@base[:object_id].should be_an Integer
end
it "should be able to call methods using [] with string" do
it "calls methods using [] with string" do
@base['object_id'].should be_an Integer
end
it "should return nil for missing method" do
it "returns nil for missing method" do
@base[:foo].should be_nil
@base['foo'].should be_nil
end
end

describe "#to_hash" do
it "should return a hash" do
it "returns a hash" do
@base.to_hash.should be_a Hash
@base.to_hash['id'].should == 1
end
end

describe "identical objects" do
it "should have the same object_id" do
it "have the same object_id" do
@base.object_id.should == Twitter::Base.get('id' => 1).object_id
end
end
Expand Down
40 changes: 20 additions & 20 deletions spec/twitter/client/accounts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
stub_get("/1/account/rate_limit_status.json").
to_return(:body => fixture("rate_limit_status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "should request the correct resource" do
it "requests the correct resource" do
@client.rate_limit_status
a_get("/1/account/rate_limit_status.json").
should have_been_made
end
it "should return the remaining number of API requests available to the requesting user before the API limit is reached" do
it "returns the remaining number of API requests available to the requesting user before the API limit is reached" do
rate_limit_status = @client.rate_limit_status
rate_limit_status.should be_a Twitter::RateLimitStatus
rate_limit_status.remaining_hits.should == 19993
Expand All @@ -28,12 +28,12 @@
stub_get("/1/account/verify_credentials.json").
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "should request the correct resource" do
it "requests the correct resource" do
@client.verify_credentials
a_get("/1/account/verify_credentials.json").
should have_been_made
end
it "should return the requesting user" do
it "returns the requesting user" do
user = @client.verify_credentials
user.should be_a Twitter::User
user.name.should == "Erik Michaels-Ober"
Expand All @@ -45,12 +45,12 @@
stub_post("/1/account/end_session.json").
to_return(:body => fixture("end_session.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "should request the correct resource" do
it "requests the correct resource" do
@client.end_session
a_post("/1/account/end_session.json").
should have_been_made
end
it "should return a null cookie" do
it "returns a null cookie" do
end_session = @client.end_session
end_session['error'].should == "Logged out."
end
Expand All @@ -62,13 +62,13 @@
with(:body => {:device => "sms"}).
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "should request the correct resource" do
it "requests the correct resource" do
@client.update_delivery_device("sms")
a_post("/1/account/update_delivery_device.json").
with(:body => {:device => "sms"}).
should have_been_made
end
it "should return a user" do
it "returns a user" do
user = @client.update_delivery_device("sms")
user.should be_a Twitter::User
user.name.should == "Erik Michaels-Ober"
Expand All @@ -81,13 +81,13 @@
with(:body => {:url => "http://github.com/sferik/"}).
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "should request the correct resource" do
it "requests the correct resource" do
@client.update_profile(:url => "http://github.com/sferik/")
a_post("/1/account/update_profile.json").
with(:body => {:url => "http://github.com/sferik/"}).
should have_been_made
end
it "should return a user" do
it "returns a user" do
user = @client.update_profile(:url => "http://github.com/sferik/")
user.should be_a Twitter::User
user.name.should == "Erik Michaels-Ober"
Expand All @@ -99,12 +99,12 @@
stub_post("/1/account/update_profile_background_image.json").
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "should request the correct resource" do
it "requests the correct resource" do
@client.update_profile_background_image(fixture("we_concept_bg2.png"))
a_post("/1/account/update_profile_background_image.json").
should have_been_made
end
it "should return a user" do
it "returns a user" do
user = @client.update_profile_background_image(fixture("we_concept_bg2.png"))
user.should be_a Twitter::User
user.name.should == "Erik Michaels-Ober"
Expand All @@ -117,13 +117,13 @@
with(:body => {:profile_background_color => "000000"}).
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "should request the correct resource" do
it "requests the correct resource" do
@client.update_profile_colors(:profile_background_color => "000000")
a_post("/1/account/update_profile_colors.json").
with(:body => {:profile_background_color => "000000"}).
should have_been_made
end
it "should return a user" do
it "returns a user" do
user = @client.update_profile_colors(:profile_background_color => "000000")
user.should be_a Twitter::User
user.name.should == "Erik Michaels-Ober"
Expand All @@ -135,12 +135,12 @@
stub_post("/1/account/update_profile_image.json").
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "should request the correct resource" do
it "requests the correct resource" do
@client.update_profile_image(fixture("me.jpeg"))
a_post("/1/account/update_profile_image.json").
should have_been_made
end
it "should return a user" do
it "returns a user" do
user = @client.update_profile_image(fixture("me.jpeg"))
user.should be_a Twitter::User
user.name.should == "Erik Michaels-Ober"
Expand All @@ -155,23 +155,23 @@
with(:body => {:trend_location_woeid => "23424803"}).
to_return(:body => fixture("settings.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "should request the correct resource on GET" do
it "requests the correct resource on GET" do
@client.settings
a_get("/1/account/settings.json").
should have_been_made
end
it "should return settings" do
it "returns settings" do
settings = @client.settings
settings.should be_a Twitter::Settings
settings.language.should == 'en'
end
it "should request the correct resource on POST" do
it "requests the correct resource on POST" do
@client.settings(:trend_location_woeid => "23424803")
a_post("/1/account/settings.json").
with(:body => {:trend_location_woeid => "23424803"}).
should have_been_made
end
it "should return settings" do
it "returns settings" do
settings = @client.settings(:trend_location_woeid => "23424803")
settings.should be_a Twitter::Settings
settings.language.should == 'en'
Expand Down
8 changes: 4 additions & 4 deletions spec/twitter/client/activity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
stub_get("/i/activity/about_me.json").
to_return(:body => fixture("about_me.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "should request the correct resource" do
it "requests the correct resource" do
@client.activity_about_me
a_get("/i/activity/about_me.json").
should have_been_made
end
it "should return activity about me" do
it "returns activity about me" do
activity_about_me = @client.activity_about_me
activity_about_me.first.should be_a Twitter::Mention
end
Expand All @@ -27,12 +27,12 @@
stub_get("/i/activity/by_friends.json").
to_return(:body => fixture("by_friends.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "should request the correct resource" do
it "requests the correct resource" do
@client.activity_by_friends
a_get("/i/activity/by_friends.json").
should have_been_made
end
it "should return activity by friends" do
it "returns activity by friends" do
activity_by_friends = @client.activity_by_friends
activity_by_friends.first.should be_a Twitter::Favorite
end
Expand Down
22 changes: 11 additions & 11 deletions spec/twitter/client/block_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
stub_get("/1/blocks/blocking.json").
to_return(:body => fixture("users.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "should request the correct resource" do
it "requests the correct resource" do
@client.blocking
a_get("/1/blocks/blocking.json").
should have_been_made
end
it "should return an array of user objects that the authenticating user is blocking" do
it "returns an array of user objects that the authenticating user is blocking" do
users = @client.blocking
users.should be_an Array
users.first.should be_a Twitter::User
Expand All @@ -29,12 +29,12 @@
stub_get("/1/blocks/blocking/ids.json").
to_return(:body => fixture("ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "should request the correct resource" do
it "requests the correct resource" do
@client.blocked_ids
a_get("/1/blocks/blocking/ids.json").
should have_been_made
end
it "should return an array of numeric user IDs the authenticating user is blocking" do
it "returns an array of numeric user IDs the authenticating user is blocking" do
ids = @client.blocked_ids
ids.should be_an Array
ids.first.should == 47
Expand All @@ -50,17 +50,17 @@
with(:query => {:screen_name => "pengwynn"}).
to_return(:body => fixture("not_found.json"), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"})
end
it "should request the correct resource" do
it "requests the correct resource" do
@client.block?("sferik")
a_get("/1/blocks/exists.json").
with(:query => {:screen_name => "sferik"}).
should have_been_made
end
it "should return true if block exists" do
it "returns true if block exists" do
block = @client.block?("sferik")
block.should be_true
end
it "should return false if block does not exist" do
it "returns false if block does not exist" do
block = @client.block?("pengwynn")
block.should be_false
end
Expand All @@ -72,12 +72,12 @@
with(:body => {:screen_name => "sferik"}).
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "should request the correct resource" do
it "requests the correct resource" do
@client.block("sferik")
a_post("/1/blocks/create.json").
should have_been_made
end
it "should return an array of blocked users" do
it "returns an array of blocked users" do
users = @client.block("sferik")
users.should be_an Array
users.first.should be_a Twitter::User
Expand All @@ -91,13 +91,13 @@
with(:query => {:screen_name => "sferik"}).
to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
it "should request the correct resource" do
it "requests the correct resource" do
@client.unblock("sferik")
a_delete("/1/blocks/destroy.json").
with(:query => {:screen_name => "sferik"}).
should have_been_made
end
it "should return an array of un-blocked users" do
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
Expand Down
Loading