Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support step definitions without blocks #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion example/scenario.feature
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,15 @@ Feature: Displaying Scenarios

Scenario: Step ending with a match with double-quotes
When searching the log for the exact match of the message "Entering application."
When the step definition has HTML escaped characters like: "<>&"
When the step definition has HTML escaped characters like: "<>&"

Scenario: Steps defined with a common block
This scenario executes several steps that were all created
with a common proc. This is useful when writing a process
that is then aliased for multiple languages. The english
keyword has been used as a constant here as that is a
different feature

When say something
When di algo
When dis quelquechose
24 changes: 23 additions & 1 deletion example/step_definitions/example.step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,26 @@
#
def a_helper_method
puts "performs some operation"
end
end

#
# This is a block used in multiple steps
#
saySomething = Proc.new do |something|
puts something
end

#
# Engligh step say something
#
When /^say ([^$]*)$/, saySomething

#
# Spanish step fo say something
#
When /^di ([^$]*)$/, saySomething

#
# French step fo say something
#
When /^dis ([^$]*)$/, saySomething
6 changes: 3 additions & 3 deletions lib/yard/handlers/step_definition_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ def self.step_definitions
o.source = statement.source
o.comments = statement.comments
o.keyword = statement.method_name.source
o.value = statement.parameters.source
o.pending = pending_keyword_used?(statement.block)
o.value = statement.parameters[0].source
o.pending = pending_keyword_used?(statement.block) unless statement.block.nil?
end

obj = register instance
parse_block(statement[2],:owner => obj)
parse_block(statement[2],:owner => obj) unless statement.block.nil?

end

Expand Down