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.2.1.49 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.48 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.47 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.46 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.45 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.44 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.43 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.42 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.41 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.40 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.39 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.38 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.37 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.36 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.35 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.34 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.33 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.32 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.31 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.30 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb