Sha256: 9c7eea0d8b739fb03517c90f2945b1d80210614bd655a81cb2735b41c29fb569

Contents?: true

Size: 1.37 KB

Versions: 52

Compression:

Stored size: 1.37 KB

Contents

require 'spec_helper'

describe Dragonfly::UrlAttributes do
  
  before(:each) do
    @hash = Dragonfly::UrlAttributes.new
  end

  describe "name" do
    it "should default to nil" do
      @hash.name.should be_nil
    end
    it "should return the name if set" do
      @hash[:name] = 'long.pigs'
      @hash.name.should == 'long.pigs'
    end
    it "should allow setting via an accessor" do
      @hash.name = 'john.doe'
      @hash[:name].should == 'john.doe'
    end
  end
  
  describe "sanity check for use of HasFilename" do
    it "should provide ext and basename" do
      @hash.name = 'dog.leg'
      @hash.basename.should == 'dog'
      @hash.ext.should == 'leg'
    end
  end

  describe "slice" do
    it "should return a subset of the params" do
      hash = Dragonfly::UrlAttributes[:a => 1, :b => 2, :c => 3]
      hash.slice(:a, :b).should == {:a => 1, :b => 2}
    end
    it "should use the method instead of the param for basename" do
      Dragonfly::UrlAttributes[:name => 'hello.ted'].slice(:basename).should == {:basename => 'hello'}
    end
    it "should use the method instead of the param for ext" do
      Dragonfly::UrlAttributes[:name => 'hello.ted'].slice(:ext).should == {:ext => 'ted'}
    end
    it "should treat strings like symbols" do
      Dragonfly::UrlAttributes[:yog => 'gurt', :john => 'doe'].slice('yog').should == {:yog => 'gurt'}
    end
  end

end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/url_attributes.rb
classiccms-0.7.4 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/url_attributes.rb
classiccms-0.7.3 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/url_attributes.rb
classiccms-0.7.2 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/url_attributes.rb
classiccms-0.7.1 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/url_attributes.rb
classiccms-0.7.0 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/url_attributes.rb
dragonfly-0.9.15 spec/dragonfly/url_attributes.rb
dragonfly-0.9.14 spec/dragonfly/url_attributes.rb
dragonfly-0.9.13 spec/dragonfly/url_attributes.rb
classiccms-0.6.9 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/url_attributes.rb
classiccms-0.6.8 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/url_attributes.rb
classiccms-0.6.7 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/url_attributes.rb
classiccms-0.6.6 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/url_attributes.rb
classiccms-0.6.5 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/url_attributes.rb
classiccms-0.6.4 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/url_attributes.rb
classiccms-0.6.3 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/url_attributes.rb
classiccms-0.6.2 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/url_attributes.rb
classiccms-0.6.1 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/url_attributes.rb
classiccms-0.6.0 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/url_attributes.rb
classiccms-0.5.17 vendor/bundle/gems/dragonfly-0.9.12/spec/dragonfly/url_attributes.rb