|
1 | 1 | describe 'Container internal methods' do
|
2 | 2 | using RSpec::Parameterized::TableSyntax
|
3 | 3 |
|
4 |
| - where(:method, :expect_output) do |
| 4 | + where(:method, :output) do |
5 | 5 | 'gsub' | %w[barbar foofoo].join("\n")
|
6 | 6 | 'gsub!' | %w[barbar barbar].join("\n")
|
7 | 7 | 'sub' | %w[barfoo foofoo].join("\n")
|
|
11 | 11 | with_them do
|
12 | 12 | let(:input) { 'foofoo' }
|
13 | 13 | let(:args) { %('puts #{method}(/foo/, "bar"); _') }
|
| 14 | + let(:expect_output) { "#{output}\n" } |
14 | 15 |
|
15 | 16 | it_behaves_like 'a successful exec'
|
16 | 17 | end
|
17 | 18 |
|
18 |
| - where(:method, :expect_output) do |
| 19 | + where(:method, :output) do |
19 | 20 | 'tr' | %w[FOOFOO foofoo].join("\n")
|
20 | 21 | 'tr!' | %w[FOOFOO FOOFOO].join("\n")
|
21 | 22 | end
|
22 | 23 |
|
23 | 24 | with_them do
|
24 | 25 | let(:input) { 'foofoo' }
|
25 | 26 | let(:args) { %('puts #{method}("a-z", "A-Z"); _') }
|
| 27 | + let(:expect_output) { "#{output}\n" } |
26 | 28 |
|
27 | 29 | it_behaves_like 'a successful exec'
|
28 | 30 | end
|
29 | 31 |
|
30 |
| - where(:command, :expect_output) do |
| 32 | + where(:command, :output) do |
31 | 33 | 'grep(/foo/)' | 'foo'
|
32 | 34 | 'grep_v(/bar/)' | 'foo baz'
|
33 | 35 | 'grep(/foo/){|i| i + "hoge" }' | 'foohoge'
|
|
37 | 39 | with_them do
|
38 | 40 | let(:input) { %w[foo bar baz].join("\n") }
|
39 | 41 | let(:args) { %(-s '#{command}') }
|
| 42 | + let(:expect_output) { "#{output}\n" } |
40 | 43 |
|
41 | 44 | it_behaves_like 'a successful exec'
|
42 | 45 | end
|
|
48 | 51 | 'String' => {
|
49 | 52 | condition: '"2 foo baz"',
|
50 | 53 | output: {
|
51 |
| - without_block: '2 foo baz', |
52 |
| - with_block: '2' |
| 54 | + without_block: "2 foo baz\n", |
| 55 | + with_block: "2\n" |
53 | 56 | }
|
54 | 57 | },
|
55 | 58 | 'Regexp' => {
|
|
60 | 63 | 2 foo baz
|
61 | 64 | 3 foo qux
|
62 | 65 | OUTPUT
|
63 |
| - with_block: %w[1 2 3].join("\n") |
| 66 | + with_block: "1\n2\n3\n" |
64 | 67 | }
|
65 | 68 | },
|
66 | 69 | 'TrueClass' => {
|
67 | 70 | condition: '_1 == "3"',
|
68 | 71 | output: {
|
69 |
| - without_block: '3 foo qux', |
70 |
| - with_block: '3' |
| 72 | + without_block: "3 foo qux\n", |
| 73 | + with_block: "3\n" |
71 | 74 | }
|
72 | 75 | },
|
73 | 76 | 'FalseClass' => {
|
|
85 | 88 | 2 foo baz
|
86 | 89 | 3 foo qux
|
87 | 90 | OUTPUT
|
88 |
| - with_block: %w[1 2 3].join("\n") |
| 91 | + with_block: "1\n2\n3\n" |
89 | 92 | }
|
90 | 93 | },
|
91 | 94 | 'NilClass' => {
|
|
131 | 134 | 'String' => {
|
132 | 135 | condition: '"2 foo baz"',
|
133 | 136 | output: {
|
134 |
| - without_block: '2 foo baz', |
135 |
| - with_block: '2 foo baz', |
136 |
| - return_value: %w[false true false].join("\n") |
| 137 | + without_block: "2 foo baz\n", |
| 138 | + with_block: "2 foo baz\n", |
| 139 | + return_value: <<~VALUE |
| 140 | + false |
| 141 | + true |
| 142 | + false |
| 143 | + VALUE |
137 | 144 | }
|
138 | 145 | },
|
139 | 146 | 'Regexp' => {
|
|
149 | 156 | 2 foo baz
|
150 | 157 | 3 foo qux
|
151 | 158 | OUTPUT
|
152 |
| - return_value: %w[true true true].join("\n") |
| 159 | + return_value: <<~VALUE |
| 160 | + true |
| 161 | + true |
| 162 | + true |
| 163 | + VALUE |
153 | 164 | }
|
154 | 165 | },
|
155 | 166 | 'TrueClass' => {
|
156 | 167 | condition: '_1 == "3"',
|
157 | 168 | output: {
|
158 |
| - without_block: '3 foo qux', |
159 |
| - with_block: '3 foo qux', |
160 |
| - return_value: %w[false false true].join("\n") |
| 169 | + without_block: "3 foo qux\n", |
| 170 | + with_block: "3 foo qux\n", |
| 171 | + return_value: <<~VALUE |
| 172 | + false |
| 173 | + false |
| 174 | + true |
| 175 | + VALUE |
161 | 176 | }
|
162 | 177 | },
|
163 | 178 | 'FalseClass' => {
|
164 | 179 | condition: '_1 == "4"',
|
165 | 180 | output: {
|
166 | 181 | without_block: '',
|
167 | 182 | with_block: '',
|
168 |
| - return_value: %w[false false false].join("\n") |
| 183 | + return_value: <<~VALUE |
| 184 | + false |
| 185 | + false |
| 186 | + false |
| 187 | + VALUE |
169 | 188 | }
|
170 | 189 | },
|
171 | 190 | 'Integer' => {
|
|
181 | 200 | 2 foo baz
|
182 | 201 | 3 foo qux
|
183 | 202 | OUTPUT
|
184 |
| - return_value: %w[true true true].join("\n") |
| 203 | + return_value: <<~VALUE |
| 204 | + true |
| 205 | + true |
| 206 | + true |
| 207 | + VALUE |
185 | 208 | }
|
186 | 209 | },
|
187 | 210 | 'NilClass' => {
|
188 | 211 | condition: '_2 =~ /hoge/',
|
189 | 212 | output: {
|
190 | 213 | without_block: '',
|
191 | 214 | with_block: '',
|
192 |
| - return_value: %w[false false false].join("\n") |
| 215 | + return_value: <<~VALUE |
| 216 | + false |
| 217 | + false |
| 218 | + false |
| 219 | + VALUE |
193 | 220 | }
|
194 | 221 | }
|
195 | 222 | }
|
|
0 commit comments