require File.expand_path('../../../test_helper', __FILE__) require 'date' require 'stringio' # Test running tests with the Rhino driver. class TestDots < MiniTest::Unit::TestCase def setup @output = StringIO.new @formatter = ::QUnited::Formatter::Dots.new({:driver_name => 'FakeDriver', :output => @output}) end def test_basic_output @formatter.start assert_output_equals "\n# Running JavaScript tests with FakeDriver:\n\n" @formatter.test_passed create_result([ create_assertion(:message => 'good assertion 1'), create_assertion(:message => 'good assertion 2') ]) assert_output_equals '.' @formatter.test_passed create_result([ create_assertion({ :result => true, :message => "doesn't matter" }) ]) assert_output_equals '.' @formatter.stop @formatter.summarize seconds = 0.02 expected = < false, :message => msg }) ]) assert_output_equals 'F' @formatter.stop @formatter.summarize seconds = 0.01 expected = < false, :message => msg, :expected => expected, :actual => actual }) ]) assert_output_equals 'F' @formatter.stop @formatter.summarize seconds = 0.01 expected = < false, :message => msg, :expected => expected, :actual => actual }) ]) assert_output_equals 'F' @formatter.stop @formatter.summarize seconds = 0.01 expected = < false, :message => msg }) ], {:file => nil}) assert_output_equals 'F' @formatter.stop @formatter.summarize seconds = 0.01 expected = < false, :message => msg1 }) ]) assert_output_equals 'F' msg2 = "These strings match" msg3 = "Another thing that should be true" expected, actual = "String here", "Other string here" @formatter.test_failed create_result([ create_assertion({ :result => false, :message => msg2, :expected => expected, :actual => actual }), create_assertion({ :result => false, :message => msg3 }) ]) assert_output_equals 'F' @formatter.stop @formatter.summarize seconds = 0.01 * 2 expected = < assertions, :assertions => assertions.size, :duration => 0.010, :failed => assertions.select {|a| !a[:result]}.size, :file => "something_test.js", :module_name => "My Tests", :name => "This stuff should work", :start => DateTime.now, :total => assertions.size }.merge(data)) end def create_assertion(data={}) { :message => 'This is the message', :result => true }.merge(data) end end