Skip to content

Commit

Permalink
Convert specs to the new RSpec expectation syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Oct 10, 2012
1 parent a606cba commit 13e211e
Show file tree
Hide file tree
Showing 56 changed files with 1,153 additions and 1,933 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -354,7 +354,7 @@ recommend [Oj][].
Here are some fun facts about this library:

* It is implemented in just 2,000 lines of Ruby code
* With over 5,000 lines of specs, the spec-to-code ratio is over 2.5:1
* With over 4,000 lines of specs, the spec-to-code ratio is over 2:1
* The spec suite contains over 600 examples and runs in under 2 seconds
* It has 100% C0 code coverage (the tests execute every line of
source code at least once)
Expand Down
6 changes: 6 additions & 0 deletions spec/helper.rb
Expand Up @@ -12,6 +12,12 @@
require 'timecop'
require 'webmock/rspec'

RSpec.configure do |config|
config.expect_with :rspec do |c|
c.syntax = :expect
end
end

def a_delete(path)
a_request(:delete, 'https://api.twitter.com' + path)
end
Expand Down
12 changes: 6 additions & 6 deletions spec/twitter/action/favorite_spec.rb
Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions spec/twitter/action/follow_spec.rb
Expand Up @@ -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

Expand Down
18 changes: 9 additions & 9 deletions spec/twitter/action/list_member_added_spec.rb
Expand Up @@ -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

Expand Down
22 changes: 11 additions & 11 deletions spec/twitter/action/mention_spec.rb
Expand Up @@ -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

Expand Down
18 changes: 9 additions & 9 deletions spec/twitter/action/reply_spec.rb
Expand Up @@ -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

Expand Down
18 changes: 9 additions & 9 deletions spec/twitter/action/retweet_spec.rb
Expand Up @@ -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

Expand Down
16 changes: 7 additions & 9 deletions spec/twitter/action_factory_spec.rb
Expand Up @@ -5,32 +5,30 @@
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
Twitter::ActionFactory.fetch_or_new
end.should raise_error(ArgumentError, "argument must have :action key")
expect{Twitter::ActionFactory.fetch_or_new}.to raise_error(ArgumentError, "argument must have :action key")
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/twitter/action_spec.rb
Expand Up @@ -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

Expand Down

0 comments on commit 13e211e

Please sign in to comment.