Sha256: 85a8e37e2bdcea6bc261ac573f3d5c32018e6098e099ee085d5ac1afee1df380

Contents?: true

Size: 1.91 KB

Versions: 3

Compression:

Stored size: 1.91 KB

Contents

require 'spec_helper'

RSpec.describe 'Generators' do
  let(:destination) { Howitzer::BaseGenerator.destination }
  let(:output) { StringIO.new }
  subject { file_tree_info(destination) }
  before do
    Howitzer::BaseGenerator.logger = output
    generator_name.new({})
  end
  after { FileUtils.rm_r(destination) }

  describe Howitzer::PrerequisitesGenerator do
    let(:generator_name) { described_class }
    let(:expected_result) do
      [
        { name: '/prerequisites', is_directory: true },
        { name: '/prerequisites/factories', is_directory: true },
        {
          name: '/prerequisites/factories/users.rb',
          is_directory: false, size: template_file_size('prerequisites', 'users.rb')
        },
        {
          name: '/prerequisites/factory_bot.rb',
          is_directory: false, size: template_file_size('prerequisites', 'factory_bot.rb')
        },
        { name: '/prerequisites/models', is_directory: true },
        {
          name: '/prerequisites/models/base.rb',
          is_directory: false,
          size: template_file_size('prerequisites', 'base.rb')
        },
        {
          name: '/prerequisites/models/user.rb',
          is_directory: false,
          size: template_file_size('prerequisites', 'user.rb')
        }
      ]
    end
    it { is_expected.to eql(expected_result) }
    describe 'output' do
      let(:expected_output) do
        "#{ColorizedString.new('  * Pre-requisites integration to the framework ...').light_cyan}
      #{ColorizedString.new('Added').light_green} 'prerequisites/factory_bot.rb' file
      #{ColorizedString.new('Added').light_green} 'prerequisites/factories/users.rb' file
      #{ColorizedString.new('Added').light_green} 'prerequisites/models/base.rb' file
      #{ColorizedString.new('Added').light_green} 'prerequisites/models/user.rb' file\n"
      end
      subject { output.string }
      it { is_expected.to eql(expected_output) }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
howitzer-2.2.0 spec/unit/generators/prerequisites_generator_spec.rb
howitzer-2.1.1 spec/unit/generators/prerequisites_generator_spec.rb
howitzer-2.1.0 spec/unit/generators/prerequisites_generator_spec.rb