Sha256: 7ed00abf6f0851b524bddcc37c1ac20f8ae358e45363540bd30e06f4112ffb40

Contents?: true

Size: 1.54 KB

Versions: 5

Compression:

Stored size: 1.54 KB

Contents

require 'spec_helper'

describe Hieracles::Interpolate do
  include Hieracles::Interpolate

  describe ".parse" do
    let(:input) { StringIO.new }
    let(:output) { StringIO.new }
    before { setio input, output }

    context "when in non-interactive mode" do
      let(:data) { 'something_%{a_var}' }
      context "and has valid value" do
        let(:values) { { a_var: 'value' } }
        let(:expected) { 'something_value' }
        it { expect(parse data, values).to eq expected }
      end
      context "and has invalid value" do
        let(:values) { { b_var: 'novalue' } }
        let(:expected) { 'something_' }
        it { expect(parse data, values).to eq expected }
      end
      context "and has valid value with doublecolumn" do
        let(:data) { 'something_%{::a_var}' }
        let(:values) { { a_var: 'value' } }
        let(:expected) { 'something_value' }
        it { expect(parse data, values).to eq expected }
      end
    end
    context "when in interactive mode" do
      let(:data) { 'something_%{a_var}' }
      context "and has valid value" do
        let(:values) { { a_var: 'value' } }
        let(:expected) { 'something_value' }
        it { expect(parse data, values, true).to eq expected }
      end
      context "and has invalid value" do
        let(:values) { { b_var: 'novalue' } }
        let(:expected) { 'something_value' }
        before { allow(input).to receive(:gets).and_return 'value' }
        it { expect(parse data, values, true).to eq expected }
      end
    end
  end

  describe ".ask_about" do
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hieracles-0.3.2 spec/lib/interpolate_spec.rb
hieracles-0.3.1 spec/lib/interpolate_spec.rb
hieracles-0.3.0 spec/lib/interpolate_spec.rb
hieracles-0.2.2 spec/lib/interpolate_spec.rb
hieracles-0.2.1 spec/lib/interpolate_spec.rb