-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathquest_test.rb
62 lines (41 loc) · 1.3 KB
/
quest_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
56
57
58
59
60
61
62
require './quest'
require 'test/unit'
class QuestTest < Test::Unit::TestCase
def sample_data
<<DATA
What's the naming convention for local variables?
`userDetails`
* `user_details`
`UserDetails`
`USER_DETAILS`
=
What's the naming convention for classes and their files?
`user_detail` class in `user_detail.rb` file
`UserDetail` class in `UserDetail.rb` file
* `UserDetail` in `user_detail.rb` file
`user_detail` class in `UserDetail.rb` file
=
Which of these options contains a global variable:
*`$names`
`@names`
`names` defined outside of any method or class
`@@names`
`$$names`
DATA
end
def test_parse_data
questions = parse_data(sample_data)
assert_equal 3, questions.size
question = questions.first
assert_equal 4, question[:answers].size
assert_equal "What's the naming convention for local variables?", question[:question]
assert_equal "`userDetails`", question[:answers][0][:answer]
assert ! question[:answers][0][:correct]
assert_equal "`user_details`", question[:answers][1][:answer]
assert question[:answers][1][:correct]
assert_equal "`UserDetails`", question[:answers][2][:answer]
assert ! question[:answers][2][:correct]
assert_equal "`USER_DETAILS`", question[:answers][3][:answer]
assert ! question[:answers][3][:correct]
end
end