Sha256: c1be04bd3827585df0d7cdf78bcc0423c8099f8a8aead41cf5d2f6e238e4a810

Contents?: true

Size: 1.69 KB

Versions: 3

Compression:

Stored size: 1.69 KB

Contents

# coding: UTF-8

# Marks scenario as pending, optionally explained with a reason.
Then /^it should work(.+?)?$/ do |message|
  pending(message)
end.overridable

# nodoc
Then 'debugger' do
  warn 'The step "Then debugger" will be removed in future versions of Spreewald. Please use "Then console" instead.'
  step 'console' # Alias
end.overridable

# Pauses test execution and opens an IRB shell with current context. Does not halt the application-
# under-test. (Replaces the "Then debugger" step that has never been adequate
# for its job)
Then 'console' do
  require 'irb'
  ARGV.clear # IRB takes ARGV as its own arguments

  # `source` is defined by Capybara as a shortcut to `page.source`. IRB tries to
  # create an alias with the same name and fails with a warning. To avoid this,
  # we remove the alias here.
  undef :source

  # We adapted the steps of IRB.run
  # https://github.com/ruby/ruby/blob/c08f7b80889b531865e74bc5f573df8fa27f2088/lib/irb.rb#L418
  # with injected workspace. See https://github.com/makandra/spreewald/issues/77 for reasons.

  # Don't setup IRB twice to avoid wall of
  # "already initialized constant" warnings
  unless IRB.conf[:LOAD_MODULES]
    IRB.setup(nil)
  end

  workspace = IRB::WorkSpace.new(binding)
  irb = IRB::Irb.new(workspace)
  irb.context.prompt_mode = :SIMPLE

  IRB.conf[:MAIN_CONTEXT] = irb.context

  trap("SIGINT") do
    irb.signal_handle
  end

  begin
    catch(:IRB_EXIT) do
      irb.eval_input
    end
  ensure
    IRB.irb_at_exit
  end
end.overridable

# Waits 2 seconds after each step
AfterStep('@slow-motion') do
  sleep 2
end

# Waits for keypress after each step
AfterStep('@single-step') do
  print "Single Stepping. Hit enter to continue"
  STDIN.getc
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spreewald-2.4.2 lib/spreewald/development_steps.rb
spreewald-2.4.0 lib/spreewald/development_steps.rb
spreewald-2.3.0 lib/spreewald/development_steps.rb