summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorKyrylo Silin <silin@kyrylo.org>2019-06-09 16:38:07 +0300
committerKyrylo Silin <silin@kyrylo.org>2019-06-09 17:11:24 +0300
commit7ce5ca70bb4a1ff447269bdde4cb5d07b8932c8a (patch)
tree0b25a4fa21dd82fedc07413fceab680b7155c528 /spec
parent17bdfd7082e66c3d2ea0d97b26d122f6e80e0050 (diff)
downloadpry-7ce5ca70bb4a1ff447269bdde4cb5d07b8932c8a.tar.gz
Add Pry::Env
Env is a helper module to work with environment variables.
Diffstat (limited to 'spec')
-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