Sha256: 09f47dce5186ed55e7309b49bceed7093d02539fdb065d05f5baf4dac3012d95

Contents?: true

Size: 1.76 KB

Versions: 7

Compression:

Stored size: 1.76 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe ExtendCore, 'Float.rb' do
  before(:all) do
    include ExtendCore
  end
  describe ExtendCore, 'round_to' do
    it "should return float rounded to specified precision" do
      0.3333.round_to(0.01).should eql(0.33)
      0.3333.round_to(0.001).should eql(0.333)
      0.33335.round_to(0.0001).should eql(0.3334)
    end
  end
end


describe ExtendCore, 'String.rb' do
  before(:all) do
    include ExtendCore
  end
  describe ExtendCore, 'safe_datetime_string' do
    it "should set US formated datetime string to international" do
      "12/31/2010".safe_datetime_string.should eql("2010-12-31")
      "12/31/2010T23:31:59".safe_datetime_string.should eql("2010-12-31T23:31:59")
      "12/31/2010 23:31:59".safe_datetime_string.should eql("2010-12-31 23:31:59")

    end
  end
  describe ExtendCore, 'to_b' do
    it "should return a Boolean" do
      "1".to_b.class.should eql(TrueClass)
      "".to_b.class.should eql(FalseClass)
    end

    it "should return true if string is '1' or 't' or 'true'"do
      ['1','t','true'].each do |s|
        s.to_b.should be_true
      end
    end
    
  end
  describe ExtendCore, 'to_date' do
    it "return a Date object" do
      "12/31/2010".to_date.class.should eql(Date)
    end
  end
  describe ExtendCore, 'to_date' do
    it "return a Time object" do
      "12/31/2010".to_time.class.should eql(Time)
    end
  end
  describe ExtendCore, 'to_f' do
    it "return a Foat from a string that may contain non-numeric values" do
      "$5,000.006".to_f.should eql(5000.006)
    end
  end
  describe ExtendCore, 'to_currency' do
    it "return a Foat from a string that may contain non-numeric values" do
      "$5,000.006".to_currency.should eql(5000.01)
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
simple_model-0.1.6 spec/extend_core_spec.rb
simple_model-0.1.5 spec/extend_core_spec.rb
simple_model-0.1.4 spec/extend_core_spec.rb
simple_model-0.1.3 spec/extend_core_spec.rb
simple_model-0.1.2 spec/extend_core_spec.rb
simple_model-0.1.1 spec/extend_core_spec.rb
simple_model-0.1.0 spec/extend_core_spec.rb