Sha256: c9c17254a6fa0f845ad3213a47c697a5ceaa7d26d66996baff1c8da0ddd3921e

Contents?: true

Size: 864 Bytes

Versions: 90

Compression:

Stored size: 864 Bytes

Contents

require 'exercise_cases'

class ConnectCase < OpenStruct
  def name
    'test_%s' % description
                .gsub(/[() -]/, '_')
                .chomp('_')
                .downcase
  end

  def test_body
    [
      'board = [',
      '  ' + board.map(&method(:single_quote)).join(",\n      "),
      ']',
      'game = Board.new(board)',
      "assert_equal #{single_quote(expected)}, game.winner, " +
        single_quote(description)
    ]
  end

  def skipped
    index.zero? ? '# skip' : 'skip'
  end

  def single_quote(string)
    string.inspect.tr('"', "'")
  end

  def ignore_method_length
    "# rubocop:disable MethodLength\n  " if board.length > 8
  end
end

ConnectCases = proc do |data|
  json = JSON.parse(data)
  cases = []
  json['cases'].each_with_index do |row, i|
    row['index'] = i
    cases << ConnectCase.new(row)
  end
  cases
end

Version data entries

90 entries across 90 versions & 1 rubygems

Version Path
trackler-2.0.8.37 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.36 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.35 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.34 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.33 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.32 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.31 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.30 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.29 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.28 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.27 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.26 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.24 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.23 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.22 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.21 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.20 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.19 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.18 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.17 tracks/ruby/lib/connect_cases.rb