Skip to content

Instantly share code, notes, and snippets.

@laribee
Created December 15, 2011 03:31
Show Gist options
  • Select an option

  • Save laribee/1479705 to your computer and use it in GitHub Desktop.

Select an option

Save laribee/1479705 to your computer and use it in GitHub Desktop.
ugly debugging harness
require 'capybara'
require 'capybara/dsl'
require 'selenium/webdriver'
require_relative './features/support/lib/api'
Capybara.app_host = 'http://localhost/'
@api = API.new('http://localhost/VersionOne.Web')
Capybara.app = class HarnessRackApp; end
Capybara.register_driver :firefox do |app|
Capybara::Selenium::Driver.new(Capybara.app, :browser => :firefox)
end
self.include Capybara::DSL
@steps = {}
def When(matcher, &block)
@steps[matcher] = block
end
def Given(matcher, &block)
@steps[matcher] = block
end
def Then(matcher, &block)
@steps[matcher] = block
end
def match(statement)
code, arguments = nil
match_count = 0
@steps.each do |key, val|
key.match(statement) do |match_data|
puts "Matched step definition: '#{key.to_s}'"
code = val
arguments = match_data.captures
match_count += 1
end
end
raise "Ambiguous step definitions :[" if match_count > 1
code.call(arguments) if code
end
cd ~/path/to/cukes
# add a call to binding.pry in one or
# more step definitions you want to debug
pry -r ./debug.rb -I ./features/step_definitions/
pry> require 'common_steps'
pry> match 'Skip is a Team Lead'
# breaks assuming there's a call to binding.pry
# also very handy: pry_debug gem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment