1
0
mirror of https://github.com/seejohnrun/haste-client.git synced 2025-12-20 10:31:29 +00:00

Upgrade to RSpec 3

This commit is contained in:
John Crepezzi
2014-11-01 10:40:23 -04:00
parent 3a1d4045b3
commit 94b2a4fbec
2 changed files with 20 additions and 20 deletions

View File

@@ -4,9 +4,9 @@ require File.dirname(__FILE__) + '/lib/haste/version'
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = 'haste' s.name = 'haste'
s.author = 'John Crepezzi' s.author = 'John Crepezzi'
s.add_development_dependency('rspec') s.add_development_dependency('rspec', '~> 3.0')
s.add_dependency('json') s.add_dependency('json', '~> 1.8')
s.add_dependency('faraday') s.add_dependency('faraday', '~> 0.9')
s.description = 'CLI Haste Client' s.description = 'CLI Haste Client'
s.license = 'MIT License' s.license = 'MIT License'
s.homepage = 'https://github.com/seejohnrun/haste-client' s.homepage = 'https://github.com/seejohnrun/haste-client'

View File

@@ -23,12 +23,12 @@ describe Haste::Uploader do
before do before do
ostruct = OpenStruct.new(:status => 200, :body => json) ostruct = OpenStruct.new(:status => 200, :body => json)
uploader.send(:connection).should_receive(:post).with('/documents', data).and_return(ostruct) expect(uploader.send(:connection)).to receive(:post).with('/documents', data).and_return(ostruct)
end end
it 'should get the key' do it 'should get the key' do
error_message.should be_nil # no error expect(error_message).to be_nil # no error
@key.should == 'hello' expect(@key).to eq('hello')
end end
end end
@@ -39,11 +39,11 @@ describe Haste::Uploader do
before do before do
ostruct = OpenStruct.new(:status => 200, :body => json) ostruct = OpenStruct.new(:status => 200, :body => json)
uploader.send(:connection).should_receive(:post).with('/documents', data).and_return(ostruct) expect(uploader.send(:connection)).to receive(:post).with('/documents', data).and_return(ostruct)
end end
it 'should get an error' do it 'should get an error' do
error_message.should start_with 'failure parsing response: ' expect(error_message).to start_with('failure parsing response: ')
end end
end end
@@ -52,11 +52,11 @@ describe Haste::Uploader do
before do before do
ostruct = OpenStruct.new(:status => 404, :body => 'ohno') ostruct = OpenStruct.new(:status => 404, :body => 'ohno')
uploader.send(:connection).should_receive(:post).with('/documents', data).and_return(ostruct) expect(uploader.send(:connection)).to receive(:post).with('/documents', data).and_return(ostruct)
end end
it 'should get an error' do it 'should get an error' do
error_message.should == 'failure uploading: ohno' expect(error_message).to eq('failure uploading: ohno')
end end
end end
@@ -65,11 +65,11 @@ describe Haste::Uploader do
before do before do
error = Errno::ECONNREFUSED error = Errno::ECONNREFUSED
uploader.send(:connection).should_receive(:post).with('/documents', data).and_raise(error) expect(uploader.send(:connection)).to receive(:post).with('/documents', data).and_raise(error)
end end
it 'should get the key' do it 'should get the key' do
error_message.should == 'failure connecting: Connection refused' expect(error_message).to eq('failure connecting: Connection refused')
end end
end end
@@ -93,7 +93,7 @@ describe Haste::Uploader do
let(:path) { nil } let(:path) { nil }
it 'should have an error' do it 'should have an error' do
error_message.should == 'No input file given' expect(error_message).to eq('No input file given')
end end
end end
@@ -103,7 +103,7 @@ describe Haste::Uploader do
let(:path) { '/tmp/why-do-you-have-a-file-called-john' } let(:path) { '/tmp/why-do-you-have-a-file-called-john' }
it 'should have an error' do it 'should have an error' do
error_message.should == "#{path}: No such path" expect(error_message).to eq("#{path}: No such path")
end end
end end
@@ -115,11 +115,11 @@ describe Haste::Uploader do
before { File.open(path, 'w') { |f| f.write(data) } } before { File.open(path, 'w') { |f| f.write(data) } }
before do before do
uploader.should_receive(:upload_raw).with(data) # check expect(uploader).to receive(:upload_raw).with(data) # check
end end
it 'should not receive an error' do it 'should not receive an error' do
error_message.should be_nil expect(error_message).to be_nil
end end
end end
@@ -135,7 +135,7 @@ describe Haste::Uploader do
let(:base) { nil } let(:base) { nil }
it 'should use the default url' do it 'should use the default url' do
server_url.should == Haste::DEFAULT_URL expect(server_url).to eq(Haste::DEFAULT_URL)
end end
end end
@@ -148,11 +148,11 @@ describe Haste::Uploader do
let(:base) { @string } let(:base) { @string }
it 'should remove the slash' do it 'should remove the slash' do
server_url.should == @string.chop expect(server_url).to eq(@string.chop)
end end
it 'should not modify the original' do it 'should not modify the original' do
@string.should == 'hello/' expect(@string).to eq('hello/')
end end
end end
@@ -162,7 +162,7 @@ describe Haste::Uploader do
let(:base) { 'hello' } let(:base) { 'hello' }
it 'should not chop the url' do it 'should not chop the url' do
server_url.should == base expect(server_url).to eq(base)
end end
end end