You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.3 KiB
74 lines
2.3 KiB
From 85c6a4e471f2013079dc5a63c1a6bb84bee9351b Mon Sep 17 00:00:00 2001
|
|
From: PikachuEXE <pikachuexe@gmail.com>
|
|
Date: Mon, 25 Jan 2021 17:26:45 +0800
|
|
Subject: [PATCH 2/5] * Update spec to specify error class to suppress RSpec
|
|
warning
|
|
|
|
---
|
|
spec/contracts_spec.rb | 6 +++---
|
|
spec/methods_spec.rb | 8 ++++----
|
|
2 files changed, 7 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/spec/contracts_spec.rb b/spec/contracts_spec.rb
|
|
index d37c40e..72c8603 100644
|
|
--- a/spec/contracts_spec.rb
|
|
+++ b/spec/contracts_spec.rb
|
|
@@ -7,7 +7,7 @@ RSpec.describe "Contracts:" do
|
|
it "should fail for insufficient arguments" do
|
|
expect do
|
|
@o.hello
|
|
- end.to raise_error
|
|
+ end.to raise_error ArgumentError
|
|
end
|
|
|
|
it "should fail for insufficient contracts" do
|
|
@@ -32,7 +32,7 @@ RSpec.describe "Contracts:" do
|
|
1
|
|
end
|
|
end
|
|
- end.to raise_error
|
|
+ end.to raise_error NameError
|
|
end
|
|
end
|
|
|
|
@@ -696,7 +696,7 @@ RSpec.describe "Contracts:" do
|
|
it "should apply the contract to an inherited method" do
|
|
c = Child.new
|
|
expect { c.double(2) }.to_not raise_error
|
|
- expect { c.double("asd") }.to raise_error
|
|
+ expect { c.double("asd") }.to raise_error ParamContractError
|
|
end
|
|
end
|
|
|
|
diff --git a/spec/methods_spec.rb b/spec/methods_spec.rb
|
|
index 334fb4e..d1b5d47 100644
|
|
--- a/spec/methods_spec.rb
|
|
+++ b/spec/methods_spec.rb
|
|
@@ -36,19 +36,19 @@ RSpec.describe "Contracts:" do
|
|
end
|
|
|
|
it "should enforce return value inside block with no other parameter" do
|
|
- expect { obj.foo(&:to_s) }.to raise_error
|
|
+ expect { obj.foo(&:to_s) }.to raise_error ReturnContractError
|
|
end
|
|
|
|
it "should enforce return value inside block with other parameter" do
|
|
- expect { obj.foo2(2) { |x| x.to_s } }.to raise_error
|
|
+ expect { obj.foo2(2) { |x| x.to_s } }.to raise_error ReturnContractError
|
|
end
|
|
|
|
it "should enforce return value inside lambda with no other parameter" do
|
|
- expect { obj.bar lambda { |x| x.to_s } }.to raise_error
|
|
+ expect { obj.bar lambda { |x| x.to_s } }.to raise_error ReturnContractError
|
|
end
|
|
|
|
it "should enforce return value inside lambda with other parameter" do
|
|
- expect { obj.bar2(2, lambda { |x| x.to_s }) }.to raise_error
|
|
+ expect { obj.bar2(2, lambda { |x| x.to_s }) }.to raise_error ReturnContractError
|
|
end
|
|
end
|
|
end
|
|
--
|
|
2.29.2
|
|
|