Sha256: e6b8e77c13d3da88e06b5a79f80b33692834bd7e78cfff6af34c28d3a74ab684

Contents?: true

Size: 735 Bytes

Versions: 54

Compression:

Stored size: 735 Bytes

Contents

require "../exercise_generator"
require "../exercise_test_case"

class AcronymGenerator < ExerciseGenerator
  def exercise_name
    "acronym"
  end

  def test_cases
    JSON.parse(data)["cases"].first["cases"].map do |test_case|
      AcronymTestCase.new(test_case)
    end
  end
end

class AcronymTestCase < ExerciseTestCase
  private getter phrase : JSON::Any
  private getter description : JSON::Any
  private getter expected : JSON::Any

  def initialize(test_case)
    @phrase = test_case["phrase"]
    @description = test_case["description"]
    @expected = test_case["expected"]
  end

  def workload
    "Acronym.abbreviate(\"#{phrase}\").should eq(\"#{expected}\")"
  end

  def test_name
    "does #{description}"
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
trackler-2.2.1.147 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.146 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.145 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.144 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.143 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.142 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.141 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.140 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.139 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.138 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.137 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.136 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.135 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.134 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.133 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.132 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.131 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.130 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.129 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.128 tracks/crystal/generator/src/generators/acronym.cr