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

describe Object, "#fixture" do
  before :each do
    @dir = File.realpath("..", __FILE__)
  end

  it "returns the expanded path to a fixture file" do
    name = fixture(__FILE__, "subdir", "file.txt")
    name.should == "#{@dir}/fixtures/subdir/file.txt"
  end

  it "omits '/shared' if it is the suffix of the directory string" do
    name = fixture("#{@dir}/shared/file.rb", "subdir", "file.txt")
    name.should == "#{@dir}/fixtures/subdir/file.txt"
  end

  it "does not append '/fixtures' if it is the suffix of the directory string" do
    commands_dir = "#{File.dirname(@dir)}/commands"
    name = fixture("#{commands_dir}/fixtures/file.rb", "subdir", "file.txt")
    name.should == "#{commands_dir}/fixtures/subdir/file.txt"
  end
end