test/unit/result_tests.rb in assert-2.15.0 vs test/unit/result_tests.rb in assert-2.15.1

- old
+ new

@@ -24,11 +24,11 @@ assert_equal Base, subject.types[Factory.string] end should "create results from data hashes" do - type = Assert::Result.types.keys.choice + type = Assert::Result.types.keys.sample exp = Assert::Result.types[type].new(:type => type) assert_equal exp, Assert::Result.new(:type => type) end @@ -39,20 +39,23 @@ setup do @given_data = { :type => Factory.string, :name => Factory.string, :test_name => Factory.string, + :test_id => Factory.string, :message => Factory.string, + :output => Factory.text, :backtrace => Backtrace.new(caller), :trace => Factory.string } @result = Base.new(@given_data) end subject{ @result } should have_cmeths :type, :name, :for_test - should have_imeths :type, :name, :test_name, :message, :backtrace, :trace + should have_imeths :type, :name, :test_name, :test_id + should have_imeths :message, :output, :backtrace, :trace should have_imeths *Assert::Result.types.keys.map{ |k| "#{k}?" } should have_imeths :set_backtrace, :data, :to_sym, :to_s should "know its class-level type/name" do assert_equal :unknown, subject.class.type @@ -65,32 +68,38 @@ result = Base.for_test(@test, message, bt) exp_backtrace = Backtrace.new(bt) exp_trace = exp_backtrace.filtered.first.to_s - assert_equal @test.name, result.test_name + assert_equal @test.name, result.test_name + assert_equal @test.file_line.to_s, result.test_id + assert_equal message, result.message assert_equal exp_backtrace, result.backtrace assert_equal exp_trace, result.trace end should "use any given attrs" do assert_equal @given_data[:type].to_sym, subject.type assert_equal @given_data[:name], subject.name assert_equal @given_data[:test_name], subject.test_name + assert_equal @given_data[:test_id], subject.test_id assert_equal @given_data[:message], subject.message + assert_equal @given_data[:output], subject.output assert_equal @given_data[:backtrace], subject.backtrace assert_equal @given_data[:trace], subject.trace end should "default its attrs" do result = Base.new({}) assert_equal :unknown, result.type assert_equal '', result.name assert_equal '', result.test_name + assert_equal '', result.test_id assert_equal '', result.message + assert_equal '', result.output assert_equal Backtrace.new([]), result.backtrace assert_equal '', result.trace end should "know if it is a certain type of result" do @@ -115,11 +124,13 @@ should "know its data" do exp = { :type => subject.type, :name => subject.name, :test_name => subject.test_name, + :test_id => subject.test_id, :message => subject.message, + :output => subject.output, :backtrace => subject.backtrace, :trace => subject.trace, } assert_equal exp, subject.data end @@ -146,10 +157,10 @@ should "know if it is equal to another result" do other = Assert::Result::Base.new(@given_data) assert_equal other, subject - Assert.stub(other, [:type, :message].choice){ Factory.string } + Assert.stub(other, [:type, :message].sample){ Factory.string } assert_not_equal other, subject end should "show only its class and message when inspected" do exp = "#<#{subject.class}:#{'0x0%x' % (subject.object_id << 1)}"\