require 'readline-ng'
require 'mocha'

# Hook to reset internal state between runs
module ReadlineNG
  class Reader
    def self.initialized=(v)
      @@initialized = v
    end
  end
end

describe ReadlineNG do

  before(:each) do
    @reader = ReadlineNG::Reader.new
    @reader.visible = false
  end

  after(:each) do
    @reader.send(:teardown)
    ReadlineNG::Reader.initialized = false
  end

  it "should only return full lines of input" do
    STDIN.stub(:read_nonblock).and_return("in", "put", "\r")
    @reader.tick # gets "in"
    @reader.lines.should be_empty
    @reader.tick # gets "put"
    @reader.lines.should be_empty
    @reader.tick
    @reader.line.should == "input"
  end

end


require 'readline-ng'
require 'mocha'

describe ReadlineNG do

  before(:each) do
    @reader = ReadlineNG::Reader.new
    @reader.visible = false
  end

  after(:each) do
    @reader.send(:teardown)
  end

  it "should only return full lines of input" do
    STDIN.stub(:read_nonblock).and_return("in", "put", "\r")
    @reader.tick # gets "in"
    @reader.lines.should be_empty
    @reader.tick # gets "put"
    @reader.lines.should be_empty
    @reader.tick
    @reader.line.should == "input"
  end

end


--- 
+++ 
@@ -1,5 +1,14 @@
 require 'readline-ng'
 require 'mocha'
+
+# Hook to reset internal state between runs
+module ReadlineNG
+  class Reader
+    def self.initialized=(v)
+      @@initialized = v
+    end
+  end
+end
 
 describe ReadlineNG do
 
@@ -10,6 +19,7 @@
 
   after(:each) do
     @reader.send(:teardown)
+    ReadlineNG::Reader.initialized = false
   end
 
   it "should only return full lines of input" do
Reset initialization state between examples
