-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- v1.1.0.alpha3
- v1.1.0.alpha2
- v1.1.0.alpha1
- v1.0.0
- v1.0.0.alpha1
- v0.8.0
- v0.8.0.alpha3
- v0.8.0.alpha2
- v0.8.0.alpha1
- v0.7.1
- v0.7.0
- v0.7.0.rc.2
- v0.7.0.rc.1
- v0.6.2
- v0.6.1
- v0.6.0
- v0.6.0.beta1
- v0.5.0
- v0.5.0.beta3
- v0.5.0.beta2
- v0.5.0.beta1
- v0.4.3
- v0.4.2
- v0.4.1
- v0.4.0
- v0.4.0.beta4
- v0.4.0.beta3
- v0.4.0.beta2
- v0.3.0.beta3
- v0.2.1
- v0.2.0
- v0.1.0
- v0.0.1.beta2
- v0.0.1.beta1
1 parent
7bea4d0
commit c01f6ad
Showing
1 changed file
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
describe "be_truthy" do | ||
it "passes with truthy values" do | ||
expect(true).to be_truthy | ||
expect(1.0).to be_truthy | ||
expect([]).to be_truthy | ||
end | ||
|
||
it "fails with falsey values" do | ||
expect { | ||
expect(false).to be_truthy | ||
}.to raise_error(Exception) | ||
|
||
expect { | ||
expect(nil).to be_truthy | ||
}.to raise_error(Exception) | ||
end | ||
end | ||
|
||
describe "be_falsey" do | ||
it "passes with falsey values" do | ||
expect(false).to be_falsey | ||
expect(nil).to be_falsey | ||
end | ||
|
||
it "fails with truthy values" do | ||
expect { | ||
expect(true).to be_falsey | ||
}.to raise_error(Exception) | ||
|
||
expect { | ||
expect({}).to be_falsey | ||
}.to raise_error(Exception) | ||
end | ||
end | ||
|
||
describe "be_nil" do | ||
it "passes when object is nil" do | ||
expect(nil).to be_nil | ||
end | ||
|
||
it "fails with any other object" do | ||
expect { | ||
expect(false).to be_nil | ||
}.to raise_error(Exception) | ||
|
||
expect { | ||
expect(:foo).to be_nil | ||
}.to raise_error(Exception) | ||
end | ||
end | ||
|
||
describe "eq" do | ||
it "matches when actual == expected" do | ||
expect(:foo).to eq(:foo) | ||
end | ||
|
||
it "does not match when actual != expected" do | ||
expect(:foo).not_to eq(42) | ||
end | ||
|
||
it "fails if matcher does not match" do | ||
expect { | ||
expect(:foo).to eq(42) | ||
}.to raise_error(Exception) | ||
|
||
expect { | ||
expect(:foo).not_to eq(:foo) | ||
}.to raise_error(Exception) | ||
end | ||
end | ||
|
||
describe "be_kind_of" do | ||
it "passes if actual is kind of expected class" do | ||
expect("foo").to be_kind_of(String) | ||
expect("foo").to_not be_kind_of(Numeric) | ||
end | ||
|
||
it "passes if actual is kind of superclass of expected class" do | ||
expect([]).to be_kind_of(Object) | ||
end | ||
|
||
it "fails if expected is not a kind of expected" do | ||
expect { | ||
expect("foo").to be_kind_of(Integer) | ||
}.to raise_error(Exception) | ||
|
||
expect { | ||
expect("foo").to_not be_kind_of(String) | ||
}.to raise_error(Exception) | ||
end | ||
end |