Sha256: 7eb510603b7fc1466ce1f40c8eea02a1b37e68f726d2c6112a77db49d6c36dc8

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

# encoding: utf-8
require 'spec_helper'
require 'generators/rspec/spec_template'
require 'dslable_dsl'

describe Dslable::Generators::RSpec::SpecTemplate do

  context :generate do
    OUTPUT_SPEC_TMP_DIR = 'generate_spec_template'

    cases = [
      {
        case_no: 1,
        case_title: 'valid spec template',
        gem_name: 'sample_gem',
        spec_dir_name: 'spec'
      },
    ]

    cases.each do |c|
      it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
        begin
          case_before c

          # -- given --
          dsl = Dslable::Dsl.new
          dsl.gem_name c[:gem_name]
          spec_template = Dslable::Generators::RSpec::SpecTemplate.new(dsl)

          # -- when --
          spec_template.generate

          # -- then --
          actual = Dir.exists?("./#{c[:spec_dir_name]}")
          expect(actual).to be_true
        ensure
          case_after c

        end
      end

      def case_before(c)
          Dir.mkdir(OUTPUT_SPEC_TMP_DIR) unless Dir.exists? OUTPUT_SPEC_TMP_DIR
          Dir.chdir(OUTPUT_SPEC_TMP_DIR)
        end

        def case_after(c)
          Dir.chdir('../')
          FileUtils.rm_rf(OUTPUT_SPEC_TMP_DIR) if Dir.exists? OUTPUT_SPEC_TMP_DIR
      end
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dslable-0.0.5 spec/generators/rspec/spec_template_spec.rb
dslable-0.0.4 spec/generators/rspec/spec_template_spec.rb
dslable-0.0.3 spec/generators/rspec/spec_template_spec.rb