spec/unit/generators/root_generator_spec.rb in howitzer-1.1.1 vs spec/unit/generators/root_generator_spec.rb in howitzer-2.0.0
- old
+ new
@@ -4,32 +4,69 @@
let(:destination) { Howitzer::BaseGenerator.destination }
let(:output) { StringIO.new }
subject { file_tree_info(destination) }
before do
Howitzer::BaseGenerator.logger = output
- generator_name.new
+ generator_name.new(options)
end
after { FileUtils.rm_r(destination) }
- describe 'RootGenerator' do
- let(:generator_name) { Howitzer::RootGenerator }
+ describe Howitzer::RootGenerator do
+ let(:generator_name) { described_class }
let(:expected_result) do
[
- {:name=> '/Gemfile', :is_directory=>false, :size=>template_file_size('root', 'Gemfile')},
- {:name=> '/Rakefile', :is_directory=>false, :size=>template_file_size('root', 'Rakefile')},
- {:name=> '/boot.rb', :is_directory=>false, :size=>template_file_size('root', 'boot.rb')}
+ { name: '/.gitignore', is_directory: false, size: 196 },
+ { name: '/.rubocop.yml', is_directory: false, size: 584 },
+ { name: '/Gemfile', is_directory: false, size: 605 },
+ { name: '/Rakefile', is_directory: false, size: template_file_size('root', 'Rakefile') }
]
end
+ let(:options) { {} }
it { is_expected.to eql(expected_result) }
describe 'output' do
- let(:expected_output) do
- " * Root files generation ...
+ subject { output.string }
+ context 'when options is empty' do
+ let(:expected_output) do
+ " * Root files generation ...
Added '.gitignore' file
- Added 'Gemfile' file
+ Added '.rubocop.yml' file
Added 'Rakefile' file
- Added 'boot.rb' file\n"
+ Added template 'Gemfile.erb' with params '{}' to destination 'Gemfile'\n"
+ end
+ it { is_expected.to eql(expected_output) }
end
- subject { output.string }
- it { is_expected.to eql(expected_output) }
+ context 'when options is rspec => true' do
+ let(:expected_output) do
+ " * Root files generation ...
+ Added '.gitignore' file
+ Added '.rubocop.yml' file
+ Added 'Rakefile' file
+ Added template 'Gemfile.erb' with params '{:rspec=>true}' to destination 'Gemfile'\n"
+ end
+ let(:options) { { rspec: true } }
+ it { is_expected.to eql(expected_output) }
+ end
+ context 'when options is cucumber => cucumber' do
+ let(:expected_output) do
+ " * Root files generation ...
+ Added '.gitignore' file
+ Added '.rubocop.yml' file
+ Added 'Rakefile' file
+ Added template 'Gemfile.erb' with params '{:cucumber=>true}' to destination 'Gemfile'\n"
+ end
+ let(:options) { { cucumber: true } }
+ it { is_expected.to eql(expected_output) }
+ end
+ context 'when options is turnip => true' do
+ let(:expected_output) do
+ " * Root files generation ...
+ Added '.gitignore' file
+ Added '.rubocop.yml' file
+ Added 'Rakefile' file
+ Added template 'Gemfile.erb' with params '{:turnip=>true}' to destination 'Gemfile'\n"
+ end
+ let(:options) { { turnip: true } }
+ it { is_expected.to eql(expected_output) }
+ end
end
end
-end
\ No newline at end of file
+end