Class: Cucumber::StepMatch

Inherits:
Object
  • Object
show all
Defined in:
lib/neverfails.rb

Instance Method Summary collapse

Instance Method Details

#invoke_with_neverfails(multiline_arg) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/neverfails.rb', line 5

def invoke_with_neverfails(multiline_arg)
  begin
    invoke_without_neverfails(multiline_arg)
  rescue Exception => e # NOTE: Test::Unit::AssertionFailedError
    match1 = /No model found called (.+?)\.$/.match(e.message)
    match2 = /No URL pattern found matching \/(.+?)\.$/.match(e.message)
    match3 = /The text "(.+?)" was not found in the current page$/.match(e.message)
    if match1
      create_missing_model match1[1]
    elsif match2
      create_missing_page_listing match2[1]
    elsif match3
      create_missing_text match3[1]
    else
      raise
    end
    return invoke_without_neverfails(multiline_arg) # Try again
  end
end