Sha256: afa290b550f14a2fd96948b3ff246ee0fcdff3adfc68e6525975f1399e9dfaca

Contents?: true

Size: 943 Bytes

Versions: 5

Compression:

Stored size: 943 Bytes

Contents

module EnvUtil

  extend self

  # Set environment variables for the duration of the block, then
  # restore them to their original value.
  # @param h [Hash]
  def set(h)
    orig = {}
    h.keys.each do |key|
      orig[key] = ENV[key]
    end
    begin
      h.each do |key, value|
        ENV[key] = value.to_s
      end
      yield
    ensure
      orig.each do |key, value|
        ENV[key] = value
      end
    end
  end

end

Around do |scenario, block|
  EnvUtil.set("CUTE_PRINT_TERM_WIDTH" => 79) do
    block.call
  end
end

Given(/^a file with:$/) do |contents|
  @example = Example.new(contents)
  @example.run
end

Given(/^a file named "(.*?)" with:$/) do |filename, contents|
  @example = Example.new(contents, :filename => filename)
  @example.run
end

Then(/^stderr should be$/) do |expected|
  expect(@example.stderr).to eq expected
end

Then(/^stdout should be$/) do |expected|
  expect(@example.stdout).to eq expected
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cute_print-1.1.4 features/support/step_definitions.rb
cute_print-1.1.3 features/support/step_definitions.rb
cute_print-1.1.2 features/support/step_definitions.rb
cute_print-1.1.1 features/support/step_definitions.rb
cute_print-1.1.0 features/support/step_definitions.rb