File: nil_test.rb

package info (click to toggle)
ruby-riot 0.12.7-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 512 kB
  • sloc: ruby: 2,557; makefile: 2
file content (15 lines) | stat: -rw-r--r-- 783 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
require 'teststrap'

context "A nil assertion macro" do
  helper(:assert_nil) { |o| Riot::Assertion.new("foo") { o }.nil.run(Riot::Situation.new) }

  asserts(":pass when result is nil") { assert_nil(nil)       }.equals([:pass, "is nil"])
  asserts(":fail with message")       { assert_nil("a")[0..1] }.equals([:fail, %Q{expected nil, not "a"}])
end # A nil assertion macro

context "A negative nil assertion macro" do
  helper(:assert_not_nil) { |o| Riot::Assertion.new("foo", true) { o }.nil.run(Riot::Situation.new) }
  
  asserts(":pass when result is not nil") { assert_not_nil(1)         }.equals([:pass, "is nil"])
  asserts(":fail with message")           { assert_not_nil(nil)[0..1] }.equals([:fail, %Q{expected is nil, not "non-nil"}])
end # A negative nil assertion macro