Class: Cucumber::Core::Test::Result::Failed

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/core/test/result.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(duration, exception) ⇒ Failed

Returns a new instance of Failed.

Raises:

  • (ArgumentError)


109
110
111
112
113
114
115
# File 'lib/cucumber/core/test/result.rb', line 109

def initialize(duration, exception)
  raise ArgumentError unless duration
  raise ArgumentError unless exception

  @duration = duration
  @exception = exception
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.



103
104
105
# File 'lib/cucumber/core/test/result.rb', line 103

def duration
  @duration
end

#exceptionObject (readonly)

Returns the value of attribute exception.



103
104
105
# File 'lib/cucumber/core/test/result.rb', line 103

def exception
  @exception
end

Class Method Details

.ok?Boolean

Returns:

  • (Boolean)


105
106
107
# File 'lib/cucumber/core/test/result.rb', line 105

def self.ok?(*)
  false
end

Instance Method Details

#describe_to(visitor, *args) ⇒ Object



117
118
119
120
121
122
# File 'lib/cucumber/core/test/result.rb', line 117

def describe_to(visitor, *args)
  visitor.failed(*args)
  visitor.duration(duration, *args)
  visitor.exception(exception, *args) if exception
  self
end

#ok?Boolean

Returns:

  • (Boolean)


142
143
144
# File 'lib/cucumber/core/test/result.rb', line 142

def ok?(*)
  self.class.ok?
end

#to_messageObject



128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/cucumber/core/test/result.rb', line 128

def to_message
  begin
    message = exception.backtrace.join("\n")
  rescue NoMethodError
    message = ''
  end

  Cucumber::Messages::TestStepResult.new(
    status: Cucumber::Messages::TestStepResultStatus::FAILED,
    duration: duration.to_message_duration,
    message: message
  )
end

#to_sObject



124
125
126
# File 'lib/cucumber/core/test/result.rb', line 124

def to_s
  ''
end

#with_appended_backtrace(step) ⇒ Object



150
151
152
153
# File 'lib/cucumber/core/test/result.rb', line 150

def with_appended_backtrace(step)
  exception.backtrace << step.backtrace_line if step.respond_to?(:backtrace_line)
  self
end

#with_duration(new_duration) ⇒ Object



146
147
148
# File 'lib/cucumber/core/test/result.rb', line 146

def with_duration(new_duration)
  self.class.new(new_duration, exception)
end

#with_filtered_backtrace(filter) ⇒ Object



155
156
157
# File 'lib/cucumber/core/test/result.rb', line 155

def with_filtered_backtrace(filter)
  self.class.new(duration, filter.new(exception.dup).exception)
end