test/unit/utils_tests.rb in assert-2.16.5 vs test/unit/utils_tests.rb in assert-2.17.0
- old
+ new
@@ -1,18 +1,18 @@
-require 'assert'
-require 'assert/utils'
+require "assert"
+require "assert/utils"
-require 'tempfile'
-require 'assert/config'
+require "tempfile"
+require "assert/config"
module Assert::Utils
class UnitTests < Assert::Context
desc "Assert::Utils"
subject{ Assert::Utils }
setup do
- @objs = [ 1, 'hi there', Hash.new, [:a, :b]]
+ @objs = [1, "hi there", Hash.new, [:a, :b]]
end
should have_imeths :show, :show_for_diff
should have_imeths :tempfile
should have_imeths :stdlib_pp_proc, :default_use_diff_proc, :syscmd_diff_proc
@@ -23,11 +23,11 @@
class ShowTests < UnitTests
desc "`show`"
setup do
@pp_config = Assert::Config.new({
:pp_objects => true,
- :pp_proc => Proc.new{ |input| 'herp derp' }
+ :pp_proc => Proc.new{ |input| "herp derp" }
})
end
should "use `inspect` to show objs when `pp_objects` setting is false" do
@objs.each do |obj|
@@ -64,12 +64,12 @@
class TempfileTests < UnitTests
desc "`tempfile`"
should "require tempfile, open a tempfile, write the given content, and yield it" do
- subject.tempfile('a-name', 'some-content') do |tmpfile|
- assert_equal false, (require 'tempfile')
+ subject.tempfile("a-name", "some-content") do |tmpfile|
+ assert_equal false, (require "tempfile")
assert tmpfile
assert_kind_of Tempfile, tmpfile
tmpfile.pos = 0
assert_equal "some-content\n", tmpfile.read
@@ -80,16 +80,16 @@
class StdlibPpProcTests < UnitTests
desc "`stdlib_pp_proc`"
should "build a pp proc that uses stdlib `PP.pp` to pretty print objects" do
- exp_obj_pps = @objs.map{ |o| PP.pp(o, '', 79).strip }
+ exp_obj_pps = @objs.map{ |o| PP.pp(o, "", 79).strip }
act_obj_pps = @objs.map{ |o| subject.stdlib_pp_proc.call(o) }
assert_equal exp_obj_pps, act_obj_pps
cust_width = 1
- exp_obj_pps = @objs.map{ |o| PP.pp(o, '', cust_width).strip }
+ exp_obj_pps = @objs.map{ |o| PP.pp(o, "", cust_width).strip }
act_obj_pps = @objs.map{ |o| subject.stdlib_pp_proc(cust_width).call(o) }
assert_equal exp_obj_pps, act_obj_pps
end
end
@@ -102,25 +102,25 @@
end
should "be true if either output has newlines or is bigger than 29 chars" do
proc = subject.default_use_diff_proc
- assert_not proc.call('', '')
- assert proc.call(@longer, '')
- assert proc.call(@newlines, '')
- assert proc.call('', @longer)
- assert proc.call('', @newlines)
+ assert_not proc.call("", "")
+ assert proc.call(@longer, "")
+ assert proc.call(@newlines, "")
+ assert proc.call("", @longer)
+ assert proc.call("", @newlines)
assert proc.call(@longer, @newlines)
end
end
class SyscmdDiffProc < UnitTests
desc "`syscmd_diff_proc`"
setup do
- @diff_a_file = File.join(ROOT_PATH, 'test/support/diff_a.txt')
- @diff_b_file = File.join(ROOT_PATH, 'test/support/diff_b.txt')
+ @diff_a_file = File.join(ROOT_PATH, "test/support/diff_a.txt")
+ @diff_b_file = File.join(ROOT_PATH, "test/support/diff_b.txt")
@diff_a = File.read(@diff_a_file)
@diff_b = File.read(@diff_b_file)
end
@@ -132,10 +132,10 @@
assert_equal exp_diff_out, subject.syscmd_diff_proc.call(@diff_a, @diff_b)
end
should "allow you to specify a custom syscmd" do
- cust_syscmd = 'diff'
+ cust_syscmd = "diff"
exp_diff_out = `#{cust_syscmd} #{@diff_a_file} #{@diff_b_file}`.strip.tap do |out|
out.sub!(/^\-\-\- .+/, "--- expected")
out.sub!(/^\+\+\+ .+/, "+++ actual")
end