spec/rake/funnel/support/internal/instantiate_symbol_spec.rb in rake-funnel-0.11.0.pre vs spec/rake/funnel/support/internal/instantiate_symbol_spec.rb in rake-funnel-0.12.0.pre
- old
+ new
@@ -23,19 +23,34 @@
class Nested
end
end
+ module SnakeCase
+ class SnakeCase
+ end
+
+ class Snake_Case
+ end
+ end
+
+ class SnakeCaseModuleDefinition
+ include Rake::Funnel::Support::InstantiateSymbol
+
+ instantiate SnakeCase
+ end
+
describe 'module methods' do
subject {
ExplicitModuleDefinition.new
}
describe 'instance methods' do
it 'should not be public' do
expect(subject).not_to respond_to(:create)
expect(subject).not_to respond_to(:available)
+ expect(subject).not_to respond_to(:mod)
end
end
describe 'class methods' do
it 'should not be public' do
@@ -102,9 +117,23 @@
end
context 'symbol not defined' do
it 'should fail' do
expect { subject.send(:create, :does_not_exist) }.to raise_error 'Unknown type to instantiate: :does_not_exist. Available types are: [:One, :Three, :Two]'
+ end
+ end
+
+ context 'snake cased symbol' do
+ subject {
+ SnakeCaseModuleDefinition.new
+ }
+
+ it 'should return instance' do
+ expect(subject.send(:create, :snake_case)).to be_an_instance_of(SnakeCase::SnakeCase)
+ end
+
+ it 'should prefer explicit type' do
+ expect(subject.send(:create, :Snake_Case)).to be_an_instance_of(SnakeCase::Snake_Case)
end
end
context 'instantiation fails' do
class WillFail