Skip to content

Instantly share code, notes, and snippets.

@joeljackson
Created October 16, 2014 22:05
Show Gist options
  • Save joeljackson/cc4e88b224387792c695 to your computer and use it in GitHub Desktop.
Save joeljackson/cc4e88b224387792c695 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
class FailFinder
def initialize(specs)
@test_specs = specs[0...-1]
@result_spec = specs.last
end
def stupid_spec
binary_search(@test_specs)
end
private
def specs_fail(specs)
result = `rspec #{specs.join(' ')} #{@result_spec}`
p "#{result}\n"
result.match(/Failure/)
end
def binary_search(array)
p "#{array}\n"
if array.length == 1
return array[0]
end
mid = array.length / 2
if specs_fail(array[0...mid])
binary_search(array[0...mid])
else
binary_search(array[mid...array.length])
end
end
end
p "The failure is: #{FailFinder.new(ARGV).stupid_spec}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment