Class: TestConfig

Inherits:
MiniTest::Test
  • Object
show all
Defined in:
/Users/martyn/cw/cw_clone/test/test_config.rb

Constant Summary

CONFIG_METHODS =
[
  :name,:wpm,:effective_wpm,:frequency,:audio_filename,:audio_dir,
  :book_name,:book_dir,:play_command,:size,:run_default,:word_spacing,
  :command_line,:author,:title,:quality,:ebook2cw_path,:noise,:no_noise,
  :tone,:word_count,:volume,:list_colour,:success_colour,:fail_colour,
  :no_run,:run,:print_letters,:no_print,:use_ebook2cw,:use_ruby_tone,
  :dictionary,:containing,:begin,:end,:including,:word_filename,:max,:min,
  :exit
]

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



21
22
23
# File '/Users/martyn/cw/cw_clone/test/test_config.rb', line 21

def setup
  CWG::Cfg.reset
end

- (Object) test_accessing_unknown_method_returns_nil



78
79
80
# File '/Users/martyn/cw/cw_clone/test/test_config.rb', line 78

def test_accessing_unknown_method_returns_nil
  refute CWG::Cfg.config["unknown"]
end

- (Object) test_an_existing_setting_works



87
88
89
90
91
# File '/Users/martyn/cw/cw_clone/test/test_config.rb', line 87

def test_an_existing_setting_works
  refute CWG::Cfg.config["exit"]
  CWG::Cfg.config.params["exit"] = true
  assert CWG::Cfg.config["exit"]
end

- (Object) test_book_dir_default



42
43
44
# File '/Users/martyn/cw/cw_clone/test/test_config.rb', line 42

def test_book_dir_default
  assert_equal "data/text/", CWG::Cfg.config["book_dir"]
end

- (Object) test_book_name_default



38
39
40
# File '/Users/martyn/cw/cw_clone/test/test_config.rb', line 38

def test_book_name_default
  assert_equal "book.txt", CWG::Cfg.config["book_name"]
end

- (Object) test_dictionary_dir_default



70
71
72
# File '/Users/martyn/cw/cw_clone/test/test_config.rb', line 70

def test_dictionary_dir_default
  assert_equal "data/text/", CWG::Cfg.config["dictionary_dir"]
end

- (Object) test_dictionary_name_default



74
75
76
# File '/Users/martyn/cw/cw_clone/test/test_config.rb', line 74

def test_dictionary_name_default
  assert_equal "english.txt", CWG::Cfg.config["dictionary_name"]
end

- (Object) test_ebook2cw_path_default



62
63
64
# File '/Users/martyn/cw/cw_clone/test/test_config.rb', line 62

def test_ebook2cw_path_default
  assert_equal "/usr/bin/ebook2cw", CWG::Cfg.config["ebook2cw_path"]
end

- (Object) test_fail_colour_default



54
55
56
# File '/Users/martyn/cw/cw_clone/test/test_config.rb', line 54

def test_fail_colour_default
  assert_equal "red", CWG::Cfg.config["fail_colour"]
end

- (Object) test_frequency



93
94
95
96
# File '/Users/martyn/cw/cw_clone/test/test_config.rb', line 93

def test_frequency
  CWG::Cfg.config.params["frequency"] = 400
  assert_equal 400, CWG::Cfg.config["frequency"]
end

- (Object) test_list_colour_default



58
59
60
# File '/Users/martyn/cw/cw_clone/test/test_config.rb', line 58

def test_list_colour_default
  assert_equal "default", CWG::Cfg.config["list_colour"]
end

- (Object) test_params_rewrite



25
26
27
28
29
30
31
32
# File '/Users/martyn/cw/cw_clone/test/test_config.rb', line 25

def test_params_rewrite
  CWG::Cfg::CONFIG_METHODS.each_with_index do |label,idx|
    CWG::Cfg.config.params[label] = idx
  end
  0.upto CWG::Cfg::CONFIG_METHODS.size - 1 do |idx|
    assert_equal(idx, CWG::Cfg.config.params[CWG::Cfg::CONFIG_METHODS[idx]])
  end
end

- (Object) test_play_command_default



46
47
48
# File '/Users/martyn/cw/cw_clone/test/test_config.rb', line 46

def test_play_command_default
  assert_equal "/usr/bin/afplay", CWG::Cfg.config["play_command"]
end

- (Object) test_run_default_default



66
67
68
# File '/Users/martyn/cw/cw_clone/test/test_config.rb', line 66

def test_run_default_default
  assert_equal "test_letters", CWG::Cfg.config["run_default"]
end

- (Object) test_setting_unknown_method_returns_nil



82
83
84
85
# File '/Users/martyn/cw/cw_clone/test/test_config.rb', line 82

def test_setting_unknown_method_returns_nil
  CWG::Cfg.config.params["unknown"] = "something"
  assert_equal "something", CWG::Cfg.config["unknown"]
end

- (Object) test_success_colour_default



50
51
52
# File '/Users/martyn/cw/cw_clone/test/test_config.rb', line 50

def test_success_colour_default
  assert_equal "green", CWG::Cfg.config["success_colour"]
end

- (Object) test_wpm_default



34
35
36
# File '/Users/martyn/cw/cw_clone/test/test_config.rb', line 34

def test_wpm_default
  assert_equal "25", CWG::Cfg.config["wpm"]
end