Sha256: 9834d123e69f3929c949127409ab00fe8b724400f34ec5bf06eaa553667f4ecb

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
require 'usher'

describe Delimiters do
  describe "#unescaped" do
    it "should unescape delimiters correctly" do
      Delimiters.new(['/', '\)', '\\\\']).unescaped.should == ['/', ')', '\\']
    end
  end

  describe "#first_in" do
    describe "when there is a complex path with a lot of delimiters occurrences" do
      before :each do
        @delimiters = Delimiters.new ['@', '.', '/']
        @paths = ['var', '.', 'var', '/', 'var', '@']
      end

      it "should find nearest delimiter correctly" do
        @delimiters.first_in(@paths).should == '.'
        @delimiters.first_in(@paths[2..-1]).should == '/'
        @delimiters.first_in(@paths[4..-1]).should == '@'
      end
    end

    describe "when there are delimiters with escaped charaters" do
      before :each do
        @delimiters = Delimiters.new ['\\(', '\\)']
        @paths = ['var', '(', 'var', ')']
      end

      it "should find nearest delimiter in unescaped path" do
        @delimiters.first_in(@paths).should == '('
      end
    end

    describe "when there is no occurence of delimiters in path" do
      before :each do
        @delimiters = Delimiters.new ['-', '/']
        @paths = ['e', '@', 'ma', '.', 'il']
      end

      it "should return nil" do
        @delimiters.first_in(@paths).should be_nil
      end
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
usher-0.5.13 spec/private/delimiters_spec.rb
usher-0.5.12 spec/private/delimiters_spec.rb
usher-0.5.11 spec/private/delimiters_spec.rb