Sha256: 497a022ea8257a21636151f43e16e0c0c638f68dd3c44a0cc189825920cdea1d

Contents?: true

Size: 745 Bytes

Versions: 19

Compression:

Stored size: 745 Bytes

Contents

# Helpers used for devise testing.
#

# Execute the block setting the given values in
# +new_values+ and restoring the old values
# after the block was 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

  clear_cached_variables(new_values)

  yield
ensure
  clear_cached_variables(new_values)

  old_values.each do |key, value|
    object.send(:"#{key}=", value)
  end
end

def clear_cached_variables(options)
  if options.key?(:case_insensitive_keys) || options.key?(:strip_whitespace_keys)
    Devise.mappings.each do |_, mapping|
      mapping.to.instance_variable_set(:@devise_parameter_filter, nil)
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
devise-token_authenticatable-1.1.0 spec/support/helpers.rb
devise-token_authenticatable-1.0.2 spec/support/helpers.rb
devise-token_authenticatable-1.0.1 spec/support/helpers.rb
devise-token_authenticatable-1.0.0 spec/support/helpers.rb
devise-token_authenticatable-0.5.3 spec/support/helpers.rb
devise-token_authenticatable-0.5.2 spec/support/helpers.rb
devise-token_authenticatable-0.5.1 spec/support/helpers.rb
devise-token_authenticatable-0.4.10 spec/support/helpers.rb
devise-token_authenticatable-0.5.0 spec/support/helpers.rb
devise-token_authenticatable-0.4.9 spec/support/helpers.rb
devise-token_authenticatable-0.4.6 spec/support/helpers.rb
devise-token_authenticatable-0.4.0 spec/support/helpers.rb
devise-token_authenticatable-0.3.2 spec/support/helpers.rb
devise-token_authenticatable-0.3.1 spec/support/helpers.rb
devise-token_authenticatable-0.3.0 spec/support/helpers.rb
devise-token_authenticatable-0.2.0 spec/support/helpers.rb
devise-token_authenticatable-0.2.0.beta1 spec/support/helpers.rb
devise-token_authenticatable-0.1.0 spec/support/helpers.rb
devise-token_authenticatable-0.1.0.beta1 spec/support/helpers.rb