Class: TestCommonWords

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

Constant Summary

ROOT =
File.expand_path File.dirname(__FILE__) + '/../'

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



13
14
15
# File '/Users/martyn/cw/cw_clone/test/test_common_words.rb', line 13

def setup
  @words = CWG::CommonWords.new
end

- (Object) teardown



17
18
19
# File '/Users/martyn/cw/cw_clone/test/test_common_words.rb', line 17

def teardown
  @words = nil
end

- (Object) test_all_returns_all_words



64
65
66
67
68
69
# File '/Users/martyn/cw/cw_clone/test/test_common_words.rb', line 64

def test_all_returns_all_words
  words = @words.read(:all)
  assert_equal 10000, words.size
  assert_equal 'the',words[0]
  assert_equal 'poison',words[-1]
end

- (Object) test_parse_quantity_for_1



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

def test_parse_quantity_for_1
  assert_equal [0], @words.parse_quantity(1)
end

- (Object) test_parse_quantity_for_2



25
26
27
# File '/Users/martyn/cw/cw_clone/test/test_common_words.rb', line 25

def test_parse_quantity_for_2
  assert_equal [0,1], @words.parse_quantity(2)
end

- (Object) test_parse_quantity_for_no_argument



37
38
39
# File '/Users/martyn/cw/cw_clone/test/test_common_words.rb', line 37

def test_parse_quantity_for_no_argument
  assert_equal [0, 999], @words.parse_quantity()
end

- (Object) test_parse_quantity_for_range_1_2



29
30
31
# File '/Users/martyn/cw/cw_clone/test/test_common_words.rb', line 29

def test_parse_quantity_for_range_1_2
  assert_equal [0,1], @words.parse_quantity(1..2)
end

- (Object) test_parse_quantity_for_range_2_3



33
34
35
# File '/Users/martyn/cw/cw_clone/test/test_common_words.rb', line 33

def test_parse_quantity_for_range_2_3
  assert_equal [1,2], @words.parse_quantity(2..3)
end

- (Object) test_read_returns_100_words_for_no_argument



53
54
55
# File '/Users/martyn/cw/cw_clone/test/test_common_words.rb', line 53

def test_read_returns_100_words_for_no_argument
  assert_equal 1000, @words.read().size
end

- (Object) test_read_returns_500_words_for_range_100_to_1600



57
58
59
60
61
62
# File '/Users/martyn/cw/cw_clone/test/test_common_words.rb', line 57

def test_read_returns_500_words_for_range_100_to_1600
  words = @words.read(100...1600)
  assert_equal 1500, words.size
  assert_equal 'find',words[0]
  assert_equal 'phentermine',words[-1]
end

- (Object) test_read_returns_the_with_argument_1



41
42
43
# File '/Users/martyn/cw/cw_clone/test/test_common_words.rb', line 41

def test_read_returns_the_with_argument_1
  assert_equal ['the'], @words.read(1)
end

- (Object) test_read_returns_the_with_argument_2



45
46
47
# File '/Users/martyn/cw/cw_clone/test/test_common_words.rb', line 45

def test_read_returns_the_with_argument_2
  assert_equal ['the','of'], @words.read(2)
end

- (Object) test_read_returns_the_with_range_2_3



49
50
51
# File '/Users/martyn/cw/cw_clone/test/test_common_words.rb', line 49

def test_read_returns_the_with_range_2_3
  assert_equal ['of','and'], @words.read(2..3)
end