Sha256: 1a73d2781f83424db32d5a1f2f2c7d760575417c1d188476434fed198285cf96

Contents?: true

Size: 1.28 KB

Versions: 8

Compression:

Stored size: 1.28 KB

Contents

# encoding: UTF-8

require File.expand_path('../../test_helper', __FILE__)


describe "Extensions" do
  describe "String" do
    it  "create paths with String#/" do
      ("this" / "that").must_equal "this/that"
      ("/this" / "/that").must_equal "/this/that"
    end

    it  "override the | method to return the argument if empty" do
      ("" | "that").must_equal "that"
      ("this" | "that").must_equal "this"
    end

    it  "override the or method to return the argument if empty" do
      ("".or("that")).must_equal "that"
      ("this".or("that")).must_equal "this"
    end

    it  "return self for #value" do
      "this".value.must_equal "this"
      "this".value(:html).must_equal "this"
      "this".value(:smsx).must_equal "this"
    end
  end

  describe "Nil" do
    it  "always return the argument for the slash switch" do
      (nil / "something").must_equal "something"
    end
    it  "always return the argument for the #or switch" do
      (nil.or("something")).must_equal "something"
    end
  end

  describe "Enumerable" do
    it  "correctly slice_between elements" do
      result = ["js", "coffee", "coffee", "js", "coffee"].slice_between { |prev, current| prev != current }.to_a
      result.must_equal [["js"], ["coffee", "coffee"], ["js"], ["coffee"]]
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta9 test/unit/test_extensions.rb
spontaneous-0.2.0.beta8 test/unit/test_extensions.rb
spontaneous-0.2.0.beta7 test/unit/test_extensions.rb
spontaneous-0.2.0.beta6 test/unit/test_extensions.rb
spontaneous-0.2.0.beta5 test/unit/test_extensions.rb
spontaneous-0.2.0.beta4 test/unit/test_extensions.rb
spontaneous-0.2.0.beta3 test/unit/test_extensions.rb
spontaneous-0.2.0.beta2 test/unit/test_extensions.rb