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.29 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.28 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.27 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.26 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.25 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.24 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.23 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.22 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.21 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.20 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.19 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.18 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.17 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.16 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.15 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.14 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.13 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.12 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.11 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb
trackler-2.2.1.10 tracks/ruby/exercises/queen-attack/.meta/generator/queen_attack_case.rb