test/unit/assertions/assert_nil_tests.rb in assert-2.18.2 vs test/unit/assertions/assert_nil_tests.rb in assert-2.18.3
- old
+ new
@@ -6,58 +6,59 @@
module Assert::Assertions
class AssertNilTests < Assert::Context
include Assert::Test::TestHelpers
desc "`assert_nil`"
- setup do
- desc = @desc = "assert nil empty fail desc"
- args = @args = [1, desc]
- @test = Factory.test do
+ subject { test1 }
+
+ let(:desc1) { "assert nil empty fail desc" }
+ let(:args1) { [1, desc1] }
+ let(:test1) {
+ args = args1
+ Factory.test do
assert_nil(nil) # pass
assert_nil(*args) # fail
end
- @c = @test.config
- @test.run(&test_run_callback)
- end
- subject{ @test }
+ }
+ let(:config1) { test1.config }
should "produce results as expected" do
- assert_equal 2, test_run_result_count
- assert_equal 1, test_run_result_count(:pass)
- assert_equal 1, test_run_result_count(:fail)
- end
+ subject.run(&test_run_callback)
- should "have a fail message with custom and generic explanations" do
- exp = "#{@args[1]}\nExpected #{Assert::U.show(@args[0], @c)} to be nil."
- assert_equal exp, test_run_results(:fail).first.message
+ assert_that(test_run_result_count).equals(2)
+ assert_that(test_run_result_count(:pass)).equals(1)
+ assert_that(test_run_result_count(:fail)).equals(1)
+
+ exp = "#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to be nil."
+ assert_that(test_run_results(:fail).first.message).equals(exp)
end
end
class AssertNotNilTests < Assert::Context
include Assert::Test::TestHelpers
desc "`assert_not_nil`"
- setup do
- desc = @desc = "assert not nil empty fail desc"
- args = @args = [nil, desc]
- @test = Factory.test do
+ subject { test1 }
+
+ let(:desc1) { "assert not nil empty fail desc" }
+ let(:args1) { [nil, desc1] }
+ let(:test1) {
+ args = args1
+ Factory.test do
assert_not_nil(1) # pass
assert_not_nil(*args) # fail
end
- @c = @test.config
- @test.run(&test_run_callback)
- end
- subject{ @test }
+ }
+ let(:config1) { test1.config }
should "produce results as expected" do
- assert_equal 2, test_run_result_count
- assert_equal 1, test_run_result_count(:pass)
- assert_equal 1, test_run_result_count(:fail)
- end
+ subject.run(&test_run_callback)
- should "have a fail message with custom and generic explanations" do
- exp = "#{@args[1]}\nExpected #{Assert::U.show(@args[0], @c)} to not be nil."
- assert_equal exp, test_run_results(:fail).first.message
+ assert_that(test_run_result_count).equals(2)
+ assert_that(test_run_result_count(:pass)).equals(1)
+ assert_that(test_run_result_count(:fail)).equals(1)
+
+ exp = "#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to not be nil."
+ assert_that(test_run_results(:fail).first.message).equals(exp)
end
end
end
-