Sha256: 63a48a9a7f134b98857bef7416ca9f54c8ea95b31d3809e408a307fbf72aa6a9

Contents?: true

Size: 1.82 KB

Versions: 24

Compression:

Stored size: 1.82 KB

Contents

require File.join(File.dirname(__FILE__), 'test_helper')

describe "Util" do
  it "camelize converts underscore lowercase to camelcase" do
    Util.camelize('hirb/util').should == "Hirb::Util"
    Util.camelize('hirb_hash').should == "HirbHash"
  end

  it "any_const_get returns nested class" do
    Util.any_const_get("Hirb::Helpers").should == Hirb::Helpers
  end

  it "any_const_get returns nil for invalid class" do
    Util.any_const_get("Basdfr").should == nil
  end

  it "any_const_get returns class when given class" do
    Util.any_const_get(String).should == String
  end

  it "recursive_hash_merge merges" do
    expected_hash = {:output=>{:fields=>["f1", "f2"], :method=>"blah"}, :key1=>"hash1", :key2=>"hash2"}
    Util.recursive_hash_merge({:output=>{:fields=>%w{f1 f2}}, :key1=>'hash1'},
      {:output=>{:method=>'blah'}, :key2=>'hash2'}).should == expected_hash
  end

  it "choose_from_array specifies range with -" do
    Util.choose_from_array([1,2,3,4], '1-2,4').should == [1,2,4]
  end

  it "choose_from_array specifies range with .." do
    Util.choose_from_array([1,2,3,4], '1 .. 2,4').should == [1,2,4]
  end

  it "choose_from_array chooses all with *" do
    Util.choose_from_array([1,2,3,4], '*').should == [1,2,3,4]
  end

  it "choose_from_array ignores non-numerical input" do
    Util.choose_from_array([1,2,3,4], 'a,2').should == [2]
  end

  it "choose_from_array ignores 0" do
    Util.choose_from_array([1,2,3,4], '0,2').should == [2]
  end

  it "choose_from_array returns empty when empty input" do
    Util.choose_from_array([1,2,3,4], "\n").should == []
  end

  it "choose_from_array returns empty with an invalid range" do
    Util.choose_from_array([1,2,3,4], "5").should == []
  end

  it "capture_stdout" do
    string = "sweetness man"
    Util.capture_stdout { puts string }.should == string + "\n"
  end
end

Version data entries

24 entries across 23 versions & 4 rubygems

Version Path
hirber-0.8.5 test/util_test.rb
hirber-0.8.4 test/util_test.rb
hirber-0.8.2 test/util_test.rb
hirber-0.8.1 test/util_test.rb
hirber-0.8.0 test/util_test.rb
hirb-0.7.3 test/util_test.rb
climine-0.0.7 vendor/bundle/ruby/2.1.0/gems/hirb-0.7.1/test/util_test.rb
climine-0.0.7 vendor/bundle/ruby/2.0.0/gems/hirb-0.7.1/test/util_test.rb
hirb-0.7.2 test/util_test.rb
climine-0.0.6 vendor/bundle/ruby/2.0.0/gems/hirb-0.7.1/test/util_test.rb
climine-0.0.5 vendor/bundle/ruby/2.0.0/gems/hirb-0.7.1/test/util_test.rb
climine-0.0.4 vendor/bundle/ruby/2.0.0/gems/hirb-0.7.1/test/util_test.rb
climine-0.0.3 vendor/bundle/ruby/2.0.0/gems/hirb-0.7.1/test/util_test.rb
climine-0.0.2 vendor/bundle/ruby/2.0.0/gems/hirb-0.7.1/test/util_test.rb
climine-0.0.1 vendor/bundle/ruby/2.0.0/gems/hirb-0.7.1/test/util_test.rb
hirb-0.7.1 test/util_test.rb
hirb-0.7.0 test/util_test.rb
hirb-0.6.2 test/util_test.rb
hirb-0.6.1 test/util_test.rb
hsume2-hirb-0.6.3 test/util_test.rb