lib/rib/test.rb in rib-1.5.1 vs lib/rib/test.rb in rib-1.5.2
- old
+ new
@@ -5,22 +5,44 @@
Pork::Suite.include(Muack::API)
require 'rib'
copy :rib do
+ before do
+ Rib.disable_plugins
+ end
+
after do
Muack.verify
end
+ def shell opts={}
+ @shell ||= new_shell(opts)
+ end
+
def new_shell opts={}
- shell = Rib::Shell.new(
- {:binding => Object.new.instance_eval{binding}}.merge(opts)
- )
+ shell = Rib::Shell.new(opts)
yield(shell) if block_given?
shell.before_loop
end
+ def stub_output
+ stub(shell).print(is_a(String)){}
+ stub(shell).puts(is_a(String)){}
+ end
+
+ def readline?
+ Rib.constants.map(&:to_s).include?('Readline') &&
+ Rib::Readline.enabled?
+ end
+
+ def stub_readline meth=:stub
+ send(meth, ::Readline).readline(is_a(String), true) do
+ (::Readline::HISTORY << str.chomp).last
+ end
+ end
+
singleton_class.module_eval do
def test_for *plugins, &block
require 'rib/all' # exhaustive tests
rest = Rib.plugins - plugins
@@ -65,20 +87,9 @@
rest[0].enable
test_level3(rest[1..-1], block)
rest[0].disable
test_level3(rest[1..-1], block)
end
- end
-
- def readline?
- Rib.constants.map(&:to_s).include?('Readline') &&
- Rib::Readline.enabled?
- end
-
- def stub_readline
- stub(::Readline).readline(is_a(String), true){
- (::Readline::HISTORY << str.chomp).last
- }
end
end
def main
'rib'