Module: Spree::Core::TestingSupport::Preferences

Defined in:
lib/spree/core/testing_support/preferences.rb

Instance Method Summary collapse

Instance Method Details

#assert_preference_unset(preference) ⇒ Object



25
26
27
28
# File 'lib/spree/core/testing_support/preferences.rb', line 25

def assert_preference_unset(preference)
  find("#preferences_#{preference}")['checked'].should be_false
  Spree::Config[preference].should be_false
end

#configure_spree_preferences {|config| ... } ⇒ Object

The preference cache is cleared before each test, so the default values will be used. You can define preferences for your spec with:

configure_spree_preferences do |config|

config.site_name = "my fancy pants store"

end

Yields:

  • (config)


20
21
22
23
# File 'lib/spree/core/testing_support/preferences.rb', line 20

def configure_spree_preferences
  config = Rails.application.config.spree.preferences
  yield(config) if block_given?
end

#reset_spree_preferences(&config_block) ⇒ Object



5
6
7
8
9
10
# File 'lib/spree/core/testing_support/preferences.rb', line 5

def reset_spree_preferences(&config_block)
  Spree::Preferences::Store.instance.persistence = false
  Spree::Preferences::Store.instance.clear_cache

  configure_spree_preferences &config_block if block_given?
end