summaryrefslogtreecommitdiff
path: root/spec/mspec/spec/helpers/tmp_spec.rb
blob: 4dcf629d9409e2ac1afba020abd2b1036d37fcd4 (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
require 'spec_helper'
require 'mspec/guards'
require 'mspec/helpers'

describe Object, "#tmp" do
  before :all do
    @dir = SPEC_TEMP_DIR
  end

  it "returns a name relative to the current working directory" do
    tmp("test.txt").should == "#{@dir}/#{SPEC_TEMP_UNIQUIFIER}-test.txt"
  end

  it "returns a 'unique' name on repeated calls" do
    a = tmp("text.txt")
    b = tmp("text.txt")
    a.should_not == b
  end

  it "does not 'uniquify' the name if requested not to" do
    tmp("test.txt", false).should == "#{@dir}/test.txt"
  end

  it "returns the name of the temporary directory when passed an empty string" do
    tmp("").should == "#{@dir}/"
  end
end