Sha256: f75534e81d042a56bb306d8c9999490eadb9d026b428442d51821daf80c2b4a4

Contents?: true

Size: 887 Bytes

Versions: 4

Compression:

Stored size: 887 Bytes

Contents

require File.dirname(__FILE__) + '/../../spec_helper'

describe "A String" do
  it "should convert a path/like/this to a Constant::String::Like::This" do
    "path/like/this".to_const_string.should == "Path::Like::This"
    "path".to_const_string.should == "Path"
    "snake_case/path/with_several_parts".to_const_string.should == "SnakeCase::Path::WithSeveralParts"
  end
  
  it "should raise an error rather than freeze when trying to convert bad Paths/12Like/-this" do
    Timeout::timeout(1) do
      lambda do
        "Paths/12Like/-this".to_const_string
      end.should raise_error(String::InvalidPathConversion)
    end.should_not raise_error(Timeout::Error)
  end

  it "should remove any indentation and add +indentation+ number of spaces" do
    "foo\n  bar\n".indent(3).should == "   foo\n     bar\n"
    "  foo\n    bar\n".indent(3).should == "   foo\n     bar\n"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
merb-0.5.0 spec/merb/core_ext/string_spec.rb
merb-0.5.1 spec/merb/core_ext/string_spec.rb
merb-0.5.2 spec/merb/core_ext/string_spec.rb
merb-0.5.3 spec/merb/core_ext/string_spec.rb