test/unit/assertions/assert_block_tests.rb in assert-2.18.2 vs test/unit/assertions/assert_block_tests.rb in assert-2.18.3
- old
+ new
@@ -4,54 +4,55 @@
module Assert::Assertions
class AssertBlockTests < Assert::Context
include Assert::Test::TestHelpers
desc "`assert_block`"
- setup do
- desc = @desc = "assert block fail desc"
- @test = Factory.test do
- assert_block{ true } # pass
- assert_block(desc){ false } # fail
+ subject { test1 }
+
+ let(:desc1) { "assert block fail desc" }
+ let(:test1) {
+ desc = desc1
+ Factory.test do
+ assert_block { true } # pass
+ assert_block(desc) { false } # fail
end
- @test.run(&test_run_callback)
- end
- subject{ @test }
+ }
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 = "#{@desc}\nExpected block to return a true value."
- 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 = "#{desc1}\nExpected block to return a true value."
+ assert_that(test_run_results(:fail).first.message).equals(exp)
end
end
class AssertNotBlockTests < Assert::Context
include Assert::Test::TestHelpers
desc "`assert_not_block`"
- setup do
- desc = @desc = "assert not block fail desc"
- @test = Factory.test do
- assert_not_block(desc){ true } # fail
- assert_not_block{ false } # pass
+ subject { test1 }
+
+ let(:desc1) { "assert not block fail desc" }
+ let(:test1) {
+ desc = desc1
+ Factory.test do
+ assert_not_block(desc) { true } # fail
+ assert_not_block { false } # pass
end
- @test.run(&test_run_callback)
- end
- subject{ @test }
+ }
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 = "#{@desc}\nExpected block to not return a true value."
- 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 = "#{desc1}\nExpected block to not return a true value."
+ assert_that(test_run_results(:fail).first.message).equals(exp)
end
end
end
-