Permalink
Browse files

Use a pipe to test command logging

* JRuby doesn't write to StringIO in the same way as cruby/rbx, and the
  #read method used in connection_spec didn't work here.
* Fixes failure 3 from #615.
  • Loading branch information...
1 parent 3f3ad93 commit 7816940122f3862028cab2da781edac73d60008f @mhoran mhoran committed Jan 29, 2014
Showing with 8 additions and 5 deletions.
  1. +8 −5 spec/driver_spec.rb
View
@@ -2246,28 +2246,31 @@ def which_for(character)
describe "logger app" do
it "logs nothing before turning on the logger" do
visit("/")
+ @write.close
log.should_not include logging_message
end
it "logs its commands after turning on the logger" do
driver.enable_logging
visit("/")
+ @write.close
log.should include logging_message
end
+ before do
+ @read, @write = IO.pipe
+ end
+
let(:logging_message) { 'Wrote response true' }
let(:driver) do
- connection = Capybara::Webkit::Connection.new(:stderr => output)
+ connection = Capybara::Webkit::Connection.new(:stderr => @write)
browser = Capybara::Webkit::Browser.new(connection)
Capybara::Webkit::Driver.new(AppRunner.app, :browser => browser)
end
- let(:output) { StringIO.new }
-
def log
- output.rewind
- output.read
+ @read.read
end
end

0 comments on commit 7816940

Please sign in to comment.