require 'generator/exercise_cases'

class RunLengthEncodingCase < Generator::ExerciseCase

  def workload
    indent_lines([
      "input = '#{input}'",
      "output = '#{expected}'",
      assertion
    ], 4)
  end

  private

  def assertion
    if property == 'consistency'
      'assert_equal output,
                 RunLengthEncoding.decode(RunLengthEncoding.encode(input))'
    else
      "assert_equal output, RunLengthEncoding.#{property}(input)"
    end
  end

end

require 'generator/exercise_cases'

class RunLengthEncodingCase < Generator::ExerciseCase

  def name
    super.sub('test_',"test_#{property}_")
  end

  def workload
    indent_lines([
      "input = '#{input}'",
      "output = '#{expected}'",
      assertion
    ], 4)
  end

  private

  def assertion
    if property == 'consistency'
      'assert_equal output,
                 RunLengthEncoding.decode(RunLengthEncoding.encode(input))'
    else
      "assert_equal output, RunLengthEncoding.#{property}(input)"
    end
  end

end

Add method name to test name.
Add method name to test name.

Adds encode_ or decode_ as a prefix to all tests depending on the method
being tested.

This fixes a name collision bug between:
def test_empty_string for encode
and
def test_empty_string for decode
