Sha256: ed899dfc517929557276d29098d891e6b1acc5b54265e6e4f401ee0fab319d0e
Contents?: true
Size: 1.09 KB
Versions: 11
Compression:
Stored size: 1.09 KB
Contents
require 'spec_helper' describe Virtus::Coercion::String, '.to_constant' do subject { object.to_constant(string) } let(:object) { described_class } context 'with a non-namespaced name' do let(:string) { 'String' } it { should be(String) } end context 'with a non-namespaced qualified name' do let(:string) { '::String' } it { should be(String) } end context 'with a namespaced name' do let(:string) { 'Virtus::Coercion::String' } it { should be(Virtus::Coercion::String) } end context 'with a namespaced qualified name' do let(:string) { '::Virtus::Coercion::String' } it { should be(Virtus::Coercion::String) } end context 'with a name outside of the namespace' do let(:string) { 'Virtus::Object' } specify { expect { subject }.to raise_error(NameError) } end context 'when the name is unknown' do let(:string) { 'Unknown' } specify { expect { subject }.to raise_error(NameError) } end context 'when the name is invalid' do let(:string) { 'invalid' } specify { expect { subject }.to raise_error(NameError) } end end
Version data entries
11 entries across 11 versions & 2 rubygems