test/unit/result_tests.rb in assert-2.18.3 vs test/unit/result_tests.rb in assert-2.18.4

- old
+ new

@@ -4,12 +4,14 @@ require "assert/file_line" module Assert::Result class UnitTests < Assert::Context desc "Assert::Result" - subject { Assert::Result } + subject { unit_class } + let(:unit_class) { Assert::Result } + let(:test1) { Factory.test("a test name") } should have_imeths :types, :new should "know its types" do @@ -30,13 +32,13 @@ exp = Assert::Result.types[type].new(:type => type) assert_that(Assert::Result.new(:type => type)).equals(exp) end end - class BaseTests < UnitTests - desc "Base" - subject { result1 } + class InitBaseTests < UnitTests + desc "Base when init" + subject { Base.new(given_data1) } let(:given_data1) { { :type => Factory.string, :name => Factory.string, @@ -45,11 +47,10 @@ :message => Factory.string, :output => Factory.text, :backtrace => Backtrace.new(Factory.backtrace) } } - let(:result1) { Base.new(given_data1) } should have_cmeths :type, :name, :for_test should have_imeths :type, :name, :test_name, :test_file_line should have_imeths :test_file_name, :test_line_num, :test_id should have_imeths :message, :output @@ -224,62 +225,56 @@ "@test_file_line=#{subject.test_file_line.to_s.inspect}>" assert_that(subject.inspect).equals(exp) end end - class PassTests < UnitTests - desc "Pass" - subject { result1 } + class InitPassTests < UnitTests + desc "Pass when init" + subject { Pass.new({}) } - let(:result1) { Pass.new({}) } - should "know its type/name" do assert_that(subject.type).equals(:pass) assert_that(subject.class.type).equals(:pass) assert_that(subject.class.name).equals("Pass") end end - class IgnoreTests < UnitTests - desc "Ignore" - subject { result1 } + class InitIgnoreTests < UnitTests + desc "Ignore when init" + subject { Ignore.new({}) } - let(:result1) { Ignore.new({}) } - should "know its type/name" do assert_that(subject.type).equals(:ignore) assert_that(subject.class.type).equals(:ignore) assert_that(subject.class.name).equals("Ignore") end end - class HaltingTestResultErrorTests < UnitTests - desc "HaltingTestResultError" + class InitHaltingTestResultErrorTests < UnitTests + desc "HaltingTestResultError when init" subject { HaltingTestResultError.new } should have_accessors :assert_with_bt should "be a runtime error" do assert_that(subject).is_kind_of(RuntimeError) end end - class TestFailureTests < UnitTests - desc "TestFailure" - subject { TestFailure } + class InitTestFailureTests < UnitTests + desc "TestFailure when init" + subject { TestFailure.new } should "be a halting test result error" do - assert_that(subject.new).is_kind_of(HaltingTestResultError) + assert_that(subject).is_kind_of(HaltingTestResultError) end end - class FailTests < UnitTests - desc "Fail" - subject { result1 } + class InitFailTests < UnitTests + desc "Fail when init" + subject { Fail.new({}) } - let(:result1) { Fail.new({}) } - should "know its type/name" do assert_that(subject.type).equals(:fail) assert_that(subject.class.type).equals(:fail) assert_that(subject.class.name).equals("Fail") end @@ -309,25 +304,23 @@ should "not allow creating for a test with non-TestFailure exceptions" do assert_that(-> { Fail.for_test(test1, RuntimeError.new) }).raises(ArgumentError) end end - class TestSkippedTests < UnitTests - desc "TestSkipped" - subject { TestSkipped } + class InitTestSkippedTests < UnitTests + desc "TestSkipped when init" + subject { TestSkipped.new } should "be a halting test result error" do - assert_that(subject.new).is_kind_of(HaltingTestResultError) + assert_that(subject).is_kind_of(HaltingTestResultError) end end - class SkipTests < UnitTests - desc "Skip" - subject { result1 } + class InitSkipTests < UnitTests + desc "Skip when init" + subject { Skip.new({}) } - let(:result1) { Skip.new({}) } - should "know its type/name" do assert_that(subject.type).equals(:skip) assert_that(subject.class.type).equals(:skip) assert_that(subject.class.name).equals("Skip") end @@ -357,16 +350,14 @@ should "not allow creating for a test with non-TestSkipped exceptions" do assert_that(-> { Skip.for_test(test1, RuntimeError.new) }).raises(ArgumentError) end end - class ErrorTests < UnitTests - desc "Error" - subject { result1 } + class InitErrorTests < UnitTests + desc "Error when init" + subject { Error.new({}) } - let(:result1) { Error.new({}) } - should "know its class-level type/name" do assert_that(subject.class.type).equals(:error) assert_that(subject.class.name).equals("Error") end @@ -386,14 +377,12 @@ should "not allow creating for a test without an exception" do assert_that(-> { Error.for_test(test1, Factory.string) }).raises(ArgumentError) end end - class BacktraceTests < UnitTests - desc "Backtrace" - subject { backtrace1 } - - let(:backtrace1) { Backtrace.new(Factory.backtrace) } + class InitBacktraceTests < UnitTests + desc "Backtrace when init" + subject { Backtrace.new(Factory.backtrace) } should have_cmeths :parse, :to_s should have_imeths :filtered should "be parseable from its string representation" do