Sha256: 5257f77f8b997c0a1e0916bc28119570e4974bd069f818f707d37039f463eccc
Contents?: true
Size: 1.79 KB
Versions: 1
Compression:
Stored size: 1.79 KB
Contents
require 'spec_helper' describe 'Transproc / Coercions' do describe 'to_string' do it 'turns integer into a string' do expect(t(:to_string)[1]).to eql('1') end end describe 'to_integer' do it 'turns string into an integer' do expect(t(:to_integer)['1']).to eql(1) end end describe 'to_float' do it 'turns string into a float' do expect(t(:to_float)['1']).to eql(1.0) end it 'turns integer into a float' do expect(t(:to_float)[1]).to eql(1.0) end end describe 'to_decimal' do it 'turns string into a decimal' do expect(t(:to_decimal)['1.251']).to eql(BigDecimal('1.251')) end it 'turns float into a decimal' do expect(t(:to_decimal)[1.251]).to eql(BigDecimal('1.251')) end it 'turns integer into a decimal' do expect(t(:to_decimal)[1]).to eql(BigDecimal('1.0')) end end describe 'to_date' do it 'turns string into a date' do date = Date.new(1983, 11, 18) expect(t(:to_date)['18th, November 1983']).to eql(date) end end describe 'to_time' do it 'turns string into a time object' do time = Time.new(2012, 1, 23, 11, 7, 7) expect(t(:to_time)['2012-01-23 11:07:07']).to eql(time) end end describe 'to_datetime' do it 'turns string into a date' do datetime = DateTime.new(2012, 1, 23, 11, 7, 7) expect(t(:to_datetime)['2012-01-23 11:07:07']).to eql(datetime) end end describe 'to_boolean' do subject(:coercer) { t(:to_boolean) } Transproc::TRUE_VALUES.each do |value| it "turns #{value.inspect} to true" do expect(coercer[value]).to be(true) end end Transproc::FALSE_VALUES.each do |value| it "turns #{value.inspect} to false" do expect(coercer[value]).to be(false) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
transproc-0.1.3 | spec/integration/coercions_spec.rb |