Sha256: fbafe0ef869715e45fffa51719b49159f6928489d08bd0af34a3ec2f30918b0b

Contents?: true

Size: 811 Bytes

Versions: 90

Compression:

Stored size: 811 Bytes

Contents

require 'exercise_cases'

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

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

  def test_body
    long_input? ? split_test : simple_test
  end

  def long_input?
    input.length > 80
  end

  def simple_test
    "#{assert_or_refute} Brackets.paired?('#{input}')"
  end

  def split_test
    "str = '#{split_input[0]}'\\
          '#{split_input[1]}'
    #{assert_or_refute} Brackets.paired?(str)"
  end

  def assert_or_refute
    expected ? 'assert' : 'refute'
  end

  def split_input
    @split_input ||= input.scan(/.{1,#{input.length / 2}}/)
  end
end

BracketPushCases = proc do |data|
  JSON.parse(data)['cases'].map.with_index do |row, i|
    BracketPushCase.new(row.merge('index' => i))
  end
end

Version data entries

90 entries across 90 versions & 1 rubygems

Version Path
trackler-2.0.6.41 tracks/ruby/lib/bracket_push_cases.rb
trackler-2.0.6.40 tracks/ruby/lib/bracket_push_cases.rb
trackler-2.0.6.39 tracks/ruby/lib/bracket_push_cases.rb
trackler-2.0.6.38 tracks/ruby/lib/bracket_push_cases.rb
trackler-2.0.6.37 tracks/ruby/lib/bracket_push_cases.rb
trackler-2.0.6.36 tracks/ruby/lib/bracket_push_cases.rb
trackler-2.0.6.35 tracks/ruby/lib/bracket_push_cases.rb
trackler-2.0.6.34 tracks/ruby/lib/bracket_push_cases.rb
trackler-2.0.6.33 tracks/ruby/lib/bracket_push_cases.rb
trackler-2.0.6.32 tracks/ruby/lib/bracket_push_cases.rb
trackler-2.0.6.31 tracks/ruby/lib/bracket_push_cases.rb
trackler-2.0.6.30 tracks/ruby/lib/bracket_push_cases.rb
trackler-2.0.6.29 tracks/ruby/lib/bracket_push_cases.rb
trackler-2.0.6.28 tracks/ruby/lib/bracket_push_cases.rb
trackler-2.0.6.27 tracks/ruby/lib/bracket_push_cases.rb
trackler-2.0.6.26 tracks/ruby/lib/bracket_push_cases.rb
trackler-2.0.6.25 tracks/ruby/lib/bracket_push_cases.rb
trackler-2.0.6.24 tracks/ruby/lib/bracket_push_cases.rb
trackler-2.0.6.23 tracks/ruby/lib/bracket_push_cases.rb
trackler-2.0.6.22 tracks/ruby/lib/bracket_push_cases.rb