Sha256: 3b181294786a988656887350bd66d8ca30b05d9c809e566978df18356286233f

Contents?: true

Size: 831 Bytes

Versions: 94

Compression:

Stored size: 831 Bytes

Contents

require 'ostruct'

module Generator
  class ExerciseCase
    using Generator::Underscore
    include CaseHelpers
    include Assertion

    attr_reader :canonical
    def initialize(canonical:)
      @canonical = canonical
    end

    def name
      'test_%s' % canonical.description.strip.underscore
    end

    def skipped(index)
      index.zero? ? '# skip' : 'skip'
    end

    def method_missing(sym, *args, &block)
      return canonical.send(sym) if canonical.respond_to?(sym)
      super(sym, *args, &block)
    end

    def respond_to?(sym, include_private = false)
      canonical.respond_to?(sym) || super
    end

    protected

    def literal(number)
      number.underscore
    end

    def underscore(string)
      string.underscore
    end

    def camel_case(string)
      string.camel_case
    end

  end
end

Version data entries

94 entries across 94 versions & 1 rubygems

Version Path
trackler-2.2.1.137 tracks/ruby/lib/generator/exercise_case.rb
trackler-2.2.1.136 tracks/ruby/lib/generator/exercise_case.rb
trackler-2.2.1.135 tracks/ruby/lib/generator/exercise_case.rb
trackler-2.2.1.134 tracks/ruby/lib/generator/exercise_case.rb
trackler-2.2.1.133 tracks/ruby/lib/generator/exercise_case.rb
trackler-2.2.1.132 tracks/ruby/lib/generator/exercise_case.rb
trackler-2.2.1.131 tracks/ruby/lib/generator/exercise_case.rb
trackler-2.2.1.130 tracks/ruby/lib/generator/exercise_case.rb
trackler-2.2.1.129 tracks/ruby/lib/generator/exercise_case.rb
trackler-2.2.1.128 tracks/ruby/lib/generator/exercise_case.rb
trackler-2.2.1.127 tracks/ruby/lib/generator/exercise_case.rb
trackler-2.2.1.126 tracks/ruby/lib/generator/exercise_case.rb
trackler-2.2.1.125 tracks/ruby/lib/generator/exercise_case.rb
trackler-2.2.1.124 tracks/ruby/lib/generator/exercise_case.rb
trackler-2.2.1.123 tracks/ruby/lib/generator/exercise_case.rb
trackler-2.2.1.122 tracks/ruby/lib/generator/exercise_case.rb
trackler-2.2.1.121 tracks/ruby/lib/generator/exercise_case.rb
trackler-2.2.1.120 tracks/ruby/lib/generator/exercise_case.rb
trackler-2.2.1.119 tracks/ruby/lib/generator/exercise_case.rb
trackler-2.2.1.118 tracks/ruby/lib/generator/exercise_case.rb