Sha256: daf352fb8a33a11a9ad6d635427404d82433139f2b327d35f190586b6479a36a

Contents?: true

Size: 1.62 KB

Versions: 17

Compression:

Stored size: 1.62 KB

Contents

require "spec_helper"

RSpec.describe Brightbox::Api, "#respond_to?" do
  let(:fog_model) { Fog::Model.new }
  let(:identifier) { "api-12345" }

  before do
    allow(fog_model).to receive(:id).and_return(identifier)
    allow(fog_model).to receive(:attributes).and_return({})
  end

  context "when initialised with a fog model" do
    subject(:instance) { described_class.new(fog_model) }

    context "with a top level method" do
      let(:method_name) { :to_s }

      it do
        expect(instance.respond_to?(method_name)).to be(true)
      end
    end

    context "with a delegated method" do
      let(:method_name) { :attributes }

      it do
        expect(instance.respond_to?(method_name)).to be(true)
      end
    end

    context "with unknown method" do
      let(:method_name) { :onions }

      it do
        expect(instance.respond_to?(method_name)).to be(false)
      end
    end
  end

  context "when initialised with an identifier string" do
    subject(:instance) { described_class.new(identifier) }

    before do
      allow(Brightbox::Api).to receive(:find).with(identifier).and_return(fog_model)
    end

    context "with a top level method" do
      let(:method_name) { :to_s }

      it do
        expect(instance.respond_to?(method_name)).to be(true)
      end
    end

    context "with a delegated method" do
      let(:method_name) { :attributes }

      it do
        expect(instance.respond_to?(method_name)).to be(true)
      end
    end

    context "with unknown method" do
      let(:method_name) { :onions }

      it do
        expect(instance.respond_to?(method_name)).to be(false)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
brightbox-cli-5.0.0.rc2 spec/unit/brightbox/api/respond_to_spec.rb
brightbox-cli-5.0.0.rc1 spec/unit/brightbox/api/respond_to_spec.rb
brightbox-cli-5.0.0.alpha spec/unit/brightbox/api/respond_to_spec.rb
brightbox-cli-4.8.0 spec/unit/brightbox/api/respond_to_spec.rb
brightbox-cli-4.7.0 spec/unit/brightbox/api/respond_to_spec.rb
brightbox-cli-4.6.0 spec/unit/brightbox/api/respond_to_spec.rb
brightbox-cli-4.5.0 spec/unit/brightbox/api/respond_to_spec.rb
brightbox-cli-4.5.0.rc1 spec/unit/brightbox/api/respond_to_spec.rb
brightbox-cli-4.4.0 spec/unit/brightbox/api/respond_to_spec.rb
brightbox-cli-4.3.2 spec/unit/brightbox/api/respond_to_spec.rb
brightbox-cli-4.3.1 spec/unit/brightbox/api/respond_to_spec.rb
brightbox-cli-4.3.0 spec/unit/brightbox/api/respond_to_spec.rb
brightbox-cli-4.2.1 spec/unit/brightbox/api/respond_to_spec.rb
brightbox-cli-4.2.0 spec/unit/brightbox/api/respond_to_spec.rb
brightbox-cli-4.1.0 spec/unit/brightbox/api/respond_to_spec.rb
brightbox-cli-4.0.0 spec/unit/brightbox/api/respond_to_spec.rb
brightbox-cli-4.0.0.rc2 spec/unit/brightbox/api/respond_to_spec.rb