File: spec_should-output.rb

package info (click to toggle)
ruby-test-spec 0.10.0-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 280 kB
  • sloc: ruby: 1,851; makefile: 9
file content (25 lines) | stat: -rw-r--r-- 628 bytes parent folder | download | duplicates (3)
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
require 'test/spec'
require 'test/spec/should-output'

context "should.output" do
  specify "works for print" do
    lambda { print "foo" }.should.output "foo"
    lambda { print "foo" }.should.output(/oo/)
  end

  specify "works for puts" do
    lambda { puts "foo" }.should.output "foo\n"
    lambda { puts "foo" }.should.output(/foo/)
  end

  specify "works with readline" do
    lambda { require 'readline' }.should.not.raise(LoadError)
    lambda { puts "foo" }.should.output "foo\n"
    lambda { puts "foo" }.should.output(/foo/)

    File.should.not.exist(File.join(Dir.tmpdir, "should_output_#{$$}"))
  end
end