summaryrefslogtreecommitdiff
path: root/spec/env_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/env_spec.rb')
-rw-r--r--spec/env_spec.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/env_spec.rb b/spec/env_spec.rb
new file mode 100644
index 00000000..8e42059f
--- /dev/null
+++ b/spec/env_spec.rb
@@ -0,0 +1,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