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.1.0.1 tracks/ruby/lib/connect_cases.rb
trackler-2.1.0.0 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.55 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.54 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.53 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.52 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.51 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.50 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.49 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.48 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.47 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.46 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.45 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.44 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.43 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.42 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.41 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.40 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.39 tracks/ruby/lib/connect_cases.rb
trackler-2.0.8.38 tracks/ruby/lib/connect_cases.rb