Sha256: 672eec1f67cfb0806f766a67ace513374b4856793cb44c1f51d3fd92431a2c70
Contents?: true
Size: 1.69 KB
Versions: 1
Compression:
Stored size: 1.69 KB
Contents
require 'spec_helper' describe NightcrawlerSwift::Delete do let(:connection) { NightcrawlerSwift::Connection.new } let(:token) { "token" } let(:expires_at) { (DateTime.now + 60).to_time } let(:upload_url) { "server-url" } subject do NightcrawlerSwift::Delete.new end before do allow(NightcrawlerSwift).to receive(:connection).and_return(connection) allow(connection).to receive(:token_id).and_return(token) allow(connection).to receive(:expires_at).and_return(expires_at) allow(connection).to receive(:upload_url).and_return(upload_url) end describe "#execute" do let :execute do subject.execute "file_path" end context "success" do let :response do double(:response, code: 204) end before do allow(subject).to receive(:delete).and_return(response) end it "deletes using upload url" do execute expect(subject).to have_received(:delete).with("server-url/file_path", headers: {accept: :json}) end it "returns true" do expect(execute).to eql true end end context "failure" do let :response do double(:response, code: 404) end before do allow(subject).to receive(:delete).and_return(response) end it "returns false" do expect(execute).to eql false end end context "when the path was not informed" do it "raises NightcrawlerSwift::Exceptions::ValidationError" do expect { subject.execute nil }.to raise_error NightcrawlerSwift::Exceptions::ValidationError expect { subject.execute "" }.to raise_error NightcrawlerSwift::Exceptions::ValidationError end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nightcrawler_swift-1.0.0 | spec/lib/nightcrawler_swift/commands/delete_spec.rb |