cucumber-attic / cucumber-ruby-tcl

Tcl bindings for Cucumber
MIT License
9 stars 6 forks source link

Step locations #15

Open mattwynne opened 9 years ago

mattwynne commented 9 years ago

When Cucumber prints the scenario, it ideally needs a location for each step so it can print them to the user.

Example (imagined):

Scenario:
    Given the range is 1000m                       # features/step_definition/steps.tcl:2
    And Samantha is 1000m from Bob                 # features/step_definition/steps.tcl:5
      TODO (Tcl::Error)
      features/hear_shout.feature:8:in `And Samantha is 1000m from Bob'
    When Bob sends a message "hello"               # features/step_definition/steps.tcl:10
    Then Samantha should hear "hello"              # features/step_definition/steps.tcl:15
d-led commented 8 years ago

see my comment in #25. In ::cucumber::_add_step:

  # an attempt at saving the source of the step definition
  # 3 in [info frame..] is a magic number that only works in this constellation of [source]s
  # haven't come up with a more robust way yet
  set location "[file tail [uplevel 3 {info script}]]:[dict get [info frame 3] line]"

  lappend STEPS [list $re $params $body $location]
d-led commented 8 years ago

this works now in cucumber-tcl-wire and could be probably directly transfered into this repo. The magic numbers are now somewhat less magic and are robust against framelevel differences when sourcing the steps.

BTW, what is the workflow for developing this lib? rake → code → rake?

mattwynne commented 8 years ago

Thanks @d-led! Yes, rake will run all the tests for both the Ruby and tcl parts of the codebase.