Class: Sus::Assertions::Assert

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

Overview

Represents a single assertion result.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identity, backtrace, assertions) ⇒ Assert

Initialize a new assertion result.



197
198
199
200
201
# File 'lib/sus/assertions.rb', line 197

def initialize(identity, backtrace, assertions)
	@identity = identity
	@backtrace = backtrace
	@assertions = assertions
end

Instance Attribute Details

#assertionsObject (readonly)

Returns the value of attribute assertions.



210
211
212
# File 'lib/sus/assertions.rb', line 210

def assertions
  @assertions
end

#backtraceObject (readonly)

Returns the value of attribute backtrace.



207
208
209
# File 'lib/sus/assertions.rb', line 207

def backtrace
  @backtrace
end

#identityObject (readonly)

Returns the value of attribute identity.



204
205
206
# File 'lib/sus/assertions.rb', line 204

def identity
  @identity
end

#The assertions instance that contains this assertion.(assertionsinstancethatcontainsthisassertion.) ⇒ Object (readonly)



210
# File 'lib/sus/assertions.rb', line 210

attr :assertions

#The backtrace where the assertion was made.(backtracewheretheassertionwasmade.) ⇒ Object (readonly)



207
# File 'lib/sus/assertions.rb', line 207

attr :backtrace

Instance Method Details

#each_failure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



213
214
215
# File 'lib/sus/assertions.rb', line 213

def each_failure(&block)
	yield self
end

#messageObject



218
219
220
221
222
223
224
# File 'lib/sus/assertions.rb', line 218

def message
	{
		# It's possible that several Assert instances might share the same output text. This is because the output is buffered for each test and each top-level test expectation.
		text: @assertions.output.string,
		location: @identity&.to_location
	}
end

#The identity of the assertion.=(identityoftheassertion. = (value)) ⇒ Object



204
# File 'lib/sus/assertions.rb', line 204

attr :identity