Sha256: 0ea98f7faf21fc3d30e131b8ee7e3b0217f3cb2473500302f841cbdad593c298

Contents?: true

Size: 1.44 KB

Versions: 5

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'
require 'sugar-high/file'

describe "SugarHigh" do
  describe "File" do
    let(:empty_file) { fixture_file 'empty.txt' }
    let(:file)       { fixture_file 'non-empty.txt'}

    describe '#self.blank' do
      it "should return true for an empty file" do
        File.blank?(empty_file).should be_true 
      end

      it "should return false for a NON-empty file" do
        File.blank?(file).should_not be_true
      end
    end

    describe '#blank' do    
      it "should return true for an empty file" do
        File.new(empty_file).blank?.should be_true
      end

      it "should return false for a NON-empty file" do
        File.new(file).blank?.should_not be_true
      end
    end
  end
  
  describe 'String path ext' do    
    describe '#path' do    
      it "should return a String extended with PathString" do
        path_str = "a/b/c".path
        path_str.kind_of?(PathString).should be_true
        path_str.respond_to?(:up).should be_true
        path_str.respond_to?(:down).should be_true
      end
    end 
  end

  describe 'PathString' do    
    describe '#up' do    
      it "should go up two folder levels" do
        up_path = "a/b/c".path.up(2)        
        up_path.should == "../../a/b/c"
      end
    end

    describe '#down' do    
      it "should go down two folder levels" do
        dwn_path = "../../a/b/c".path.down(2)        
        dwn_path.should == "a/b/c"
      end
    end
  end
end
    

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sugar-high-0.1.5 spec/sugar-high/file_spec.rb
sugar-high-0.1.4 spec/sugar-high/file_spec.rb
sugar-high-0.1.2 spec/sugar-high/file_spec.rb
sugar-high-0.1.1 spec/sugar-high/file_spec.rb
sugar-high-0.1.0 spec/sugar-high/file_spec.rb