rubyspec / rubyspec

Executable specification for the Ruby programming language using RSpec syntax.

This URL has Read+Write access

rubyspec / core / io / shared / tty.rb
100644 19 lines (15 sloc) 0.56 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require File.dirname(__FILE__) + '/../fixtures/classes'
 
describe :io_tty, :shared => true do
  with_tty do
    # Yeah, this will probably break.
    it "returns true if this stream is a terminal device (TTY)" do
      File.open('/dev/tty') {|f| f.send @method }.should == true
    end
  end
 
  it "returns false if this stream is not a terminal device (TTY)" do
    File.open(__FILE__) {|f| f.send @method }.should == false
  end
 
  it "raises IOError on closed stream" do
    lambda { IOSpecs.closed_file.send @method }.should raise_error(IOError)
  end
end