Sha256: 1e164a54b06c1874ed3ac2c0d4e401c741ef1dd716acd7c0beb932370a37b8f1

Contents?: true

Size: 414 Bytes

Versions: 4

Compression:

Stored size: 414 Bytes

Contents

class ActiveSupport::TestCase
  # Execute the block setting the given values and restoring old values after
  # the block is executed.
  def swap(object, new_values)
    old_values = {}
    new_values.each do |key, value|
      old_values[key] = object.send key
      object.send :"#{key}=", value
    end
    yield
  ensure
    old_values.each do |key, value|
      object.send :"#{key}=", value
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
rails_customerbeats-0.0.5 test/support/helpers.rb
rails_customerbeats-0.0.4 test/support/helpers.rb
rails_customerbeats-0.3 test/support/helpers.rb
rails_metrics-0.1 test/support/helpers.rb