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.180 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.179 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.178 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.177 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.176 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.175 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.174 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.173 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.172 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.171 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.170 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.169 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.167 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.166 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.165 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.164 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.163 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.162 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.161 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb
trackler-2.2.1.160 tracks/ruby/exercises/grains/.meta/generator/grains_case.rb