spec/file_spec.rb in happi-0.0.5 vs spec/file_spec.rb in happi-0.0.10

- old
+ new

@@ -1,22 +1,46 @@ require 'spec_helper' +require 'rack/test' describe Happi::File do - subject { Happi::File.new(__FILE__) } + context "with a file name" do + subject { Happi::File.new(__FILE__) } - describe '#encode_file' do - encoded = Base64.encode64(File.read(__FILE__)) - specify { expect(subject.encode_file).to eql(encoded) } - end + describe '#encode_file' do + encoded = Base64.encode64(File.read(__FILE__)) + specify { expect(subject.encode_file).to eql(encoded) } + end - describe '#mime_type' do - specify { expect(subject.mime_type).to eql('application/x-ruby') } - end + describe '#mime_type' do + specify { expect(subject.mime_type).to eql('application/x-ruby') } + end - describe '#multipart' do - # specify { expect(subject.multipart).to } + describe '#multipart' do + # specify { expect(subject.multipart).to } + end + + describe '#exists?' do + specify { expect(subject.exists?).to eq(true) } + end end - describe '#exists?' do - specify { expect(subject.exists?).to be_true } + context "with an ActionDispatch::Http::UploadedFile" do + subject { Happi::File.new(Rack::Test::UploadedFile.new(__FILE__, 'application/x-ruby')) } + + describe '#encode_file' do + encoded = Base64.encode64(File.read(__FILE__)) + specify { expect(subject.encode_file).to eql(encoded) } + end + + describe '#mime_type' do + specify { expect(subject.mime_type).to eql('application/x-ruby') } + end + + describe '#multipart' do + # specify { expect(subject.multipart).to } + end + + describe '#exists?' do + specify { expect(subject.exists?).to eq(true) } + end end end