File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change 1
1
class WordyCase < OpenStruct
2
2
def test_name
3
- 'test_%s' % description . downcase . tr_s ( ' ' , '_' )
3
+ 'test_%s' % description . downcase . tr ( ' ' , '_' )
4
4
end
5
5
6
6
def workload
@@ -17,9 +17,7 @@ def skipped
17
17
private
18
18
19
19
def indent ( size , lines )
20
- lines . split ( "\n " ) . map do |line |
21
- ' ' * size + line
22
- end . join ( "\n " )
20
+ lines . lines . each_with_object ( '' ) { |line , obj | obj << ' ' * size + line }
23
21
end
24
22
25
23
def assertion
@@ -48,13 +46,13 @@ def message_assertion
48
46
49
47
class WordyCase ::PreProcessor
50
48
class << self
51
- def call ( row : )
52
- row . merge ( 'message' => message_for ( row : row ) )
49
+ def call ( row )
50
+ row . merge ( 'message' => message_for ( row ) )
53
51
end
54
52
55
53
private
56
54
57
- def message_for ( row : )
55
+ def message_for ( row )
58
56
return unless row [ 'input' ] == 'What is -3 plus 7 multiplied by -2?'
59
57
60
58
'You should ignore order of precedence. -3 + 7 * -2 = -8, not %s'
@@ -64,6 +62,6 @@ def message_for(row:)
64
62
65
63
WordyCases = proc do |data |
66
64
JSON . parse ( data ) [ 'cases' ] . map . with_index do |row , i |
67
- WordyCase . new ( WordyCase ::PreProcessor . call ( row : row ) . merge ( index : i ) )
65
+ WordyCase . new ( WordyCase ::PreProcessor . call ( row ) . merge ( index : i ) )
68
66
end
69
67
end
Original file line number Diff line number Diff line change @@ -66,14 +66,14 @@ def test_workload_without_expected
66
66
class WordyCasePrProcessorTest < Minitest ::Test
67
67
def test_call_as_non_special_case
68
68
row = { 'input' => '' }
69
- processed_row = WordyCase ::PreProcessor . call ( row : row )
69
+ processed_row = WordyCase ::PreProcessor . call ( row )
70
70
71
71
assert_equal ( { 'input' => '' , 'message' => nil } , processed_row )
72
72
end
73
73
74
74
def test_call_as_special_case
75
75
row = { 'input' => 'What is -3 plus 7 multiplied by -2?' }
76
- processed_row = WordyCase ::PreProcessor . call ( row : row )
76
+ processed_row = WordyCase ::PreProcessor . call ( row )
77
77
expected_row = {
78
78
'input' => 'What is -3 plus 7 multiplied by -2?' ,
79
79
'message' => 'You should ignore order of precedence. -3 + 7 * -2 = -8, not %s' ,
You can’t perform that action at this time.
0 commit comments