Sha256: 1342dc207ab4e7068b989922fe0c201f4a57500cc737f23292a7d71a55e11700

Contents?: true

Size: 932 Bytes

Versions: 1

Compression:

Stored size: 932 Bytes

Contents

require "spec_helper"

describe Stairs::EnvAdapters::Rbenv do
  subject { described_class.new }

  describe ".present?" do
    before { described_class.should_receive(:`).with("which rbenv-vars") }

    context "when rbenv-vars is installed" do
      before { $?.stub success?: true }

      it "returns true" do
        expect(described_class.present?).to be_true
      end
    end

    context "when rbenv-vars is not installed" do
      before { $?.stub success?: false }

      it "returns true" do
        expect(described_class.present?).to be_false
      end
    end
  end

  describe "#set" do
    it "delegates to the well tested FileMutation util" do
      name = "VAR_NAME"
      value = "the_value"

      Stairs::Util::FileMutation.should_receive(:replace_or_append).with(
        Regexp.new("^#{name}=(.*)$"),
        "#{name}=#{value}",
        ".rbenv-vars",
      )

      subject.set(name, value)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stairs-0.4.0 spec/lib/stairs/env_adapters/rbenv_spec.rb