Class: Shoulda::Setup
- Inherits:
-
Object
- Object
- Shoulda::Setup
- Defined in:
- lib/shoulda/context.rb
Instance Method Summary collapse
-
#initialize(can_run_count, &blk) ⇒ Setup
constructor
A new instance of Setup.
- #run(binding) ⇒ Object
Constructor Details
#initialize(can_run_count, &blk) ⇒ Setup
Returns a new instance of Setup.
290 291 292 293 294 295 |
# File 'lib/shoulda/context.rb', line 290 def initialize(can_run_count,&blk) @ran_already = false @can_run_count = (can_run_count == :once ? 1 : 10) @blk = blk @ivars = {} end |
Instance Method Details
#run(binding) ⇒ Object
297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/shoulda/context.rb', line 297 def run(binding) if can_ran? before_ivars = binding.instance_variables @blk.bind(binding).call after_ivars = binding.instance_variables capture_ivars(before_ivars,after_ivars,binding) if @can_run_count == 1 @ran_already = true else copy_ivars(binding) end end |