Sha256: 0f24d9cfd675cfb29da35d2fbbd70b9b34001f1c75daad004795b4d3f7f4ba0d

Contents?: true

Size: 1.29 KB

Versions: 6

Compression:

Stored size: 1.29 KB

Contents

# encoding: UTF-8

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


class ExtensionsTest < MiniTest::Spec
  context "String" do
    should "create paths with String#/" do
      ("this" / "that").should == "this/that"
      ("/this" / "/that").should == "/this/that"
    end

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

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

    should "return self for #value" do
      "this".value.should == "this"
      "this".value(:html).should == "this"
      "this".value(:smsx).should == "this"
    end
  end

  context "Nil" do
    should "always return the argument for the slash switch" do
      (nil / "something").should == "something"
    end
    should "always return the argument for the #or switch" do
      (nil.or("something")).should == "something"
    end
  end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta1 test/unit/test_extensions.rb
spontaneous-0.2.0.alpha7 test/unit/test_extensions.rb
spontaneous-0.2.0.alpha6 test/unit/test_extensions.rb
spontaneous-0.2.0.alpha5 test/unit/test_extensions.rb
spontaneous-0.2.0.alpha4 test/unit/test_extensions.rb
spontaneous-0.2.0.alpha3 test/unit/test_extensions.rb