Sha256: 310ff9e55173674a672a49dea198d6ec9991ac86a08c9967545e3021be8dc52e

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), "../../../spec_helper"))
module WebResourceBundler::Filters::ImageEncodeFilter
	describe ImageData do
    def image_path(filename)
      File.join("/images", filename)
    end

		context "with non existent file" do

      it "doesn't raise exception if image url is absolute but exist should be false" do
        ImageData.new("http://google.com/1.png", "some_folder").exist.should == false
      end

		end

		context "with existent small enough file" do
			before(:each) do
				@data = ImageData.new(image_path("logo.jpg"), settings.resource_dir)
			end
			
			it "should exist" do
				@data.exist.should be_true
			end

			it "should have id and extension" do
				@data.id.should_not be_nil
				@data.extension.should_not be_nil
			end
			
			it "should return some text when encoded" do
				@data.encoded.should_not be_nil
			end

			it "should have unique id" do
				new_data = ImageData.new(image_path("good.jpg"), settings.resource_dir)
				new_data.exist.should be_true
				@data.id.should_not equal(new_data.id)
  		end

			describe "#construct_mthml_image_data" do
				it "should return proper data" do
					result = '--' + CssGenerator::SEPARATOR + "\n" +
					"Content-Location:" + @data.id  + "\n" + 
					"Content-Transfer-Encoding:base64" + "\n\n" +
					@data.encoded + "\n\n"
					@data.construct_mhtml_image_data('--' + CssGenerator::SEPARATOR).should == result
				end
			end
				
		end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
web_resource_bundler-0.0.13 spec/web_resource_bundler/filters/image_encode_filter/image_data_spec.rb