Sha256: 6f76d7a36ae756b724c88012893979648a09d25e388268525a522335c2608439

Contents?: true

Size: 515 Bytes

Versions: 25

Compression:

Stored size: 515 Bytes

Contents

require 'generator/exercise_case'

class CollatzConjectureCase < Generator::ExerciseCase
  using Generator::Underscore

  def workload
    case expected
    when Fixnum
      standard_assertion
    when Hash
      error_assertion
    end
  end

  def standard_assertion
    assert_equal { subject_of_test }
  end

  def error_assertion
    "assert_raises(ArgumentError) { #{subject_of_test} }"
  end

  def subject_of_test
    "CollatzConjecture.steps(#{input})"
  end

  def input
    number.underscore
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
trackler-2.1.0.53 tracks/ruby/exercises/collatz-conjecture/.meta/generator/collatz_conjecture_case.rb
trackler-2.1.0.52 tracks/ruby/exercises/collatz-conjecture/.meta/generator/collatz_conjecture_case.rb
trackler-2.1.0.51 tracks/ruby/exercises/collatz-conjecture/.meta/generator/collatz_conjecture_case.rb
trackler-2.1.0.50 tracks/ruby/exercises/collatz-conjecture/.meta/generator/collatz_conjecture_case.rb
trackler-2.1.0.49 tracks/ruby/exercises/collatz-conjecture/.meta/generator/collatz_conjecture_case.rb