Sha256: b00b5aeec9611b2911422659a21f47f8e48b4841f5d43b8a6385e8b1bbaf54f9

Contents?: true

Size: 691 Bytes

Versions: 104

Compression:

Stored size: 691 Bytes

Contents

require 'generator/exercise_case'

class QueenAttackCase < Generator::ExerciseCase

  def workload
    property == 'create' ? create_workload : attack_workload
  end

  private

  def attack_workload
    """queens = Queens.new(white: #{parse_position white_queen}, black: #{parse_position black_queen})
    #{assert} queens.attack?"""
  end

  def parse_position queen
    queen['position'].delete('() ').split(',').map{|i| i.to_i}
  end

  def create_workload
    raises_error? ? exception : "#{assert} #{test_case}"
  end

  def test_case
    "Queens.new(white: #{parse_position queen})"
  end

  def exception
    """assert_raises ArgumentError do
      #{test_case}
    end"""
  end
end

Version data entries

104 entries across 104 versions & 1 rubygems

Version Path
trackler-2.1.0.52 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.1.0.51 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.1.0.50 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.1.0.49 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.1.0.48 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.1.0.47 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.1.0.46 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.1.0.45 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.1.0.44 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.1.0.43 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.1.0.42 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.1.0.41 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.1.0.40 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.1.0.39 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.1.0.38 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.1.0.37 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.1.0.36 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.1.0.34 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.1.0.33 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.1.0.32 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb