Sha256: 849ac8570f99ab544ddbb77f1aa97acd7ed2195d0f58cf399a30d2088c19084c

Contents?: true

Size: 1.91 KB

Versions: 21

Compression:

Stored size: 1.91 KB

Contents

describe LinuxAdmin::RegistrationSystem do
  context ".registration_type" do
    it "when registered Subscription Manager" do
      stub_registered_to_system(:sm)
      expect(described_class.registration_type).to eq(LinuxAdmin::SubscriptionManager)
    end

    it "when registered RHN" do
      stub_registered_to_system(:sm, :rhn)
      expect(described_class.registration_type).to eq(LinuxAdmin::Rhn)
    end

    it "when unregistered" do
      stub_registered_to_system(nil)
      expect(described_class.registration_type).to eq(described_class)
    end

    it "should memoize results" do
      expect(described_class).to receive(:registration_type_uncached).once.and_return("anything_non_nil")
      described_class.registration_type
      described_class.registration_type
    end

    it "with reload should refresh results" do
      expect(described_class).to receive(:registration_type_uncached).twice.and_return("anything_non_nil")
      described_class.registration_type
      described_class.registration_type(true)
    end
  end

  it "#registered? when unregistered" do
    stub_registered_to_system(nil)
    expect(described_class.registered?).to be_falsey
  end

  context ".method_missing" do
    before do
      stub_registered_to_system(:rhn)
    end

    it "exists on the subclass" do
      expect(LinuxAdmin::RegistrationSystem.registered?).to be_truthy
    end

    it "does not exist on the subclass" do
      expect { LinuxAdmin::RegistrationSystem.organizations }.to raise_error(NotImplementedError)
    end

    it "is an unknown method" do
      expect { LinuxAdmin::RegistrationSystem.method_does_not_exist }.to raise_error(NoMethodError)
    end
  end

  def stub_registered_to_system(*system)
    allow_any_instance_of(LinuxAdmin::SubscriptionManager).to receive_messages(:registered? => (system.include?(:sm)))
    allow_any_instance_of(LinuxAdmin::Rhn).to receive_messages(:registered? => (system.include?(:rhn)))
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
linux_admin-1.1.0 spec/registration_system_spec.rb
linux_admin-1.0.0 spec/registration_system_spec.rb
linux_admin-0.20.2 spec/registration_system_spec.rb
linux_admin-0.20.1 spec/registration_system_spec.rb
linux_admin-0.20.0 spec/registration_system_spec.rb
linux_admin-0.19.0 spec/registration_system_spec.rb
linux_admin-0.18.0 spec/registration_system_spec.rb
linux_admin-0.17.0 spec/registration_system_spec.rb
linux_admin-0.16.0 spec/registration_system_spec.rb
linux_admin-0.15.0 spec/registration_system_spec.rb
linux_admin-0.14.0 spec/registration_system_spec.rb
linux_admin-0.13.0 spec/registration_system_spec.rb
linux_admin-0.12.1 spec/registration_system_spec.rb
linux_admin-0.12.0 spec/registration_system_spec.rb
linux_admin-0.11.1 spec/registration_system_spec.rb
linux_admin-0.11.0 spec/registration_system_spec.rb
linux_admin-0.10.1 spec/registration_system_spec.rb
linux_admin-0.10.0 spec/registration_system_spec.rb
linux_admin-0.9.4 spec/registration_system_spec.rb
linux_admin-0.9.3 spec/registration_system_spec.rb