-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_item.rb
More file actions
45 lines (32 loc) · 1.46 KB
/
Copy pathtest_item.rb
File metadata and controls
45 lines (32 loc) · 1.46 KB
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
# frozen_string_literal: true
require_relative 'test_helper'
class TestFile < Minitest::Test
def test_equals_with_same_items
item1 = DotStrings::Item.new(comment: 'Comment', key: 'key 1', value: 'value 1')
item2 = DotStrings::Item.new(comment: 'Comment', key: 'key 1', value: 'value 1')
assert_equal item1, item2
end
def test_equals_with_different_comment
item1 = DotStrings::Item.new(comment: 'Comment', key: 'key 1', value: 'value 1')
item2 = DotStrings::Item.new(comment: 'Comment 2', key: 'key 1', value: 'value 1')
refute_equal item1, item2 # skipcq: RB-RL1045
end
def test_equals_with_different_key
item1 = DotStrings::Item.new(comment: 'Comment', key: 'key 1', value: 'value 1')
item2 = DotStrings::Item.new(comment: 'Comment', key: 'key 2', value: 'value 1')
refute_equal item1, item2 # skipcq: RB-RL1045
end
def test_equals_with_different_value
item1 = DotStrings::Item.new(comment: 'Comment', key: 'key 1', value: 'value 1')
item2 = DotStrings::Item.new(comment: 'Comment', key: 'key 1', value: 'value 2')
refute_equal item1, item2 # skipcq: RB-RL1045
end
def test_to_s
item = DotStrings::Item.new(comment: 'Comment', key: 'key 1', value: 'value 1')
assert_equal "/* Comment */\n\"key 1\" = \"value 1\";", item.to_s
end
def test_to_s_with_nil_comment
item = DotStrings::Item.new(comment: nil, key: 'key 1', value: 'value 1')
assert_equal '"key 1" = "value 1";', item.to_s
end
end