Sha256: 203a8d21ad77885cb90bf14aa59421e9c04327070a0802bd8ed7ee86c9780140

Contents?: true

Size: 838 Bytes

Versions: 67

Compression:

Stored size: 838 Bytes

Contents

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

67 entries across 67 versions & 1 rubygems

Version Path
trackler-2.0.6.11 tracks/ruby/lib/connect_cases.rb
trackler-2.0.6.10 tracks/ruby/lib/connect_cases.rb
trackler-2.0.6.9 tracks/ruby/lib/connect_cases.rb
trackler-2.0.6.8 tracks/ruby/lib/connect_cases.rb
trackler-2.0.6.7 tracks/ruby/lib/connect_cases.rb
trackler-2.0.6.6 tracks/ruby/lib/connect_cases.rb
trackler-2.0.6.5 tracks/ruby/lib/connect_cases.rb
trackler-2.0.6.4 tracks/ruby/lib/connect_cases.rb
trackler-2.0.6.3 tracks/ruby/lib/connect_cases.rb
trackler-2.0.6.2 tracks/ruby/lib/connect_cases.rb
trackler-2.0.6.1 tracks/ruby/lib/connect_cases.rb
trackler-2.0.6.0 tracks/ruby/lib/connect_cases.rb
trackler-2.0.5.18 tracks/ruby/lib/connect_cases.rb
trackler-2.0.5.17 tracks/ruby/lib/connect_cases.rb
trackler-2.0.5.16 tracks/ruby/lib/connect_cases.rb
trackler-2.0.5.15 tracks/ruby/lib/connect_cases.rb
trackler-2.0.5.14 tracks/ruby/lib/connect_cases.rb
trackler-2.0.5.13 tracks/ruby/lib/connect_cases.rb
trackler-2.0.5.12 tracks/ruby/lib/connect_cases.rb
trackler-2.0.5.11 tracks/ruby/lib/connect_cases.rb