-
Notifications
You must be signed in to change notification settings - Fork 0
/
wikilang_test.rb
55 lines (46 loc) · 1.57 KB
/
wikilang_test.rb
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require 'minitest/autorun'
require File.expand_path('../wikilang.rb', __FILE__)
describe WikiLang do
subject { WikiLang.new }
describe "#url" do
it "should get the omniglot languages page" do
subject.url.must_equal "http://omniglot.com/writing/languages.htm"
end
end
describe "#document" do
it "should be a NokoGiri::HTML document" do
subject.document.must_be_kind_of Nokogiri::HTML::Document
end
end
describe "#add_language" do
it "adds a language to languages if the text is not empty" do
subject.add_language "Chinese"
subject.languages.must_include "Chinese"
end
it "doesn't add a language if the text is empty" do
@lang_length = subject.languages.length
subject.add_language ""
subject.languages.length.must_equal @lang_length
end
it "doesn't add a language if it contains more than two words" do
@lang_length = subject.languages.length
subject.add_language "Learn Chinese with omnitglot app"
subject.languages.length.must_equal @lang_length
end
it "doesn't add a language if it is the word 'top'" do
@lang_length = subject.languages.length
subject.add_language "top"
subject.languages.length.must_equal @lang_length
end
it "doesn't add a language if it is the word is a comma" do
@lang_length = subject.languages.length
subject.add_language ","
subject.languages.length.must_equal @lang_length
end
end
describe "#languages" do
it "should be an array" do
subject.languages.must_be_kind_of Array
end
end
end