GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/zmack/mephisto.git
svenfuchs (author)
Wed Feb 20 11:11:20 -0800 2008
commit  1ad1b56b4a6c9284534b0afbb9d5d87715ae4312
tree    adc435b61f05728a991fd314188bc3e75cfb6038
parent  2772ec18227b04b3cb618748a2900a7b93b84d94
mephisto / vendor / plugins / engines_config / test / test_engines_configurable.rb
100644 39 lines (30 sloc) 1.055 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
 
class EnginesConfigurableTest < Test::Unit::TestCase
  def teardown
    Engines::Plugin::Config.destroy_all
    plugin_alpha.instance_variable_set(:@config, nil)
  end
  
  def test_should_load_test_plugin
    assert_nothing_raised { plugin_alpha }
  end
  
  def test_should_allow_to_define_option_within_plugin_init_rb
    assert plugin_alpha.respond_to?(:an_option)
  end
  
  def test_should_use_option_default_value
    assert_equal 'a default', plugin_alpha.an_option
  end
  
  def test_should_save_option_to_active_record_store
    plugin_alpha.another_option = 'a value'
    plugin_alpha.save!
    assert_equal 'a value', Engines::Plugin::Config.find_by_name('plugin_alpha').options[:another_option]
  end
  
  def test_should_read_option_from_active_record_store
    plugin_alpha.another_option = 'a value'
    plugin_alpha.save!
    assert_equal 'a value', plugin_alpha.another_option
  end
  
  private
  
  def plugin_alpha
    Engines.plugins['plugin_alpha']
  end
end