spec/extensions/pretty_table_spec.rb in sequel-5.2.0 vs spec/extensions/pretty_table_spec.rb in sequel-5.3.0

- old
+ new

@@ -58,35 +58,66 @@ end it "should infer the columns if not given" do Sequel::PrettyTable.print(@data1) @output.rewind - @output.read.must_match(/\n(\|x\|y\|)|(\|y\|x\|)\n/) + @output.read.must_equal(<<OUTPUT) ++-+-+ +|x|y| ++-+-+ +|3|4| ++-+-+ +OUTPUT end it "should have #string return the string without printing" do - Sequel::PrettyTable.string(@data1).must_match(/\n(\|x\|y\|)|(\|y\|x\|)\n/) + Sequel::PrettyTable.string(@data1).must_equal((<<OUTPUT).chomp) ++-+-+ +|x|y| ++-+-+ +|3|4| ++-+-+ +OUTPUT @output.rewind @output.read.must_equal '' end it "should calculate the maximum width of each column correctly" do Sequel::PrettyTable.print(@data2, [:a, :b]) @output.rewind - @output.read.must_equal \ - "+--+----+\n|a |b |\n+--+----+\n|23| 45|\n|45|2377|\n+--+----+\n" + @output.read.must_equal(<<OUTPUT) ++--+----+ +|a |b | ++--+----+ +|23| 45| +|45|2377| ++--+----+ +OUTPUT end it "should also take header width into account" do Sequel::PrettyTable.print(@data3, [:aaa, :bb, :c]) @output.rewind - @output.read.must_equal \ - "+---+--+---+\n|aaa|bb|c |\n+---+--+---+\n| 1| | |\n| | 2| |\n| | |3.1|\n+---+--+---+\n" + @output.read.must_equal(<<OUTPUT) ++---+--+---+ +|aaa|bb|c | ++---+--+---+ +| 1| | | +| | 2| | +| | |3.1| ++---+--+---+ +OUTPUT end it "should print only the specified columns" do Sequel::PrettyTable.print(@data2, [:a]) @output.rewind - @output.read.must_equal \ - "+--+\n|a |\n+--+\n|23|\n|45|\n+--+\n" + @output.read.must_equal(<<OUTPUT) ++--+ +|a | ++--+ +|23| +|45| ++--+ +OUTPUT end end