Sha256: 59a7cbd6a5cee3b61afae9d380894e19b19bbf54a6a42224ffd82afdc25b3acd

Contents?: true

Size: 952 Bytes

Versions: 4

Compression:

Stored size: 952 Bytes

Contents

ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../../../../config/environment")
require 'test_help'

def create_file(filename, mode='w')
  @file = File.new(File.dirname(__FILE__) + "/fixtures/#{filename}", mode)
end

def close
  @file.close
  @file = @file.path
end

def open_file(filename, mode='r')
  @file = File.open(File.dirname(__FILE__) + "/fixtures/#{filename}", mode)
end

def write_file(filename, data, mode='wb')
  file = create_file(filename, mode)
  file.write(data)
  file.flush
end

def file_or_path(file)
  file.is_a?(File) ? file.path : file
end

def delete_file
  File.delete file_or_path(@file)
end

def it_should_have_an_extension_of(ext)
  it "should have an extension of #{ext}" do
    File.extname(file_or_path(@file)).should == ".#{ext}"
  end
end

def it_should_have_a_mime_type_of(mimetype)
  it "should have a mime type of #{mimetype}" do
    File.mime_type?(@file).should == mimetype
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
futuresinc-mimetype-fu-0.1.0 spec/spec_helper.rb
futuresinc-mimetype-fu-0.1.1 spec/spec_helper.rb
mimetype-fu-0.1.2 spec/spec_helper.rb
mimetype-fu-0.1.1 spec/spec_helper.rb