spec/api_connection_spec.rb in esendex-0.5.0 vs spec/api_connection_spec.rb in esendex-0.6.0
- old
+ new
@@ -3,13 +3,13 @@
describe ApiConnection do
let(:api_connection) { ApiConnection.new }
before(:each) do
@connection = Nestful::Connection.new Esendex::API_HOST
- Nestful::Connection.stub(:new) { @connection }
- @connection.stub(:get) {}
- @connection.stub(:post) {}
+ allow(Nestful::Connection).to receive(:new) { @connection }
+ allow(@connection).to receive(:get) {}
+ allow(@connection).to receive(:post) {}
Esendex.configure do |config|
config.username = random_string
config.password = random_string
end
end
@@ -17,38 +17,38 @@
describe "#initialise" do
subject { ApiConnection.new }
it "should set the username" do
subject
- @connection.user.should eq(Esendex.username)
+ expect(@connection.user).to eq(Esendex.username)
end
it "should set the password" do
subject
- @connection.password.should eq(Esendex.password)
+ expect(@connection.password).to eq(Esendex.password)
end
it "should set the auth to basic" do
subject
- @connection.auth_type.should eq(:basic)
+ expect(@connection.auth_type).to eq(:basic)
end
end
describe "#get" do
let(:url) { random_string }
subject { api_connection.get url }
it "should call get with headers" do
- @connection.should_receive(:get).with(url, api_connection.default_headers)
+ expect(@connection).to receive(:get).with(url, api_connection.default_headers)
subject
end
context "when 403 raised" do
before(:each) do
- @connection.stub(:get) { raise Nestful::ForbiddenAccess.new(nil) }
+ allow(@connection).to receive(:get) { raise Nestful::ForbiddenAccess.new(nil) }
end
it "raises an ForbiddenError" do
expect { subject }.to raise_error(ForbiddenError)
end
@@ -60,16 +60,16 @@
let(:body) { random_string }
subject { api_connection.post url, body }
it "should call post with headers" do
- @connection.should_receive(:post).with(url, body, api_connection.default_headers)
+ expect(@connection).to receive(:post).with(url, body, api_connection.default_headers)
subject
end
context "when 403 raised" do
before(:each) do
- @connection.stub(:post) { raise Nestful::ForbiddenAccess.new(nil) }
+ allow(@connection).to receive(:post) { raise Nestful::ForbiddenAccess.new(nil) }
end
it "raises an ForbiddenError" do
expect { subject }.to raise_error(ForbiddenError)
end
\ No newline at end of file