Sha256: fc100f1197f511c53a18dd196cef66ceed62ccfb6bb4aebf24e0fcfc366892ed

Contents?: true

Size: 1.55 KB

Versions: 17

Compression:

Stored size: 1.55 KB

Contents

require 'spec_helper'
require 'napa/identity'

describe Napa::Identity do
  context '#name' do
    it "returns 'api-service' if no ENV['SERVICE_NAME'] is set" do
      ENV['SERVICE_NAME'] = nil
      Napa::Identity.name.should == 'api-service'
    end

    it "returns the ENV['SERVICE_NAME'] when specified" do
      ENV['SERVICE_NAME'] = nil
      ENV['SERVICE_NAME'] = 'my-service'
      Napa::Identity.name.should eq('my-service')
    end
  end

  context '#hostname' do
    it 'returns the value of the hostname system call and doesn\'t make a second system call' do
      Napa::Identity.should_receive(:`).with('hostname').and_return('system-hostname')
      Napa::Identity.hostname.should eq('system-hostname')

      Napa::Identity.should_not_receive(:`).with('hostname')
      Napa::Identity.hostname.should eq('system-hostname')
    end
  end

  context '#revision' do
    it 'returns the value of the \'git rev-parse HEAD\' system call and doesn\'t make a second system call' do
      Napa::Identity.should_receive(:`).with('git rev-parse HEAD').and_return('12345')
      Napa::Identity.revision.should eq('12345')

      Napa::Identity.should_not_receive(:`).with('git rev-parse HEAD')
      Napa::Identity.revision.should eq('12345')
    end
  end

  context '#pid' do
    it 'returns the process ID value' do
      Process.stub(:pid).and_return(112233)
      Napa::Identity.pid.should be(112233)
    end
  end

  context '#napa_revision' do
    it 'returns the current version of the platform gem' do
      Napa::Identity.napa_revision.should == Napa::VERSION
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
napa-0.1.26 spec/identity_spec.rb
napa-0.1.25 spec/identity_spec.rb
napa-0.1.24 spec/identity_spec.rb
napa-0.1.23 spec/identity_spec.rb
napa-0.1.22 spec/identity_spec.rb
napa-0.1.21 spec/identity_spec.rb
napa-0.1.20 spec/identity_spec.rb
napa-0.1.19 spec/identity_spec.rb
napa-0.1.18 spec/identity_spec.rb
napa-0.1.17 spec/identity_spec.rb
napa-0.1.16 spec/identity_spec.rb
napa-0.1.15 spec/identity_spec.rb
napa-0.1.14 spec/identity_spec.rb
napa-0.1.12 spec/identity_spec.rb
napa-0.1.13 spec/identity_spec.rb
napa-0.1.11 spec/identity_spec.rb
napa-0.1.10 spec/identity_spec.rb