File: env_spec.rb

package info (click to toggle)
pry 0.15.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,772 kB
  • sloc: ruby: 21,692; sh: 17; makefile: 11
file content (26 lines) | stat: -rw-r--r-- 628 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

RSpec.describe Pry::Env do
  describe "#[]" do
    let(:key) { 'PRYTESTKEY' }

    after { ENV.delete(key) }

    context "when ENV contains the passed key" do
      before { ENV[key] = 'val' }
      after { ENV.delete(key) }

      specify { expect(described_class[key]).to eq('val') }
    end

    context "when ENV doesn't contain the passed key" do
      specify { expect(described_class[key]).to be_nil }
    end

    context "when ENV contains the passed key but its value is nil" do
      before { ENV[key] = '' }

      specify { expect(described_class[key]).to be_nil }
    end
  end
end