Sha256: ee28ddfb24b13ba9d6be66287988f3aa26ff3a6807a616569f5138812514f60b

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

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

describe Dslable::Generators::RSpec::Specs do

  context :generate do
    OUTPUT_SPECS_TMP_DIR = 'generate_specs_template'

    cases = [
      {
        case_no: 1,
        case_title: 'valid specs template',
        gem_name: 'sample_gem',
        specs: ['spec/sample_gem_core_spec.rb']
      },
    ]

    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]
          specs = Dslable::Generators::RSpec::Specs.new(dsl)

          # -- when --
          specs.generate

          # -- then --
          c[:specs].each do |spec|
            actual = File.exists?("./#{spec}")
            expect(actual).to be_true
          end
        ensure
          case_after c

        end
      end

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

        def case_after(c)
          Dir.chdir('../')
          FileUtils.rm_rf(OUTPUT_SPECS_TMP_DIR) if Dir.exists? OUTPUT_SPECS_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/specs_spec.rb
dslable-0.0.4 spec/generators/rspec/specs_spec.rb
dslable-0.0.3 spec/generators/rspec/specs_spec.rb