class RSpec::Sequencing
Attributes
flows[R]
Public Class Methods
new()
click to toggle source
# File lib/rspec/sequencing.rb, line 17 def initialize @flows = [] end
run(description = '', &block)
click to toggle source
# File lib/rspec/sequencing.rb, line 7 def self.run(description = '', &block) run_after(0, description, &block) end
run_after(delay, description = '', &block)
click to toggle source
# File lib/rspec/sequencing.rb, line 11 def self.run_after(delay, description = '', &block) new.then_after(delay, description, &block) end
Public Instance Methods
activate()
click to toggle source
# File lib/rspec/sequencing.rb, line 38 def activate # use this method if you define the sequencing in a let block so RSpec instantiates it formatted_puts "sequence activated" end
activate_quietly()
click to toggle source
# File lib/rspec/sequencing.rb, line 34 def activate_quietly # use this method if you define the sequencing in a let block so RSpec instantiates it end
assert_no_errors()
click to toggle source
# File lib/rspec/sequencing.rb, line 43 def assert_no_errors # if you think you might get exceptions raised in any step the use this to get rspec to see them # the raised error gets set as the dataflow `reason`. value @flows.map do |flow| if flow.rejected? raise flow.reason end flow.value end end
then(description = '', &block)
click to toggle source
# File lib/rspec/sequencing.rb, line 30 def then(description = '', &block) then_after(0, description, &block) end
then_after(delay, description = '', &block)
click to toggle source
# File lib/rspec/sequencing.rb, line 21 def then_after(delay, description = '', &block) @flows << Concurrent.dataflow(*@flows) do sleep delay formatted_puts(description) unless description.empty? block.call end self end
value()
click to toggle source
# File lib/rspec/sequencing.rb, line 55 def value # this is a blocking operation @flows.last.value end
Private Instance Methods
doc_formatter?()
click to toggle source
# File lib/rspec/sequencing.rb, line 68 def doc_formatter? @doc_formatter ||= RSpec.configuration.formatters.first.is_a?( RSpec::Core::Formatters::DocumentationFormatter) end
formatted_puts(text)
click to toggle source
# File lib/rspec/sequencing.rb, line 62 def formatted_puts(text) return if text.empty? || !doc_formatter? txt = RSpec.configuration.format_docstrings_block.call(text) RSpec.configuration.output_stream.puts " #{txt}" end