Sha256: 4bde87742688b019d39e3e4a3a51933b501bc05b0c0d410efa40d96f0cdb8089

Contents?: true

Size: 1.02 KB

Versions: 9

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Arstotzka::Config do
  describe 'readme' do
    subject(:restaurant) { Restaurant.new(hash) }

    let(:hash) do
      {
        restaurant: {
          complete_meals: {
            dishes: %w[
              Goulash
              Spaghetti
              Pizza
            ]
          }
        }
      }
    end

    after { Arstotzka.reset_config }

    it 'does not find the values' do
      expect { restaurant.dishes }.to raise_error(NoMethodError)
    end

    context 'when configuring json to be instance_variable' do
      before do
        Arstotzka.configure { json :@hash }
      end

      it do
        expect(restaurant.dishes).to be_nil
      end

      context 'when setting default case to snake' do
        before do
          Arstotzka.configure { |c| c.case :snake }
        end

        it do
          expect(restaurant.dishes)
            .to eq(%w[
                     Goulash Spaghetti Pizza
                   ])
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
arstotzka-1.6.2 spec/integration/readme/arstotzka/config_spec.rb
arstotzka-1.6.1 spec/integration/readme/arstotzka/config_spec.rb
arstotzka-1.6.0 spec/integration/readme/arstotzka/config_spec.rb
arstotzka-1.5.0 spec/integration/readme/arstotzka/config_spec.rb
arstotzka-1.4.4 spec/integration/readme/arstotzka/config_spec.rb
arstotzka-1.4.3 spec/integration/readme/arstotzka/config_spec.rb
arstotzka-1.4.2 spec/integration/readme/arstotzka/config_spec.rb
arstotzka-1.4.1 spec/integration/readme/arstotzka/config_spec.rb
arstotzka-1.4.0 spec/integration/readme/arstotzka/config_spec.rb