Sha256: 52cbaff56861fdb5d647951250e132c158f63cc8f10a0af19296736ce62178c3

Contents?: true

Size: 544 Bytes

Versions: 233

Compression:

Stored size: 544 Bytes

Contents

require 'generator/exercise_case'

class GrainsCase < Generator::ExerciseCase

  def workload
    send("#{property}_workload")
  end

  private

  def square_workload
    if raises_error?
      "assert_raises(ArgumentError) { Grains.square(#{input}) }"
    else
      "assert_equal #{underscore_format(expected)}, Grains.square(#{input})"
    end
  end

  def total_workload
    "assert_equal #{underscore_format(expected)}, Grains.total"
  end

  def underscore_format(number)
    number.to_s.reverse.gsub(/...(?=.)/, '\&_').reverse
  end
end

Version data entries

233 entries across 233 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.138 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.137 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.136 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.135 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.134 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.133 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.132 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.131 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.130 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.129 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.128 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.127 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.126 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.125 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.124 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.123 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.122 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.121 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.120 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb