lib/rib/test.rb in rib-1.5.4 vs lib/rib/test.rb in rib-1.6.0

- old
+ new

@@ -18,18 +18,21 @@ def shell opts={} @shell ||= new_shell(opts) end def new_shell opts={} - shell = Rib::Shell.new(opts) - yield(shell) if block_given? - shell.before_loop + result = Rib::Shell.new( + {:binding => Object.new.instance_eval{binding}}. + merge(opts)) + yield(result) if block_given? + result.before_loop end def stub_output stub(shell).print(is_a(String)){} stub(shell).puts(is_a(String)){} + stub(shell).puts{} end def readline? Rib.constants.map(&:to_s).include?('Readline') && Rib::Readline.enabled? @@ -49,46 +52,66 @@ before do Rib.enable_plugins(plugins) Rib.disable_plugins(rest) end - yield + describe "enabling #{plugins}" do + block.call - case ENV['TEST_LEVEL'] + case ENV['TEST_LEVEL'] when '0' when '1' test_level1(rest, block) when '2' test_level2(rest, block) when '3' test_level3(rest, block) else # test_level3 is too slow because of rr (i guess) test_level2(rest, block) + end end end def test_level1 rest, block rest.each{ |target| target.enable - block.call + + describe "also enabling #{target}" do + block.call + end + target.disable } end def test_level2 rest, block rest.combination(2).each{ |targets| Rib.enable_plugins(targets) - block.call + + describe "also enabling #{targets.join(', ')}" do + block.call + end + Rib.disable_plugins(targets) } end def test_level3 rest, block - return block.call if rest.empty? - rest[0].enable - test_level3(rest[1..-1], block) - rest[0].disable - test_level3(rest[1..-1], block) + if rest.empty? + block.call + else + rest[0].enable + + describe "also enabling #{rest[0]}" do + test_level3(rest[1..-1], block) + end + + rest[0].disable + + describe "disabling #{rest[0]}" do + test_level3(rest[1..-1], block) + end + end end end end def main