Sha256: c0ff607a3ca3ae6f0cf33c6939261fc481edcc9a966cd221cd219be2f333bc97
Contents?: true
Size: 1.84 KB
Versions: 7
Compression:
Stored size: 1.84 KB
Contents
require "spec_helper" describe Brightbox::Api, ".find" do context "when passed nil" do it "raises an error" do expect { Brightbox::Api.find(nil) }.to raise_error(Brightbox::Api::InvalidArguments) end end context "when passed an empty object" do it "raises an error" do expect { Brightbox::Api.find([]) }.to raise_error(Brightbox::Api::InvalidArguments) end end context "when all objects are requested" do it "returns a collection" do @fog_model = double @resource = double expect(Brightbox::Api).to receive(:all).and_return([@fog_model]) expect(Brightbox::Api).to receive(:new).with(@fog_model).and_return(@resource) expect(Brightbox::Api.find(:all)).to eql([@resource]) end end context "when passed an identifier string" do it "returns a wrapped Api model" do @identifier = "api-12345" @fog_model = double @resource = double expect(Brightbox::Api).to receive(:get).with(@identifier).and_return(@fog_model) expect(Brightbox::Api).to receive(:new).with(@fog_model).and_return(@resource) expect(Brightbox::Api.find(@identifier)).to eql(@resource) end end context "when passed a collection of identifiers" do before do @identifier = "api-12345" @fog_model = double @resource = double end it "returns collection of found resources" do expect(Brightbox::Api).to receive(:cached_get).with(@identifier).and_return(@fog_model) expect(Brightbox::Api).to receive(:new).with(@fog_model).and_return(@resource) expect(Brightbox::Api.find([@identifier])).to eq([@resource]) end end context "when passed a bad search value" do it "raises an error" do expect { Brightbox::Api.find(double) }.to raise_error(Brightbox::Api::InvalidArguments) end end end
Version data entries
7 entries across 7 versions & 1 rubygems