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.3.1 tracks/ruby/lib/connect_cases.rb
trackler-2.0.3.0 tracks/ruby/lib/connect_cases.rb
trackler-2.0.2.0 tracks/ruby/lib/connect_cases.rb
trackler-2.0.1.2 tracks/ruby/lib/connect_cases.rb
trackler-2.0.1.1 tracks/ruby/lib/connect_cases.rb
trackler-2.0.1.0 tracks/ruby/lib/connect_cases.rb
trackler-2.0.0.10 tracks/ruby/lib/connect_cases.rb
trackler-2.0.0.9 tracks/ruby/lib/connect_cases.rb
trackler-2.0.0.8 tracks/ruby/lib/connect_cases.rb
trackler-2.0.0.7 tracks/ruby/lib/connect_cases.rb
trackler-2.0.0.6 tracks/ruby/lib/connect_cases.rb
trackler-2.0.0.5 tracks/ruby/lib/connect_cases.rb
trackler-2.0.0.4 tracks/ruby/lib/connect_cases.rb
trackler-2.0.0.3 tracks/ruby/lib/connect_cases.rb
trackler-2.0.0.2 tracks/ruby/lib/connect_cases.rb
trackler-2.0.0.1 tracks/ruby/lib/connect_cases.rb
trackler-2.0.0.0 tracks/ruby/lib/connect_cases.rb
trackler-1.0.4.1 tracks/ruby/lib/connect_cases.rb
trackler-1.0.4.0 tracks/ruby/lib/connect_cases.rb
trackler-1.0.3.0 tracks/ruby/lib/connect_cases.rb