Module: RPicSim::RSpec::Helpers
- Includes:
- PersistentExpectations
- Defined in:
- lib/rpicsim/rspec/helpers.rb
Overview
This module gets included into your RSpec examples if you use the following line in your spec_helper.rb:
require 'rpicsim/rspec'
It provides the #start_sim method and includes all the methods from PersistentExpectations.
For more information, see RSpecIntegration.
Instance Attribute Summary collapse
-
#sim ⇒ Object
readonly
This attribute allows you to type
sim
in your specs instead of @sim to get access to the Sim instance which represents the simulation.
Instance Method Summary collapse
-
#start_sim(klass, *args) ⇒ Object
Starts a new simulation with the specified class, makes it accessible via the attribute #sim, and adds convenient shortcut methods that can be used in the RSpec example.
Methods included from PersistentExpectations
#check_expectations, #expectations, #expecting
Instance Attribute Details
#sim ⇒ Object (readonly)
This attribute allows you to type sim
in your specs instead of
@sim to get access to the Sim instance which represents the
simulation. You must call #start_sim before using sim
.
22 23 24 |
# File 'lib/rpicsim/rspec/helpers.rb', line 22 def sim @sim end |
Instance Method Details
#start_sim(klass, *args) ⇒ Object
Starts a new simulation with the specified class, makes it accessible via the attribute #sim, and adds convenient shortcut methods that can be used in the RSpec example.
31 32 33 34 35 |
# File 'lib/rpicsim/rspec/helpers.rb', line 31 def start_sim(klass, *args) @sim = klass.new(*args) add_shortcuts sim.every_step { check_expectations } end |