Sha256: 72eb1c6f9c765fdb2257b117446b22a9240856279e8fa8dd10e41a7987779e7b

Contents?: true

Size: 744 Bytes

Versions: 32

Compression:

Stored size: 744 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["input"]["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

32 entries across 32 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.179 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.178 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.177 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.176 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.175 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.174 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.173 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.172 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.171 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.170 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.169 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.167 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.166 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.165 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.164 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.163 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.162 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.161 tracks/crystal/generator/src/generators/acronym.cr
trackler-2.2.1.160 tracks/crystal/generator/src/generators/acronym.cr