Sha256: 9f660923e3ae9b16711b36685136a52676b86879c2d0a23cb27b2cf263262c13

Contents?: true

Size: 917 Bytes

Versions: 2

Compression:

Stored size: 917 Bytes

Contents

require 'lotus/lotusrc'
module Lotus
  module Generators
    class TestFramework
      RSPEC = 'rspec'.freeze
      MINITEST = 'minitest'.freeze
      VALID_FRAMEWORKS = [RSPEC, MINITEST].freeze

      attr_reader :framework

      def initialize(lotusrc, framework)
        @framework = (framework || lotusrc.options.fetch(:test))
        assert_framework!
      end

      def rspec?
        framework == RSPEC
      end

      def minitest?
        framework == MINITEST
      end

      private

      def assert_framework!
        if !supported_framework?
          raise ArgumentError.new("Unknown test framework '#{ framework}'. Please use one of #{ valid_test_frameworks.join(', ')}")
        end
      end

      def valid_test_frameworks
        VALID_FRAMEWORKS.map { |name| "'#{ name }'"}
      end

      def supported_framework?
        VALID_FRAMEWORKS.include?(framework)
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lotusrb-0.6.1 lib/lotus/generators/test_framework.rb
lotusrb-0.6.0 lib/lotus/generators/test_framework.rb