cw 0.2.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.cw_config +18 -0
- data/.gitignore +10 -1
- data/LICENSE +2 -1
- data/README.md +212 -96
- data/Rakefile +15 -2
- data/VERSION +1 -1
- data/Vagrantfile +45 -0
- data/cw.gemspec +6 -1
- data/data/text/book_to_read.txt +4 -0
- data/data/text/english.txt +10000 -0
- data/example.rb +172 -106
- data/lib/cw.rb +10 -126
- data/lib/cw/alphabet.rb +53 -46
- data/lib/cw/audio_player.rb +83 -72
- data/lib/cw/book.rb +160 -185
- data/lib/cw/book_details.rb +38 -49
- data/lib/cw/cl.rb +101 -95
- data/lib/cw/common_words.rb +76 -0
- data/lib/cw/config.rb +50 -0
- data/lib/cw/current_word.rb +23 -24
- data/lib/cw/cw_dsl.rb +264 -131
- data/lib/cw/cw_encoding.rb +63 -69
- data/lib/cw/cw_stream.rb +86 -82
- data/lib/cw/cw_threads.rb +132 -22
- data/lib/cw/element.rb +60 -54
- data/lib/cw/file_details.rb +26 -11
- data/lib/cw/key_input.rb +53 -35
- data/lib/cw/numbers.rb +26 -19
- data/lib/cw/os.rb +13 -0
- data/lib/cw/play.rb +92 -0
- data/lib/cw/print.rb +102 -100
- data/lib/cw/process.rb +3 -0
- data/lib/cw/progress.rb +20 -17
- data/lib/cw/randomize.rb +56 -52
- data/lib/cw/repeat_word.rb +59 -66
- data/lib/cw/reveal.rb +32 -31
- data/lib/cw/rss.rb +52 -48
- data/lib/cw/sentence.rb +83 -76
- data/lib/cw/speak.rb +8 -4
- data/lib/cw/spoken.rb +8 -4
- data/lib/cw/str.rb +62 -30
- data/lib/cw/test_letters.rb +20 -28
- data/lib/cw/test_words.rb +25 -31
- data/lib/cw/tester.rb +219 -226
- data/lib/cw/text_helpers.rb +19 -15
- data/lib/cw/timing.rb +63 -67
- data/lib/cw/tone_generator.rb +176 -153
- data/lib/cw/tone_helpers.rb +15 -23
- data/lib/cw/voice.rb +12 -8
- data/lib/cw/words.rb +136 -106
- data/run_script_tests.rb +165 -0
- data/test/my_words.txt +1 -0
- data/test/test_common_words.rb +71 -0
- data/test/test_config.rb +98 -0
- data/test/test_current_word.rb +62 -0
- data/test/test_cw.rb +87 -120
- data/test/test_cw_threads.rb +123 -0
- data/test/test_filtering.rb +439 -0
- data/test/test_params.rb +28 -0
- data/test/test_play.rb +51 -0
- data/test/test_stream.rb +83 -83
- data/test/test_tester.rb +9 -27
- data/test/test_timing.rb +212 -0
- metadata +94 -12
- data/lib/cw/config_file.rb +0 -69
- data/lib/cw/monitor_keys.rb +0 -37
- data/lib/cw/params.rb +0 -104
data/test/my_words.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
one two three four five six seven eignt nine ten
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
$VERBOSE = nil #FIXME
|
3
|
+
SimpleCov.start
|
4
|
+
|
5
|
+
require 'minitest/autorun'
|
6
|
+
require 'minitest/pride'
|
7
|
+
require_relative '../lib/cw'
|
8
|
+
|
9
|
+
class TestCommonWords < MiniTest::Test
|
10
|
+
|
11
|
+
ROOT = File.expand_path File.dirname(__FILE__) + '/../'
|
12
|
+
|
13
|
+
def setup
|
14
|
+
@words = CWG::CommonWords.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def teardown
|
18
|
+
@words = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_parse_quantity_for_1
|
22
|
+
assert_equal [0], @words.parse_quantity(1)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_parse_quantity_for_2
|
26
|
+
assert_equal [0,1], @words.parse_quantity(2)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_parse_quantity_for_range_1_2
|
30
|
+
assert_equal [0,1], @words.parse_quantity(1..2)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_parse_quantity_for_range_2_3
|
34
|
+
assert_equal [1,2], @words.parse_quantity(2..3)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_parse_quantity_for_no_argument
|
38
|
+
assert_equal [0, 999], @words.parse_quantity()
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_read_returns_the_with_argument_1
|
42
|
+
assert_equal ['the'], @words.read(1)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_read_returns_the_with_argument_2
|
46
|
+
assert_equal ['the','of'], @words.read(2)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_read_returns_the_with_range_2_3
|
50
|
+
assert_equal ['of','and'], @words.read(2..3)
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_read_returns_100_words_for_no_argument
|
54
|
+
assert_equal 1000, @words.read().size
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_read_returns_500_words_for_range_100_to_1600
|
58
|
+
words = @words.read(100...1600)
|
59
|
+
assert_equal 1500, words.size
|
60
|
+
assert_equal 'find',words[0]
|
61
|
+
assert_equal 'phentermine',words[-1]
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_all_returns_all_words
|
65
|
+
words = @words.read(:all)
|
66
|
+
assert_equal 10000, words.size
|
67
|
+
assert_equal 'the',words[0]
|
68
|
+
assert_equal 'poison',words[-1]
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
data/test/test_config.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
$VERBOSE = nil #FIXME
|
3
|
+
SimpleCov.start
|
4
|
+
|
5
|
+
require 'minitest/autorun'
|
6
|
+
require 'minitest/pride'
|
7
|
+
require_relative '../lib/cw/config'
|
8
|
+
|
9
|
+
class TestConfig < MiniTest::Test
|
10
|
+
|
11
|
+
CONFIG_METHODS = [
|
12
|
+
:name,:wpm,:effective_wpm,:frequency,:audio_filename,:audio_dir,
|
13
|
+
:book_name,:book_dir,:play_command,:size,:run_default,:word_spacing,
|
14
|
+
:command_line,:author,:title,:quality,:ebook2cw_path,:noise,:no_noise,
|
15
|
+
:tone,:word_count,:volume,:list_colour,:success_colour,:fail_colour,
|
16
|
+
:no_run,:run,:print_letters,:no_print,:use_ebook2cw,:use_ruby_tone,
|
17
|
+
:dictionary,:containing,:begin,:end,:including,:word_filename,:max,:min,
|
18
|
+
:exit
|
19
|
+
]
|
20
|
+
|
21
|
+
def setup
|
22
|
+
CWG::Cfg.reset
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_params_rewrite
|
26
|
+
CWG::Cfg::CONFIG_METHODS.each_with_index do |label,idx|
|
27
|
+
CWG::Cfg.config.params[label] = idx
|
28
|
+
end
|
29
|
+
0.upto CWG::Cfg::CONFIG_METHODS.size - 1 do |idx|
|
30
|
+
assert_equal(idx, CWG::Cfg.config.params[CWG::Cfg::CONFIG_METHODS[idx]])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_wpm_default
|
35
|
+
assert_equal "25", CWG::Cfg.config["wpm"]
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_book_name_default
|
39
|
+
assert_equal "book.txt", CWG::Cfg.config["book_name"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_book_dir_default
|
43
|
+
assert_equal "data/text/", CWG::Cfg.config["book_dir"]
|
44
|
+
end
|
45
|
+
|
46
|
+
# def test_play_command_default
|
47
|
+
# assert_equal "/usr/bin/afplay", CWG::Cfg.config["play_command"]
|
48
|
+
# end
|
49
|
+
|
50
|
+
def test_success_colour_default
|
51
|
+
assert_equal "green", CWG::Cfg.config["success_colour"]
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_fail_colour_default
|
55
|
+
assert_equal "red", CWG::Cfg.config["fail_colour"]
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_list_colour_default
|
59
|
+
assert_equal "default", CWG::Cfg.config["list_colour"]
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_ebook2cw_path_default
|
63
|
+
assert_equal "/usr/bin/ebook2cw", CWG::Cfg.config["ebook2cw_path"]
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_run_default_default
|
67
|
+
assert_equal "test_letters", CWG::Cfg.config["run_default"]
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_dictionary_dir_default
|
71
|
+
assert_equal "data/text/", CWG::Cfg.config["dictionary_dir"]
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_dictionary_name_default
|
75
|
+
assert_equal "english.txt", CWG::Cfg.config["dictionary_name"]
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_accessing_unknown_method_returns_nil
|
79
|
+
refute CWG::Cfg.config["unknown"]
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_setting_unknown_method_returns_nil
|
83
|
+
CWG::Cfg.config.params["unknown"] = "something"
|
84
|
+
assert_equal "something", CWG::Cfg.config["unknown"]
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_an_existing_setting_works
|
88
|
+
refute CWG::Cfg.config["exit"]
|
89
|
+
CWG::Cfg.config.params["exit"] = true
|
90
|
+
assert CWG::Cfg.config["exit"]
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_frequency
|
94
|
+
CWG::Cfg.config.params["frequency"] = 400
|
95
|
+
assert_equal 400, CWG::Cfg.config["frequency"]
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
$VERBOSE = nil #FIXME
|
3
|
+
SimpleCov.start
|
4
|
+
|
5
|
+
require 'minitest/autorun'
|
6
|
+
require 'minitest/pride'
|
7
|
+
require_relative '../lib/cw'
|
8
|
+
|
9
|
+
class TestCurrentWord < MiniTest::Test
|
10
|
+
|
11
|
+
ROOT = File.expand_path File.dirname(__FILE__) + '/../'
|
12
|
+
|
13
|
+
def setup
|
14
|
+
@word = CWG::CurrentWord.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def teardown
|
18
|
+
@word = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_initialize
|
22
|
+
assert_equal '', @word.to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_current_word
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_push_letter
|
29
|
+
@word.push_letter 'a'
|
30
|
+
assert_equal 'a', @word.to_s
|
31
|
+
@word.push_letter '0'
|
32
|
+
assert_equal 'a0', @word.to_s
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_to_s
|
36
|
+
@word.push_letter '-'
|
37
|
+
assert_equal '-', @word.to_s
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_clear
|
41
|
+
@word.push_letter '.'
|
42
|
+
assert_equal '.', @word.to_s
|
43
|
+
@word.clear
|
44
|
+
assert_equal '', @word.to_s
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_strip
|
48
|
+
@word.push_letter ' a '
|
49
|
+
assert_equal ' a ', @word.to_s
|
50
|
+
@word.strip
|
51
|
+
assert_equal 'a', @word.to_s
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_process_letter
|
55
|
+
@word.process_letter 'A'
|
56
|
+
assert_equal 'a', @word.to_s
|
57
|
+
@word.process_letter 'z'
|
58
|
+
assert_equal 'az', @word.to_s
|
59
|
+
@word.process_letter ','
|
60
|
+
assert_equal 'az,', @word.to_s
|
61
|
+
end
|
62
|
+
end
|
data/test/test_cw.rb
CHANGED
@@ -12,7 +12,7 @@ class TestCW < MiniTest::Test
|
|
12
12
|
|
13
13
|
def setup
|
14
14
|
@cw = CW.new
|
15
|
-
@cw.
|
15
|
+
@cw.no_run
|
16
16
|
end
|
17
17
|
|
18
18
|
def teardown
|
@@ -23,12 +23,17 @@ class TestCW < MiniTest::Test
|
|
23
23
|
assert true
|
24
24
|
end
|
25
25
|
|
26
|
+
def test_os_play_command
|
27
|
+
obj = CWG::AudioPlayer.new
|
28
|
+
assert ('afplay' == obj.os_play_command) || ('ossplay' == obj.os_play_command)
|
29
|
+
end
|
30
|
+
|
26
31
|
def test_cw_class
|
27
32
|
assert_equal CW, @cw.class
|
28
33
|
end
|
29
34
|
|
30
|
-
def
|
31
|
-
|
35
|
+
def test_name_is_nil_if_unnamed
|
36
|
+
refute @cw.name
|
32
37
|
end
|
33
38
|
|
34
39
|
def test_name_can_be_set
|
@@ -37,41 +42,25 @@ class TestCW < MiniTest::Test
|
|
37
42
|
end
|
38
43
|
|
39
44
|
def test_loads_words_by_default
|
40
|
-
assert_equal ["the", "of", "and", "
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_dictionary_defaults_to_COMMON_WORDS
|
44
|
-
temp = nil
|
45
|
-
CW.new {
|
46
|
-
pause
|
47
|
-
temp = Params.dictionary
|
48
|
-
}
|
49
|
-
assert_equal File.expand_path(ROOT + '/data/text/common_words.txt'), File.expand_path(temp)
|
45
|
+
assert_equal ["the", "of", "and", "to", "a"] , @cw.words.first(5)
|
50
46
|
end
|
51
47
|
|
52
48
|
def test_CW_takes_a_block
|
53
49
|
CW.new {
|
54
|
-
|
50
|
+
no_run
|
55
51
|
}
|
56
52
|
end
|
57
53
|
|
58
|
-
def
|
54
|
+
def test_words_loads_words
|
59
55
|
cw = CW.new {
|
60
|
-
|
56
|
+
no_run
|
61
57
|
}
|
58
|
+
assert_equal 1000, cw.words.size
|
62
59
|
cw.words = ["some", "words"]
|
63
60
|
assert_equal ["some", "words"], cw.words
|
64
61
|
end
|
65
62
|
|
66
|
-
def
|
67
|
-
cw = CW.new {
|
68
|
-
pause
|
69
|
-
}
|
70
|
-
cw.words = ["some", "words"]
|
71
|
-
assert_equal ["some","words"], cw.words
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_no_run_aliases_pause
|
63
|
+
def test_no_run_aliases_no_run
|
75
64
|
time = Time.now
|
76
65
|
cw = CW.new {
|
77
66
|
no_run
|
@@ -80,70 +69,44 @@ class TestCW < MiniTest::Test
|
|
80
69
|
assert (Time.now - time) < 1
|
81
70
|
end
|
82
71
|
|
83
|
-
def test_reload_reloads_dictionary
|
84
|
-
cw = CW.new {
|
85
|
-
pause
|
86
|
-
}
|
87
|
-
cw.words = ["some", "words"]
|
88
|
-
assert_equal ["some", "words"], cw.words
|
89
|
-
cw.reload
|
90
|
-
assert_equal ["the", "of", "and", "a", "to"] , cw.words.first(5)
|
91
|
-
end
|
92
|
-
|
93
72
|
def test_load_common_words_loads_common_words
|
94
73
|
cw = CW.new {
|
95
|
-
|
74
|
+
no_run
|
96
75
|
}
|
97
76
|
cw.words = ["some", "words"]
|
98
77
|
assert_equal ["some", "words"], cw.words
|
99
78
|
cw.load_common_words
|
100
|
-
assert_equal ["the", "of", "and", "
|
79
|
+
assert_equal ["the", "of", "and", "to", "a"] , cw.words.first(5)
|
101
80
|
end
|
102
81
|
|
103
82
|
def test_load_words_loads_passed_filename
|
104
83
|
temp = Tempfile.new("words.tmp")
|
105
84
|
temp << "some words"
|
106
85
|
temp.close
|
107
|
-
@cw.
|
86
|
+
@cw.load_text temp
|
108
87
|
assert_equal ["some", "words"], @cw.words
|
109
88
|
end
|
110
89
|
|
111
|
-
|
112
|
-
temp = Tempfile.new("words.tmp")
|
113
|
-
temp << "some more words"
|
114
|
-
temp.close
|
115
|
-
@cw.load_words(temp)
|
116
|
-
assert_equal ["some", "more", "words"], @cw.words
|
117
|
-
@cw.words = ''
|
118
|
-
@cw.reload
|
119
|
-
assert_equal ["some", "more", "words"], @cw.words
|
120
|
-
@cw.load_common_words
|
121
|
-
assert_equal ["the", "of", "and", "a", "to"] , @cw.words.first(5)
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_to_s_outputs_test_run_header_if_paused
|
90
|
+
def test_to_s_outputs_test_run_header_if_no_run
|
125
91
|
temp =
|
126
|
-
%q(
|
127
|
-
=======
|
92
|
+
%q(========
|
128
93
|
WPM: 25
|
129
|
-
|
94
|
+
Word count: 16
|
95
|
+
========
|
130
96
|
)
|
131
97
|
assert_equal temp, @cw.to_s
|
132
98
|
end
|
133
99
|
|
134
100
|
def test_to_s_outputs_relevant_params_if_set
|
135
101
|
temp =
|
136
|
-
%q(
|
137
|
-
=======
|
102
|
+
%q(========
|
138
103
|
WPM: 25
|
139
|
-
Shuffle: yes
|
140
104
|
Word count: 2
|
141
105
|
Word size: 3
|
142
106
|
Beginning: l
|
143
107
|
Ending: x
|
144
|
-
|
108
|
+
========
|
145
109
|
)
|
146
|
-
@cw.shuffle
|
147
110
|
@cw.word_count 2
|
148
111
|
@cw.word_size 3
|
149
112
|
@cw.ending_with('x')
|
@@ -167,51 +130,48 @@ Ending: x
|
|
167
130
|
|
168
131
|
def test_effective_wpm_is_settable
|
169
132
|
effective_wpm = rand(50)
|
170
|
-
@cw.effective_wpm
|
171
|
-
assert_equal
|
133
|
+
@cw.effective_wpm(effective_wpm)
|
134
|
+
assert_equal(effective_wpm, @cw.effective_wpm)
|
172
135
|
end
|
173
136
|
|
174
|
-
def test_word_spacing_is_settable_and_readable
|
175
|
-
word_spacing = rand(50)
|
176
|
-
@cw.word_spacing
|
177
|
-
assert_equal
|
178
|
-
end
|
137
|
+
#todo def test_word_spacing_is_settable_and_readable
|
138
|
+
# word_spacing = rand(50)
|
139
|
+
# @cw.word_spacing(word_spacing)
|
140
|
+
# assert_equal(word_spacing, @cw.word_spacing)
|
141
|
+
# end
|
179
142
|
|
180
143
|
def test_shuffle_shuffles_words
|
181
144
|
@cw.shuffle
|
182
|
-
refute_equal ["the", "of", "and", "
|
183
|
-
end
|
184
|
-
|
185
|
-
def test_no_shuffle_doesnt_shuffle
|
186
|
-
@cw.no_shuffle
|
187
|
-
assert_equal ["the", "of", "and", "a", "to"] , @cw.words.first(5)
|
145
|
+
refute_equal ["the", "of", "and", "to", "a"], @cw.words.first(5)
|
188
146
|
end
|
189
147
|
|
190
148
|
def test_word_size_returns_words_of_such_size
|
191
149
|
@cw.word_size 2
|
192
|
-
assert_equal ["of", "to", "in", "is", "
|
150
|
+
assert_equal ["of", "to", "in", "is", "on"] , @cw.words.first(5)
|
193
151
|
end
|
194
152
|
|
195
153
|
def test_beginning_with_returns_words_beginning_with_letter
|
196
154
|
@cw.beginning_with 'l'
|
197
|
-
assert_equal ["like", "
|
155
|
+
assert_equal ["like", "list", "last", "links", "life"], @cw.words.first(5)
|
198
156
|
end
|
199
157
|
|
200
158
|
def test_beginning_with_will_take_two_letters
|
201
|
-
@cw.
|
202
|
-
|
159
|
+
@cw.load_words(1500)
|
160
|
+
@cw.beginning_with 'x','q'
|
161
|
+
assert_equal ["x", "xml", "quality", "questions", "q", "quote"],
|
203
162
|
@cw.words.first(6)
|
204
163
|
end
|
205
164
|
|
206
165
|
def test_ending_with_returns_words_ending_with_letter
|
207
166
|
@cw.ending_with 'l'
|
208
|
-
assert_equal ["all", "will", "
|
167
|
+
assert_equal ["all", "will", "email", "well", "school"], @cw.words.first(5)
|
209
168
|
end
|
210
169
|
|
211
170
|
def test_ending_with_will_take_two_letters
|
171
|
+
@cw.load_words 200
|
212
172
|
@cw.ending_with 'x', 'a'
|
213
|
-
assert_equal ["
|
214
|
-
@cw.words
|
173
|
+
assert_equal ["x", "sex", "a", "data"],
|
174
|
+
@cw.words
|
215
175
|
end
|
216
176
|
|
217
177
|
def test_word_count_returns_x_words
|
@@ -221,22 +181,23 @@ Ending: x
|
|
221
181
|
|
222
182
|
def test_including_returns_words_including_letter
|
223
183
|
@cw.including 'l'
|
224
|
-
assert_equal ["all", "will", "
|
184
|
+
assert_equal ["all", "will", "only", "also", "help"], @cw.words.first(5)
|
225
185
|
end
|
226
186
|
|
227
187
|
def test_including_will_take_two_letters
|
228
|
-
@cw.
|
229
|
-
|
188
|
+
@cw.load_words(100)
|
189
|
+
@cw.including 'p','b'
|
190
|
+
assert_equal ["page", "up", "help", "pm", "by", "be", "about", "but"],@cw.words.first(8)
|
230
191
|
end
|
231
192
|
|
232
193
|
def test_no_longer_than_will_return_words_no_longer_than_x
|
233
194
|
@cw.no_longer_than 4
|
234
|
-
assert_equal ["the", "of", "and", "
|
195
|
+
assert_equal ["the", "of", "and", "to", "a"] , @cw.words.first(5)
|
235
196
|
end
|
236
197
|
|
237
198
|
def test_no_shorter_than_will_return_words_no_shorter_than_x
|
238
199
|
@cw.no_shorter_than 4
|
239
|
-
assert_equal ["that", "
|
200
|
+
assert_equal ["that", "this", "with", "from", "your"], @cw.words.first(5)
|
240
201
|
end
|
241
202
|
|
242
203
|
def test_words_fn_adds_words
|
@@ -356,7 +317,7 @@ Ending: x
|
|
356
317
|
assert_equal 567, @cw.frequency(567)
|
357
318
|
@cw.frequency 456
|
358
319
|
assert_equal 456, @cw.frequency
|
359
|
-
|
320
|
+
end
|
360
321
|
|
361
322
|
def test_play_command_returns_play_command
|
362
323
|
assert_equal 567, @cw.play_command(567)
|
@@ -392,111 +353,117 @@ Ending: x
|
|
392
353
|
assert @cw.method(:words_no_shorter_than), @cw.method(:no_shorter_than)
|
393
354
|
assert @cw.method(:random_alphanumeric), @cw.method(:random_letters_numbers)
|
394
355
|
assert @cw.method(:comment), @cw.method(:name)
|
395
|
-
assert @cw.method(:no_run), @cw.method(:pause)
|
396
356
|
end
|
397
357
|
|
398
358
|
def test_set_wpm_param
|
399
|
-
@cw.wpm
|
400
|
-
|
359
|
+
@cw.wpm 35
|
360
|
+
assert_equal 35, @cw.wpm
|
361
|
+
assert @cw.instance_variable_get('@cl').cl_wpm == '-w 35 ', 'wpm param invalid'
|
401
362
|
end
|
402
363
|
|
403
364
|
def test_set_ewpm_param
|
404
365
|
@cw.effective_wpm 33
|
405
|
-
assert @cw.cl.cl_effective_wpm == '-e 33 ', 'effective_wpm param invalid'
|
366
|
+
assert @cw.instance_variable_get('@cl').cl_effective_wpm == '-e 33 ', 'effective_wpm param invalid'
|
406
367
|
end
|
407
368
|
|
408
369
|
def test_set_word_spacing_W_param
|
409
370
|
@cw.word_spacing 2
|
410
|
-
assert @cw.cl.cl_word_spacing == '-W 2 ', 'word_spacing param invalid'
|
371
|
+
assert @cw.instance_variable_get('@cl').cl_word_spacing == '-W 2 ', 'word_spacing param invalid'
|
411
372
|
end
|
412
373
|
|
413
374
|
def test_set_freq_f_param
|
414
375
|
@cw.frequency 800
|
415
|
-
assert @cw.cl.cl_frequency == '-f 800 ', 'frequency param invalid'
|
376
|
+
assert @cw.instance_variable_get('@cl').cl_frequency == '-f 800 ', 'frequency param invalid'
|
416
377
|
end
|
417
378
|
|
418
|
-
def
|
419
|
-
@cw.
|
420
|
-
assert @cw.cl.cl_squarewave == '-T 2 ', 'squarewave param invalid'
|
379
|
+
def test_tone_squarewave_param
|
380
|
+
@cw.tone :squarewave
|
381
|
+
assert @cw.instance_variable_get('@cl').cl_squarewave == '-T 2 ', 'squarewave param invalid'
|
421
382
|
end
|
422
383
|
|
423
|
-
def
|
424
|
-
@cw.
|
425
|
-
assert @cw.cl.cl_sawtooth == '-T 1 ', 'sawtooth param invalid'
|
384
|
+
def test_tone_sawtooth_param
|
385
|
+
@cw.tone :sawtooth
|
386
|
+
assert @cw.instance_variable_get('@cl').cl_sawtooth == '-T 1 ', 'sawtooth param invalid'
|
426
387
|
end
|
427
388
|
|
428
|
-
def
|
429
|
-
@cw.
|
430
|
-
assert @cw.cl.cl_sinewave == '-T 0 ', 'sinewave param invalid'
|
389
|
+
def test_tone_sinewave_param
|
390
|
+
@cw.tone :sinewave
|
391
|
+
assert @cw.instance_variable_get('@cl').cl_sinewave == '-T 0 ', 'sinewave param invalid'
|
431
392
|
end
|
432
393
|
|
433
394
|
def test_build_build_cl_ignores_invalid_tone_type
|
434
|
-
@cw.
|
435
|
-
@cw.
|
436
|
-
assert @cw.cl.cl_sinewave == '-T 0 ', 'not ignoring invalid tone type'
|
395
|
+
@cw.tone :invalid
|
396
|
+
assert @cw.instance_variable_get('@cl').cl_sinewave == '', 'not ignoring invalid tone type'
|
437
397
|
end
|
438
398
|
|
439
399
|
def test_set_author_param
|
440
400
|
@cw.author 'some author'
|
441
|
-
assert @cw.cl.cl_author == '-a "some author" ', 'author param invalid'
|
401
|
+
assert @cw.instance_variable_get('@cl').cl_author == '-a "some author" ', 'author param invalid'
|
442
402
|
end
|
443
403
|
|
444
404
|
def test_set_title_param
|
445
405
|
@cw.title 'some title'
|
446
|
-
assert @cw.cl.cl_title == '-t "some title" ', 'title param invalid'
|
406
|
+
assert @cw.instance_variable_get('@cl').cl_title == '-t "some title" ', 'title param invalid'
|
447
407
|
end
|
448
408
|
|
449
409
|
def test_set_N_param_in_noise_mode
|
450
410
|
@cw.noise
|
451
|
-
assert @cw.cl.cl_noise.include?('-N 5 '), 'noise N param invalid'
|
411
|
+
assert @cw.instance_variable_get('@cl').cl_noise.include?('-N 5 '), 'noise N param invalid'
|
452
412
|
end
|
453
413
|
|
454
414
|
def test_set_B_param_in_noise_mode
|
455
415
|
@cw.noise
|
456
|
-
assert @cw.cl.cl_noise.include?('-B 1000 '), 'noise B param invalid'
|
416
|
+
assert @cw.instance_variable_get('@cl').cl_noise.include?('-B 1000 '), 'noise B param invalid'
|
457
417
|
end
|
458
418
|
|
459
419
|
def test_set_default_filename
|
460
|
-
assert @cw.cl.cl_audio_filename.
|
420
|
+
assert @cw.instance_variable_get('@cl').cl_audio_filename.
|
421
|
+
include?('audio_output'), 'default audio output filename invalid'
|
461
422
|
end
|
462
423
|
|
463
424
|
def test_set_audio_filename_to_given_name
|
464
425
|
@cw.audio_filename('some name')
|
465
|
-
assert @cw.cl.cl_audio_filename.
|
426
|
+
assert @cw.instance_variable_get('@cl').cl_audio_filename.
|
427
|
+
include?("some name"), 'default audio filename invalid'
|
466
428
|
end
|
467
429
|
|
468
430
|
def test_set_q_param_when_numeric_quality
|
469
431
|
@cw.quality 5
|
470
|
-
assert @cw.cl.cl_quality.
|
432
|
+
assert @cw.instance_variable_get('@cl').cl_quality.
|
433
|
+
include?('-q 5 '), 'audio quality invalid'
|
471
434
|
end
|
472
435
|
|
473
436
|
def test_set_low_quality
|
474
437
|
@cw.quality :low
|
475
|
-
assert @cw.cl.cl_quality.
|
438
|
+
assert @cw.instance_variable_get('@cl').cl_quality.
|
439
|
+
include?('-q 9 '), 'audio low quality invalid'
|
476
440
|
end
|
477
441
|
|
478
442
|
def test_set_medium_quality
|
479
443
|
@cw.quality :medium
|
480
|
-
assert @cw.cl.cl_quality.
|
444
|
+
assert @cw.instance_variable_get('@cl').cl_quality.
|
445
|
+
include?('-q 5 '), 'audio medium quality invalid'
|
481
446
|
end
|
482
447
|
|
483
448
|
def test_set_high_quality
|
484
449
|
@cw.quality :high
|
485
|
-
assert @cw.cl.cl_quality.
|
450
|
+
assert @cw.instance_variable_get('@cl').cl_quality.
|
451
|
+
include?('-q 1 '), 'audio high quality invalid'
|
486
452
|
end
|
487
453
|
|
488
454
|
def test_build_command_includes_custom_commands_via_build_cl
|
489
455
|
@cw.command_line '-x "some custom command"'
|
490
|
-
assert @cw.cl.cl_command_line.
|
456
|
+
assert @cw.instance_variable_get('@cl').cl_command_line.
|
457
|
+
include?( '-x "some custom command"'), 'custom command invalid'
|
491
458
|
end
|
492
459
|
|
493
460
|
def test_cl_echo_returns_correct_string
|
494
461
|
str = ''
|
495
462
|
CW.new do
|
496
463
|
str = @cl.cl_echo('some words')
|
497
|
-
|
464
|
+
no_run
|
498
465
|
end
|
499
|
-
assert str.include?('
|
466
|
+
assert str.include?('some words')
|
500
467
|
end
|
501
468
|
|
502
469
|
def test_words_exist
|
@@ -504,19 +471,19 @@ Ending: x
|
|
504
471
|
CW.new do
|
505
472
|
words = 'some words added here'
|
506
473
|
temp = words
|
507
|
-
|
474
|
+
no_run
|
508
475
|
end
|
509
476
|
assert_equal(4, temp.split.size)
|
510
477
|
CW.new do
|
511
478
|
@words.add 'a couple of words'
|
512
479
|
temp = words
|
513
|
-
|
480
|
+
no_run
|
514
481
|
end
|
515
482
|
assert_equal(4, temp.split.size)
|
516
483
|
CW.new do
|
517
484
|
@words.add nil
|
518
485
|
temp = words
|
519
|
-
|
486
|
+
no_run
|
520
487
|
end
|
521
488
|
assert_nil(temp)
|
522
489
|
end
|