spec/rake/funnel/support/internal/instantiate_symbol_spec.rb in rake-funnel-0.18.0 vs spec/rake/funnel/support/internal/instantiate_symbol_spec.rb in rake-funnel-0.19.0
- old
+ new
@@ -1,5 +1,7 @@
+# rubocop:disable RSpec/FilePath
+
describe Rake::Funnel::Support::InstantiateSymbol do
module Creatable
class One
end
@@ -27,24 +29,24 @@
module SnakeCase
class SnakeCase
end
- class Snake_Case
+ class Snake_Case # rubocop:disable Style/ClassAndModuleCamelCase
end
end
class SnakeCaseModuleDefinition
include Rake::Funnel::Support::InstantiateSymbol
instantiate SnakeCase
end
describe 'module methods' do
- subject {
+ subject do
ExplicitModuleDefinition.new
- }
+ end
describe 'instance methods' do
it 'should not be public' do
expect(subject).not_to respond_to(:create)
expect(subject).not_to respond_to(:available)
@@ -59,36 +61,36 @@
end
end
describe 'inspection' do
context 'implicit module' do
- subject {
+ subject do
ImplicitModuleDefinition.new
- }
+ end
it 'should yield constants in self' do
- expect(subject.send(:available)).to eq([:ClassMethods, :Nested])
+ expect(subject.send(:available)).to eq(%i(ClassMethods Nested))
end
end
context 'explicit module' do
- subject {
+ subject do
ExplicitModuleDefinition.new
- }
+ end
it 'should yield sorted constants in module' do
- expect(subject.send(:available)).to eq([:One, :Three, :Two])
+ expect(subject.send(:available)).to eq(%i(One Three Two))
end
end
context 'multiple uses' do
- subject {
+ subject do
[
ExplicitModuleDefinition.new,
ImplicitModuleDefinition.new
]
- }
+ end
it 'should not overlap' do
first = subject[0].send(:available)
second = subject[1].send(:available)
@@ -96,13 +98,13 @@
end
end
end
describe 'instantiation' do
- subject {
+ subject do
ExplicitModuleDefinition.new
- }
+ end
context 'with instance' do
it 'should return instance' do
instance = Object.new
@@ -116,18 +118,19 @@
end
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]'
+ 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 {
+ subject do
SnakeCaseModuleDefinition.new
- }
+ end
it 'should return instance' do
expect(subject.send(:create, :snake_case)).to be_an_instance_of(SnakeCase::SnakeCase)
end
@@ -140,18 +143,18 @@
class WillFail
include Rake::Funnel::Support::InstantiateSymbol
class Failure
def initialize
- fail 'BAM!'
+ raise 'BAM!'
end
end
end
- subject {
+ subject do
WillFail.new
- }
+ end
it 'should fail' do
expect { subject.send(:create, :Failure) }.to raise_error 'BAM!'
end
end
@@ -163,32 +166,29 @@
end
describe 'args' do
module CreatableWithArgs
class None
- def initialize
- end
+ def initialize; end
end
class Single
- def initialize(_arg)
- end
+ def initialize(_arg); end
end
class Multiple
- def initialize(_arg1, _arg2)
- end
+ def initialize(_arg1, _arg2); end
end
end
class WithArgs
include Rake::Funnel::Support::InstantiateSymbol
instantiate CreatableWithArgs
end
- subject {
+ subject do
WithArgs.new
- }
+ end
context 'no argument' do
it 'should not pass arg' do
expect(subject.send(:create, :None)).to be_an_instance_of(CreatableWithArgs::None)
end