Sha256: 8d0afda8cdb1426c4de42692d5a6b37d2434a4487deb4aac7d4262deacea55a1
Contents?: true
Size: 1.4 KB
Versions: 4
Compression:
Stored size: 1.4 KB
Contents
require 'sham/util' describe Sham::Util do context '#extract_options!' do let(:ary){ [1, 2, 3, 4, {:opt => 'arg', :opt2 => 'arg'}] } it 'should alter the original array' do expect { described_class.extract_options!(ary) }.to change{ ary.count }.from(5).to(4) end it 'should return the hash' do described_class.extract_options!(ary).keys.should include(:opt, :opt2) end it 'should succeed when there are no options to extract' do described_class.extract_options!([1,2,3]).should == {} end it 'should succeed when the array is empty' do described_class.extract_options!([]).should == {} end it 'should fail if the argument is not an array' do expect { described_class.extract_options!(10) }.to raise_error(NoMethodError) end end context '#constantize' do before do Object.send(:remove_const, :User) if defined?(User) class User; end end it 'should raise a NameError when the constant is not valid' do expect { described_class.constantize('user') }.to raise_error(NameError) end it 'should raise a NameError when the constant is undefined' do expect { described_class.constantize("U#{Sham.string!}") }.to raise_error(NameError) end it 'should return the constant' do described_class.constantize('User').should == User end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
sham-2.0.0 | spec/lib/sham/util_spec.rb |
sham-1.2.0 | spec/lib/sham/util_spec.rb |
sham-1.1.0 | spec/lib/sham/util_spec.rb |
sham-1.0.3 | spec/lib/sham/util_spec.rb |