Skip to content
Browse files

I guess these belong in the helper

  • Loading branch information...
1 parent 9ea1324 commit e1dfd1c308fc23166b07fad81ce98c318062198b @snaggled snaggled committed Mar 17, 2009
Showing with 38 additions and 39 deletions.
  1. +0 −39 spec/mime_type_spec.rb
  2. +38 −0 spec/spec_helper.rb
View
39 spec/mime_type_spec.rb
@@ -6,45 +6,6 @@
# between file sizes, and has a tendency to classify files into the 'application/octet-stream'
# mimetype, whereas, looking at the ext results in 'unknown/unknown' more often.
-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
-
describe "An open file" do
describe "with a zero filelength" do
View
38 spec/spec_helper.rb
@@ -2,3 +2,41 @@
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

0 comments on commit e1dfd1c

Please sign in to comment.
Something went wrong with that request. Please try again.