Class: Specifier::Example

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

Overview

Configures an example (used for it statements).

Usage:

example = Specifier::Example.new("...") do
  expect(value).to equal(value)
end

world = Specifier::World.new
example.run(world)

Defined Under Namespace

Classes: Result

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description, &block) ⇒ Example

Returns a new instance of Example.



19
20
21
22
# File 'lib/specifier/example.rb', line 19

def initialize(description, &block)
  @description = description
  @block = block
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



17
18
19
# File 'lib/specifier/example.rb', line 17

def description
  @description
end

Instance Method Details

#run(world) ⇒ Object



24
25
26
27
28
29
# File 'lib/specifier/example.rb', line 24

def run(world)
  world.instance_eval(&@block)
  Result.new(:pass)
rescue StandardError => message
  Result.new(:fail, message)
end