Sha256: 4ed5064cb929e68c6d95d72bed446edbdd8615e7994148239e1b45d0ee97d885

Contents?: true

Size: 1.99 KB

Versions: 12

Compression:

Stored size: 1.99 KB

Contents

require 'spec_helper'

describe IMGKit::Source do
  
  describe "#url?" do
    it "should return true if passed a url like string" do
      source = IMGKit::Source.new('http://google.com')
      source.should be_url
    end
    
    it "should return false if passed a file" do
      source = IMGKit::Source.new(File.new(__FILE__))
      source.should_not be_url
    end
    
    it "should return false if passed HTML" do
      source = IMGKit::Source.new('<blink>Oh Hai!</blink>')
      source.should_not be_url
    end
  end
  
  describe "#file?" do
    it "should return true if passed a file" do
      source = IMGKit::Source.new(File.new(__FILE__))
      source.should be_file
    end
    
    it "should return false if passed a url like string" do
      source = IMGKit::Source.new('http://google.com')
      source.should_not be_file
    end
    
    it "should return false if passed HTML" do
      source = IMGKit::Source.new('<blink>Oh Hai!</blink>')
      source.should_not be_file
    end
  end
  
  describe "#html?" do
    it "should return true if passed HTML" do
      source = IMGKit::Source.new('<blink>Oh Hai!</blink>')
      source.should be_html
    end
    
    it "should return false if passed a file" do
      source = IMGKit::Source.new(File.new(__FILE__))
      source.should_not be_html
    end
    
    it "should return false if passed a url like string" do
      source = IMGKit::Source.new('http://google.com')
      source.should_not be_html
    end
  end
  
  describe "#to_s" do
    it "should return the HTML if passed HTML" do
      source = IMGKit::Source.new('<blink>Oh Hai!</blink>')
      source.to_s.should == '<blink>Oh Hai!</blink>'
    end
    
    it "should return a path if passed a file" do
      source = IMGKit::Source.new(File.new(__FILE__))
      source.to_s.should == __FILE__
    end
    
    it "should return the url if passed a url like string" do
      source = IMGKit::Source.new('http://google.com')
      source.to_s.should == 'http://google.com'
    end
  end
  
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
imgkit-1.3.4 spec/source_spec.rb
imgkit-1.3.3 spec/source_spec.rb
imgkit-1.3.2 spec/source_spec.rb
imgkit-1.3.1 spec/source_spec.rb
imgkit-1.3.0 spec/source_spec.rb
imgkit-1.2.1 spec/source_spec.rb
imgkit-1.2.0 spec/source_spec.rb
imgkit-1.1.0 spec/source_spec.rb
imgkit-1.0.2 spec/source_spec.rb
imgkit-1.0.1 spec/source_spec.rb
imgkit-1.0.0 spec/source_spec.rb
imgkit-0.9.2 spec/source_spec.rb