Class: Cucumber::Tree::BaseStep
- Defined in:
- lib/gems/cucumber-0.1.15/lib/cucumber/tree/step.rb
Constant Summary collapse
- PENDING_ADJUSTMENT =
3
- REGULAR_ADJUSTMENT =
2
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
-
#scenario ⇒ Object
readonly
Returns the value of attribute scenario.
Class Method Summary collapse
Instance Method Summary collapse
- #actual_keyword ⇒ Object
- #execute_in(world, regexp, args, proc) ⇒ Object
- #file ⇒ Object
- #forced_to_pending? ⇒ Boolean
- #format_error(strip_pos, proc, e) ⇒ Object
- #id ⇒ Object
- #length ⇒ Object
- #outline? ⇒ Boolean
- #padding_length ⇒ Object
- #previous_step ⇒ Object
- #steps ⇒ Object
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
5 6 7 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/step.rb', line 5 def error @error end |
#scenario ⇒ Object (readonly)
Returns the value of attribute scenario.
4 5 6 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/step.rb', line 4 def scenario @scenario end |
Class Method Details
.new_id! ⇒ Object
7 8 9 10 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/step.rb', line 7 def self.new_id! @next_id ||= -1 @next_id += 1 end |
Instance Method Details
#actual_keyword ⇒ Object
82 83 84 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/step.rb', line 82 def actual_keyword keyword == Cucumber.language['and'] ? previous_step.actual_keyword : keyword end |
#execute_in(world, regexp, args, proc) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/step.rb', line 34 def execute_in(world, regexp, args, proc) strip_pos = nil begin proc.call_in(world, *args) rescue ArityMismatchError => e e.backtrace[0] = proc.to_backtrace_line strip_pos = e.backtrace.index("#{__FILE__}:#{__LINE__ - 3}:in `execute_in'") format_error(strip_pos, proc, e) rescue => e method_line = "#{__FILE__}:#{__LINE__ - 6}:in `execute_in'" # IronRuby returns nil for backtrace... if e.backtrace.nil? def e.backtrace @cucumber_backtrace ||= [] end end method_line_pos = e.backtrace.index(method_line) if method_line_pos strip_pos = method_line_pos - (Pending === e ? PENDING_ADJUSTMENT : REGULAR_ADJUSTMENT) else # This happens with rails, because they screw up the backtrace # before we get here (injecting erb stacktrace and such) end format_error(strip_pos, proc, e) end end |
#file ⇒ Object
14 15 16 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/step.rb', line 14 def file @scenario.file end |
#forced_to_pending? ⇒ Boolean
94 95 96 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/step.rb', line 94 def forced_to_pending? @error.kind_of?(ForcedPending) end |
#format_error(strip_pos, proc, e) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/step.rb', line 63 def format_error(strip_pos, proc, e) @error = e # Remove lines underneath the plain text step e.backtrace[strip_pos..-1] = nil unless strip_pos.nil? e.backtrace.compact! # Replace the step line with something more readable e.backtrace.replace(e.backtrace.map{|l| l.gsub(/`#{proc.meth}'/, "`#{keyword} #{proc.name}'")}) if row? e.backtrace << "#{file}:#{line}:in `#{proc.name}'" else e.backtrace << "#{file}:#{line}:in `#{keyword} #{name}'" end raise e end |
#id ⇒ Object
78 79 80 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/step.rb', line 78 def id @id ||= self.class.new_id! end |
#length ⇒ Object
22 23 24 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/step.rb', line 22 def length keyword.jlength + 1 + name.jlength end |
#outline? ⇒ Boolean
98 99 100 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/step.rb', line 98 def outline? false end |
#padding_length ⇒ Object
90 91 92 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/step.rb', line 90 def padding_length @scenario.step_padding_length(self) end |
#previous_step ⇒ Object
86 87 88 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/step.rb', line 86 def previous_step @scenario.previous_step(self) end |
#steps ⇒ Object
18 19 20 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/tree/step.rb', line 18 def steps self end |