Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/app/spec/stdout.rb
blob: bffa90b9d74f5dfa0d3eb72cc5082b5a8d5b4d98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env ruby

require 'lib/dev/stdout'

require 'spec/autorun'

# XXX: dots will be doubled because they are written also as part of the test
#      I chose to display dots so that the spec execution output looks good
describe STDOUT, "#write" do
  it "should emit the :output signal" do
    event_called = false
    conn = STDOUT.on_event :output, :any do
      event_called = true
    end
    STDOUT.write "."
    STDOUT.delete_event_connection conn
    event_called.should == true
  end

  it "should emit a signal with the correct argument" do
    event_called = false
    conn = STDOUT.on_event :output, :any do |arg|
      event_called = true
      arg.should == "."
    end
    STDOUT.write "."
    STDOUT.delete_event_connection conn
    event_called.should == true
  end

  it "should be called when using print" do
    event_called = false
    conn = STDOUT.on_event :output, :any do
      event_called = true
    end
    print "."
    STDOUT.delete_event_connection conn
    event_called.should == true
  end
end