Created
December 15, 2011 03:31
-
-
Save laribee/1479705 to your computer and use it in GitHub Desktop.
ugly debugging harness
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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