Sha256: 123d194871e96f01b774fed3c7b3f64190755700b0c41ae818e15bd54189b209
Contents?: true
Size: 1.51 KB
Versions: 4
Compression:
Stored size: 1.51 KB
Contents
require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') describe Attributor::String do subject(:type) { Attributor::String } context '.native_type' do it "returns String" do type.native_type.should be(::String) end end context '.example' do it "should return a valid String" do type.example(options:{regexp: /\w\d{2,3}/}).should be_a(::String) end it "should return a valid String" do type.example.should be_a(::String) end it 'handles regexps that Randexp can not' do pending 'resolution of #72' do regex = /\w+(,\w+)*/ expect { val = Attributor::String.example(options:{regexp: regex}) val.should be_a(::String) }.to_not raise_error end end end context '.load' do let(:value) { nil } it 'returns nil for nil' do type.load(nil).should be(nil) end context 'for incoming String values' do it 'returns the incoming value' do ['', 'foo', '0.0', '-1.0', '1.0', '1e-10', 1].each do |value| type.load(value).should eq(String(value)) end end end end context 'for incoming Symbol values' do let(:value) { :something } it 'returns the stringified-value' do type.load(value).should == value.to_s end end context 'for Enumerable values' do let(:value) { [1] } it 'raises IncompatibleTypeError' do expect { type.load(value) }.to raise_error(Attributor::IncompatibleTypeError) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
attributor-2.6.1 | spec/types/string_spec.rb |
attributor-2.6.0 | spec/types/string_spec.rb |
attributor-2.5.0 | spec/types/string_spec.rb |
attributor-2.4.0 | spec/types/string_spec.rb |