aboutsummaryrefslogtreecommitdiffstats
path: root/spec/lib/result_spec.rb
diff options
context:
space:
mode:
authorRobert2017-07-31 08:03:13 +0200
committerRobert2017-07-31 08:03:13 +0200
commit609b774388a7f57703ec14a224363c88f3564eaf (patch)
tree4610e6b5a82a6f472d2b6ecc7901385b7415f296 /spec/lib/result_spec.rb
parentaa5028a21f28a2bee9f64b5e87e70828c9c8b75f (diff)
downloadchouette-core-609b774388a7f57703ec14a224363c88f3564eaf.tar.bz2
Refs: #3507_1726@6h Code Review
Diffstat (limited to 'spec/lib/result_spec.rb')
-rw-r--r--spec/lib/result_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/lib/result_spec.rb b/spec/lib/result_spec.rb
new file mode 100644
index 000000000..949de163c
--- /dev/null
+++ b/spec/lib/result_spec.rb
@@ -0,0 +1,20 @@
+RSpec.describe Result do
+
+ context 'is a wrapper of a value' do
+ it { expect( described_class.ok('hello').value ).to eq('hello') }
+ it { expect( described_class.error('hello').value ).to eq('hello') }
+ end
+
+ context 'it has status information' do
+ it { expect( described_class.ok('hello') ).to be_ok }
+ it { expect( described_class.ok('hello').status ).to eq(:ok) }
+
+ it { expect( described_class.error('hello') ).not_to be_ok }
+ it { expect( described_class.error('hello').status ).to eq(:error) }
+ end
+
+ context 'nil is just another value' do
+ it { expect( described_class.ok(nil) ).to be_ok }
+ it { expect( described_class.ok(nil).value ).to be_nil }
+ end
+end