Sha256: 9b86253428b7d1f7b59bf5f8f5634d7526787dc9ef9a45efc7502d4e244d897d

Contents?: true

Size: 715 Bytes

Versions: 4

Compression:

Stored size: 715 Bytes

Contents

require 'spec_helper'

describe 'default option' do
  subject do
    StarGazer.new(hash).favorite_star
  end

  let(:hash) { {} }

  context 'when node is not found' do
    it 'returns the default before wrapping' do
      expect(subject.name).to eq('Sun')
    end

    it 'wraps the returned value in a class' do
      expect(subject).to be_a(Star)
    end
  end

  context 'when node is not missing' do
    let(:hash) do
      {
        universe: {
          star: { name: 'Antares' }
        }
      }
    end

    it 'returns the value before wrapping' do
      expect(subject.name).to eq('Antares')
    end

    it 'wraps the returned value in a class' do
      expect(subject).to be_a(Star)
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
arstotzka-1.0.1 spec/integration/readme/default_spec.rb
arstotzka-1.0.0 spec/integration/readme/default_spec.rb
json_parser-1.3.1 spec/integration/readme/default_spec.rb
json_parser-1.3.0 spec/integration/readme/default_spec.rb