|
12 | 12 | expect { @o.double(2.2) }.to_not raise_error
|
13 | 13 | end
|
14 | 14 |
|
15 |
| - it "should fail for Strings" do |
16 |
| - expect { @o.double("bad") }.to raise_error(ContractError) |
| 15 | + it "should fail for nil and other data types" do |
| 16 | + expect { @o.double(nil) }.to raise_error(ContractError) |
| 17 | + expect { @o.double(:x) }.to raise_error(ContractError) |
| 18 | + expect { @o.double("x") }.to raise_error(ContractError) |
| 19 | + expect { @o.double(/x/) }.to raise_error(ContractError) |
17 | 20 | end
|
18 | 21 | end
|
19 | 22 |
|
20 | 23 | describe "Pos:" do
|
21 | 24 | it "should pass for positive numbers" do
|
22 | 25 | expect { @o.pos_test(1) }.to_not raise_error
|
| 26 | + expect { @o.pos_test(1.6) }.to_not raise_error |
23 | 27 | end
|
24 | 28 |
|
25 | 29 | it "should fail for 0" do
|
|
28 | 32 |
|
29 | 33 | it "should fail for negative numbers" do
|
30 | 34 | expect { @o.pos_test(-1) }.to raise_error(ContractError)
|
| 35 | + expect { @o.pos_test(-1.6) }.to raise_error(ContractError) |
31 | 36 | end
|
32 | 37 |
|
33 |
| - it "should fail for nil" do |
| 38 | + it "should fail for nil and other data types" do |
34 | 39 | expect { @o.pos_test(nil) }.to raise_error(ContractError)
|
| 40 | + expect { @o.pos_test(:x) }.to raise_error(ContractError) |
| 41 | + expect { @o.pos_test("x") }.to raise_error(ContractError) |
| 42 | + expect { @o.pos_test(/x/) }.to raise_error(ContractError) |
35 | 43 | end
|
36 | 44 | end
|
37 | 45 |
|
38 | 46 | describe "Neg:" do
|
39 | 47 | it "should pass for negative numbers" do
|
40 | 48 | expect { @o.neg_test(-1) }.to_not raise_error
|
| 49 | + expect { @o.neg_test(-1.6) }.to_not raise_error |
41 | 50 | end
|
42 | 51 |
|
43 | 52 | it "should fail for 0" do
|
|
46 | 55 |
|
47 | 56 | it "should fail for positive numbers" do
|
48 | 57 | expect { @o.neg_test(1) }.to raise_error(ContractError)
|
| 58 | + expect { @o.neg_test(1.6) }.to raise_error(ContractError) |
49 | 59 | end
|
50 | 60 |
|
51 |
| - it "should fail for nil" do |
| 61 | + it "should fail for nil and other data types" do |
52 | 62 | expect { @o.neg_test(nil) }.to raise_error(ContractError)
|
| 63 | + expect { @o.neg_test(:x) }.to raise_error(ContractError) |
| 64 | + expect { @o.neg_test("x") }.to raise_error(ContractError) |
| 65 | + expect { @o.neg_test(/x/) }.to raise_error(ContractError) |
53 | 66 | end
|
54 | 67 | end
|
55 | 68 |
|
|
68 | 81 |
|
69 | 82 | it "should fail for negative numbers" do
|
70 | 83 | expect { @o.nat_test(-1) }.to raise_error(ContractError)
|
| 84 | + expect { @o.nat_test(-1.6) }.to raise_error(ContractError) |
71 | 85 | end
|
72 | 86 |
|
73 |
| - it "should fail for nil" do |
| 87 | + it "should fail for nil and other data types" do |
74 | 88 | expect { @o.nat_test(nil) }.to raise_error(ContractError)
|
| 89 | + expect { @o.nat_test(:x) }.to raise_error(ContractError) |
| 90 | + expect { @o.nat_test("x") }.to raise_error(ContractError) |
| 91 | + expect { @o.nat_test(/x/) }.to raise_error(ContractError) |
75 | 92 | end
|
76 | 93 | end
|
77 | 94 |
|
|
0 commit comments