Sha256: bcd364dcbcaece8524456ae5990bc99bb99b8313b33986dfe3ddffbccb54f225

Contents?: true

Size: 771 Bytes

Versions: 2

Compression:

Stored size: 771 Bytes

Contents

require "tset/translators/rspec"
require "tset/translators/minitest"
require "active_support/inflector"

module Tset
  #
  # Snippet of code that can be converted to a test by Writers
  #
  # @param type [String] The part of application from which the code originate (e.g. controller, model)
  # @param code [String] The testable code itself
  #
  class Testable

    TRANSLATOR_NAMESPACE = "Tset::Translators::%s"

    attr_reader :type, :code

    def initialize(type, code)
      @type = type
      @code = code
    end

    def to_test(framework = 'rspec')
      translator(framework).start
    end

    private

    def translator(framework)
      class_name = framework.classify
      Object.const_get(TRANSLATOR_NAMESPACE % class_name).new(self)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tset-0.0.2 lib/tset/testable.rb
tset-0.0.1 lib/tset/testable.rb