mirror of
https://github.com/samsonjs/instapaper.git
synced 2026-03-25 08:55:49 +00:00
update rspec to 3.2
This commit is contained in:
parent
da3498ac38
commit
d3f08bc508
8 changed files with 101 additions and 101 deletions
2
Gemfile
2
Gemfile
|
|
@ -9,7 +9,7 @@ end
|
|||
|
||||
group :test do
|
||||
gem 'json', :platforms => :ruby_18
|
||||
gem 'rspec', '~> 2.99'
|
||||
gem 'rspec', '~> 3.2'
|
||||
gem 'timecop'
|
||||
gem 'webmock', '>= 1.10.1'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ describe Faraday::Response do
|
|||
end
|
||||
|
||||
it "should raise Instapaper::Error error" do
|
||||
lambda do
|
||||
expect do
|
||||
@client.folders
|
||||
end.should raise_error(Instapaper::Error)
|
||||
end.to raise_error(Instapaper::Error)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,14 +13,14 @@ describe Instapaper::Client::Account do
|
|||
|
||||
it "should get the correct resource" do
|
||||
@client.verify_credentials
|
||||
a_post("account/verify_credentials").
|
||||
should have_been_made
|
||||
expect(a_post("account/verify_credentials")).
|
||||
to have_been_made
|
||||
end
|
||||
|
||||
it "should return the user" do
|
||||
user = @client.verify_credentials.first
|
||||
user.should be_a Hashie::Rash
|
||||
user.username.should == 'TestUserOMGLOL'
|
||||
expect(user).to be_a Hashie::Rash
|
||||
expect(user.username).to eq('TestUserOMGLOL')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -13,21 +13,21 @@ describe Instapaper::Client::Bookmark do
|
|||
|
||||
it "should get the correct resource" do
|
||||
@client.bookmarks
|
||||
a_post("bookmarks/list").
|
||||
should have_been_made
|
||||
expect(a_post("bookmarks/list")).
|
||||
to have_been_made
|
||||
end
|
||||
|
||||
it "should return an array containing bookmarks on success" do
|
||||
bookmarks = @client.bookmarks
|
||||
bookmarks.should be_an Array
|
||||
bookmarks.size.should == 2
|
||||
expect(bookmarks).to be_an Array
|
||||
expect(bookmarks.size).to eq(2)
|
||||
end
|
||||
|
||||
it "should remove the meta and current user objects from the array" do
|
||||
bookmarks = @client.bookmarks
|
||||
bookmarks.each do |bookmark|
|
||||
bookmark.should be_a Hashie::Rash
|
||||
bookmark.type.should == 'bookmark'
|
||||
expect(bookmark).to be_a Hashie::Rash
|
||||
expect(bookmark.type).to eq('bookmark')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -41,15 +41,15 @@ describe Instapaper::Client::Bookmark do
|
|||
|
||||
it "should get the correct resource" do
|
||||
@client.update_read_progress(123, 0.5, @time)
|
||||
a_post("bookmarks/update_read_progress").with(:body => {:bookmark_id => "123", :progress => '0.5', :progress_timestamp => @time.to_i.to_s }).
|
||||
should have_been_made
|
||||
expect(a_post("bookmarks/update_read_progress").with(:body => {:bookmark_id => "123", :progress => '0.5', :progress_timestamp => @time.to_i.to_s })).
|
||||
to have_been_made
|
||||
end
|
||||
|
||||
it "should return an array containing bookmarks on success" do
|
||||
bookmark = @client.update_read_progress(123, 0.5, @time)
|
||||
bookmark.should be_a Hashie::Rash
|
||||
bookmark.type.should == 'bookmark'
|
||||
bookmark.progress.should == "0.5"
|
||||
expect(bookmark).to be_a Hashie::Rash
|
||||
expect(bookmark.type).to eq('bookmark')
|
||||
expect(bookmark.progress).to eq("0.5")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -61,14 +61,14 @@ describe Instapaper::Client::Bookmark do
|
|||
|
||||
it "should get the correct resource" do
|
||||
@client.add_bookmark('http://someurl.com', :title => 'This is the title', :description => 'This is the description')
|
||||
a_post("bookmarks/add").with(:body => {:url => "http://someurl.com", :title => 'This is the title', :description => 'This is the description' }).
|
||||
should have_been_made
|
||||
expect(a_post("bookmarks/add").with(:body => {:url => "http://someurl.com", :title => 'This is the title', :description => 'This is the description' })).
|
||||
to have_been_made
|
||||
end
|
||||
|
||||
it "should return the bookmark on success" do
|
||||
bookmark = @client.add_bookmark('http://someurl.com', :title => 'This is the title', :description => 'This is the description')
|
||||
bookmark.should be_a Hashie::Rash
|
||||
bookmark.type.should == 'bookmark'
|
||||
expect(bookmark).to be_a Hashie::Rash
|
||||
expect(bookmark.type).to eq('bookmark')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -80,14 +80,14 @@ describe Instapaper::Client::Bookmark do
|
|||
|
||||
it "should get the correct resource" do
|
||||
@client.delete_bookmark(123)
|
||||
a_post("bookmarks/delete").with(:body => {:bookmark_id => "123" }).
|
||||
should have_been_made
|
||||
expect(a_post("bookmarks/delete").with(:body => {:bookmark_id => "123" })).
|
||||
to have_been_made
|
||||
end
|
||||
|
||||
it "should return an array containing bookmarks on success" do
|
||||
confirm = @client.delete_bookmark(123)
|
||||
confirm.should be_an Array
|
||||
confirm.should be_empty
|
||||
expect(confirm).to be_an Array
|
||||
expect(confirm).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -99,19 +99,19 @@ describe Instapaper::Client::Bookmark do
|
|||
|
||||
it "should get the correct resource" do
|
||||
@client.star(123)
|
||||
a_post("bookmarks/star").with(:body => {:bookmark_id => "123" }).
|
||||
should have_been_made
|
||||
expect(a_post("bookmarks/star").with(:body => {:bookmark_id => "123" })).
|
||||
to have_been_made
|
||||
end
|
||||
|
||||
it "should return a starred bookmark on success" do
|
||||
bookmark = @client.star(123)
|
||||
bookmark.should be_a Hashie::Rash
|
||||
bookmark.type.should == 'bookmark'
|
||||
bookmark.starred.should == '1'
|
||||
expect(bookmark).to be_a Hashie::Rash
|
||||
expect(bookmark.type).to eq('bookmark')
|
||||
expect(bookmark.starred).to eq('1')
|
||||
end
|
||||
|
||||
it 'should be aliased as .star_bookmark' do
|
||||
@client.star(123).should == @client.star_bookmark(123)
|
||||
expect(@client.star(123)).to eq(@client.star_bookmark(123))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -123,19 +123,19 @@ describe Instapaper::Client::Bookmark do
|
|||
|
||||
it "should get the correct resource" do
|
||||
@client.unstar(123)
|
||||
a_post("bookmarks/unstar").with(:body => {:bookmark_id => "123" }).
|
||||
should have_been_made
|
||||
expect(a_post("bookmarks/unstar").with(:body => {:bookmark_id => "123" })).
|
||||
to have_been_made
|
||||
end
|
||||
|
||||
it "should return an unstarred bookmark on success" do
|
||||
bookmark = @client.unstar(123)
|
||||
bookmark.should be_a Hashie::Rash
|
||||
bookmark.type.should == 'bookmark'
|
||||
bookmark.starred.should == '0'
|
||||
expect(bookmark).to be_a Hashie::Rash
|
||||
expect(bookmark.type).to eq('bookmark')
|
||||
expect(bookmark.starred).to eq('0')
|
||||
end
|
||||
|
||||
it 'should be aliased as .unstar_bookmark' do
|
||||
@client.unstar(123).should == @client.unstar_bookmark(123)
|
||||
expect(@client.unstar(123)).to eq(@client.unstar_bookmark(123))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -147,18 +147,18 @@ describe Instapaper::Client::Bookmark do
|
|||
|
||||
it "should get the correct resource" do
|
||||
@client.archive(123)
|
||||
a_post("bookmarks/archive").with(:body => {:bookmark_id => "123" }).
|
||||
should have_been_made
|
||||
expect(a_post("bookmarks/archive").with(:body => {:bookmark_id => "123" })).
|
||||
to have_been_made
|
||||
end
|
||||
|
||||
it "should return the bookmark on success" do
|
||||
bookmark = @client.archive(123)
|
||||
bookmark.should be_a Hashie::Rash
|
||||
bookmark.type.should == 'bookmark'
|
||||
expect(bookmark).to be_a Hashie::Rash
|
||||
expect(bookmark.type).to eq('bookmark')
|
||||
end
|
||||
|
||||
it 'should be aliased as .archive_bookmark' do
|
||||
@client.archive(123).should == @client.archive_bookmark(123)
|
||||
expect(@client.archive(123)).to eq(@client.archive_bookmark(123))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -170,18 +170,18 @@ describe Instapaper::Client::Bookmark do
|
|||
|
||||
it "should get the correct resource" do
|
||||
@client.unarchive(123)
|
||||
a_post("bookmarks/unarchive").with(:body => {:bookmark_id => "123" }).
|
||||
should have_been_made
|
||||
expect(a_post("bookmarks/unarchive").with(:body => {:bookmark_id => "123" })).
|
||||
to have_been_made
|
||||
end
|
||||
|
||||
it "should return the bookmark on success" do
|
||||
bookmark = @client.unarchive(123)
|
||||
bookmark.should be_a Hashie::Rash
|
||||
bookmark.type.should == 'bookmark'
|
||||
expect(bookmark).to be_a Hashie::Rash
|
||||
expect(bookmark.type).to eq('bookmark')
|
||||
end
|
||||
|
||||
it 'should be aliased as .unarchive_bookmark' do
|
||||
@client.unarchive(123).should == @client.unarchive_bookmark(123)
|
||||
expect(@client.unarchive(123)).to eq(@client.unarchive_bookmark(123))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -193,18 +193,18 @@ describe Instapaper::Client::Bookmark do
|
|||
|
||||
it "should get the correct resource" do
|
||||
@client.move(123, 12345)
|
||||
a_post("bookmarks/move").with(:body => {:bookmark_id => "123", :folder_id => "12345" }).
|
||||
should have_been_made
|
||||
expect(a_post("bookmarks/move").with(:body => {:bookmark_id => "123", :folder_id => "12345" })).
|
||||
to have_been_made
|
||||
end
|
||||
|
||||
it "should return the bookmark on success" do
|
||||
bookmark = @client.move(123, 12345)
|
||||
bookmark.should be_a Hashie::Rash
|
||||
bookmark.type.should == 'bookmark'
|
||||
expect(bookmark).to be_a Hashie::Rash
|
||||
expect(bookmark.type).to eq('bookmark')
|
||||
end
|
||||
|
||||
it 'should be aliased as .move_bookmark' do
|
||||
@client.move(123, 12345).should == @client.move_bookmark(123, 12345)
|
||||
expect(@client.move(123, 12345)).to eq(@client.move_bookmark(123, 12345))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -216,18 +216,18 @@ describe Instapaper::Client::Bookmark do
|
|||
|
||||
it "should get the correct resource" do
|
||||
@client.text(123)
|
||||
a_post("bookmarks/get_text").with(:body => {:bookmark_id => "123" }).
|
||||
should have_been_made
|
||||
expect(a_post("bookmarks/get_text").with(:body => {:bookmark_id => "123" })).
|
||||
to have_been_made
|
||||
end
|
||||
|
||||
it "should return the bookmark's html on success" do
|
||||
bookmark = @client.text(123)
|
||||
bookmark.length.should > 0
|
||||
bookmark.should include("Ideo's Axioms for Starting Disruptive New Businesses")
|
||||
expect(bookmark.length).to be > 0
|
||||
expect(bookmark).to include("Ideo's Axioms for Starting Disruptive New Businesses")
|
||||
end
|
||||
|
||||
it 'should be aliased as .get_text' do
|
||||
@client.text(123).should == @client.get_text(123)
|
||||
expect(@client.text(123)).to eq(@client.get_text(123))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -13,16 +13,16 @@ describe Instapaper::Client::Folder do
|
|||
|
||||
it "should get the correct resource" do
|
||||
@client.folders
|
||||
a_post("folders/list").
|
||||
should have_been_made
|
||||
expect(a_post("folders/list")).
|
||||
to have_been_made
|
||||
end
|
||||
|
||||
it "should return an array containing folders on success" do
|
||||
folders = @client.folders
|
||||
folders.should be_an Array
|
||||
folders.size.should == 2
|
||||
folders.first.should be_a Hashie::Rash
|
||||
folders.first['title'].should == 'Ruby'
|
||||
expect(folders).to be_an Array
|
||||
expect(folders.size).to eq(2)
|
||||
expect(folders.first).to be_a Hashie::Rash
|
||||
expect(folders.first['title']).to eq('Ruby')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -34,16 +34,16 @@ describe Instapaper::Client::Folder do
|
|||
|
||||
it "should get the correct resource" do
|
||||
@client.add_folder("Ruby")
|
||||
a_post("folders/add").
|
||||
should have_been_made
|
||||
expect(a_post("folders/add")).
|
||||
to have_been_made
|
||||
end
|
||||
|
||||
it "should return an array containing the new folder on success" do
|
||||
folders = @client.add_folder("Ruby")
|
||||
folders.should be_an Array
|
||||
folders.should_not be_empty
|
||||
folders.first.should be_a Hashie::Rash
|
||||
folders.first['title'].should == 'Ruby'
|
||||
expect(folders).to be_an Array
|
||||
expect(folders).not_to be_empty
|
||||
expect(folders.first).to be_a Hashie::Rash
|
||||
expect(folders.first['title']).to eq('Ruby')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -55,14 +55,14 @@ describe Instapaper::Client::Folder do
|
|||
|
||||
it "should get the correct resource" do
|
||||
@client.delete_folder("1")
|
||||
a_post("folders/delete").
|
||||
should have_been_made
|
||||
expect(a_post("folders/delete")).
|
||||
to have_been_made
|
||||
end
|
||||
|
||||
it "should return an empty array on success" do
|
||||
confirm = @client.delete_folder("1")
|
||||
confirm.should be_an Array
|
||||
confirm.should be_empty
|
||||
expect(confirm).to be_an Array
|
||||
expect(confirm).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -74,15 +74,15 @@ describe Instapaper::Client::Folder do
|
|||
|
||||
it "should get the correct resource" do
|
||||
@client.set_order(['1121173:2','1121174:1'])
|
||||
a_post("folders/set_order").
|
||||
should have_been_made
|
||||
expect(a_post("folders/set_order")).
|
||||
to have_been_made
|
||||
end
|
||||
|
||||
it "should return an array reflecting the new order on success" do
|
||||
folders = @client.set_order(['1121173:2','1121174:1'])
|
||||
folders.should be_an Array
|
||||
folders.first.should be_a Hashie::Rash
|
||||
folders.first['position'].should == 1
|
||||
expect(folders).to be_an Array
|
||||
expect(folders.first).to be_a Hashie::Rash
|
||||
expect(folders.first['position']).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -15,21 +15,21 @@ describe Instapaper::Client::User do
|
|||
|
||||
it "should get the correct resource" do
|
||||
@client.access_token('ohai', 'p455w0rd')
|
||||
a_post("oauth/access_token").
|
||||
should have_been_made
|
||||
expect(a_post("oauth/access_token")).
|
||||
to have_been_made
|
||||
end
|
||||
|
||||
it "should return the a hash containing an oauth token and secret" do
|
||||
tokens = @client.access_token('ohai', 'p455w0rd')
|
||||
tokens.should be_a Hash
|
||||
tokens.key?('oauth_token').should be true
|
||||
tokens.key?('oauth_token_secret').should be true
|
||||
expect(tokens).to be_a Hash
|
||||
expect(tokens.key?('oauth_token')).to be true
|
||||
expect(tokens.key?('oauth_token_secret')).to be true
|
||||
end
|
||||
|
||||
it "should return a hash containing the error on invalid credentials" do
|
||||
tokens = @client.access_token('inval1d', 'cr3dentials')
|
||||
tokens.should be_a Hash
|
||||
tokens.key?('error').should be true
|
||||
expect(tokens).to be_a Hash
|
||||
expect(tokens.key?('error')).to be true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ describe Instapaper::Client do
|
|||
it "should inherit module configuration" do
|
||||
api = Instapaper::Client.new
|
||||
@keys.each do |key|
|
||||
api.send(key).should eq(key)
|
||||
expect(api.send(key)).to eq(key)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -33,7 +33,7 @@ describe Instapaper::Client do
|
|||
api = Instapaper::Client.new(@options)
|
||||
@keys.each do |key|
|
||||
h = @options.has_key?(key) ? @options : Instapaper.options
|
||||
api.send(key).should eq(h[key])
|
||||
expect(api.send(key)).to eq(h[key])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -46,7 +46,7 @@ describe Instapaper::Client do
|
|||
end
|
||||
@keys.each do |key|
|
||||
h = @options.has_key?(key) ? @options : Instapaper.options
|
||||
api.send(key).should eq(h[key])
|
||||
expect(api.send(key)).to eq(h[key])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -59,7 +59,7 @@ describe Instapaper::Client do
|
|||
end
|
||||
|
||||
it 'should return the ' do
|
||||
@client.endpoint_with_prefix.should == Instapaper.endpoint + Instapaper.path_prefix
|
||||
expect(@client.endpoint_with_prefix).to eq(Instapaper.endpoint + Instapaper.path_prefix)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -7,65 +7,65 @@ describe Instapaper do
|
|||
|
||||
describe '.respond_to?' do
|
||||
it 'takes an optional include private argument' do
|
||||
Instapaper.respond_to?(:client, true).should be true
|
||||
expect(Instapaper.respond_to?(:client, true)).to be true
|
||||
end
|
||||
end
|
||||
|
||||
describe ".client" do
|
||||
it "should be a Instapaper::Client" do
|
||||
Instapaper.client.should be_a Instapaper::Client
|
||||
expect(Instapaper.client).to be_a Instapaper::Client
|
||||
end
|
||||
end
|
||||
|
||||
describe ".adapter" do
|
||||
it "should return the default adapter" do
|
||||
Instapaper.adapter.should == Instapaper::Configuration::DEFAULT_ADAPTER
|
||||
expect(Instapaper.adapter).to eq(Instapaper::Configuration::DEFAULT_ADAPTER)
|
||||
end
|
||||
end
|
||||
|
||||
describe ".adapter=" do
|
||||
it "should set the adapter" do
|
||||
Instapaper.adapter = :typhoeus
|
||||
Instapaper.adapter.should == :typhoeus
|
||||
expect(Instapaper.adapter).to eq(:typhoeus)
|
||||
end
|
||||
end
|
||||
|
||||
describe ".endpoint" do
|
||||
it "should return the default endpoint" do
|
||||
Instapaper.endpoint.should == Instapaper::Configuration::DEFAULT_ENDPOINT
|
||||
expect(Instapaper.endpoint).to eq(Instapaper::Configuration::DEFAULT_ENDPOINT)
|
||||
end
|
||||
end
|
||||
|
||||
describe ".endpoint=" do
|
||||
it "should set the endpoint" do
|
||||
Instapaper.endpoint = 'http://tumblr.com/'
|
||||
Instapaper.endpoint.should == 'http://tumblr.com/'
|
||||
expect(Instapaper.endpoint).to eq('http://tumblr.com/')
|
||||
end
|
||||
end
|
||||
|
||||
describe ".user_agent" do
|
||||
it "should return the default user agent" do
|
||||
Instapaper.user_agent.should == Instapaper::Configuration::DEFAULT_USER_AGENT
|
||||
expect(Instapaper.user_agent).to eq(Instapaper::Configuration::DEFAULT_USER_AGENT)
|
||||
end
|
||||
end
|
||||
|
||||
describe ".user_agent=" do
|
||||
it "should set the user_agent" do
|
||||
Instapaper.user_agent = 'Custom User Agent'
|
||||
Instapaper.user_agent.should == 'Custom User Agent'
|
||||
expect(Instapaper.user_agent).to eq('Custom User Agent')
|
||||
end
|
||||
end
|
||||
|
||||
describe ".version" do
|
||||
it "should return the default version" do
|
||||
Instapaper.version.should == Instapaper::Configuration::DEFAULT_VERSION
|
||||
expect(Instapaper.version).to eq(Instapaper::Configuration::DEFAULT_VERSION)
|
||||
end
|
||||
end
|
||||
|
||||
describe ".version=" do
|
||||
it "should set the user_agent" do
|
||||
Instapaper.version = '2'
|
||||
Instapaper.version.should == '2'
|
||||
expect(Instapaper.version).to eq('2')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ describe Instapaper do
|
|||
it "should set the #{key}" do
|
||||
Instapaper.configure do |config|
|
||||
config.send("#{key}=", key)
|
||||
Instapaper.send(key).should == key
|
||||
expect(Instapaper.send(key)).to eq(key)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue