|
220 | 220 | before do |
221 | 221 | allow(Dir).to receive(:glob).with("app/views/**/*.erb").and_return(["app/views/layouts/application.html.erb"]) |
222 | 222 | allow(Dir).to receive(:glob).with("app/views/**/*.haml").and_return([]) |
| 223 | + allow(Dir).to receive(:glob).with("app/views/**/*.slim").and_return([]) |
223 | 224 | allow(File).to receive(:exist?).with("app/views/layouts/application.html.erb").and_return(true) |
224 | 225 | allow(File).to receive(:read).with("app/views/layouts/application.html.erb") |
225 | 226 | .and_return('<%= javascript_pack_tag "application", :async %>') |
|
279 | 280 | allow(Dir).to receive(:glob).with("app/views/**/*.erb") |
280 | 281 | .and_return(["app/views/layouts/application.html.erb"]) |
281 | 282 | allow(Dir).to receive(:glob).with("app/views/**/*.haml").and_return([]) |
| 283 | + allow(Dir).to receive(:glob).with("app/views/**/*.slim").and_return([]) |
282 | 284 | allow(File).to receive(:exist?).with("app/views/layouts/application.html.erb").and_return(true) |
283 | 285 | allow(File).to receive(:read).with("app/views/layouts/application.html.erb") |
284 | 286 | .and_return('<%= javascript_pack_tag "app", :async %>') |
|
297 | 299 | allow(Dir).to receive(:glob).with("app/views/**/*.erb") |
298 | 300 | .and_return(["app/views/layouts/application.html.erb"]) |
299 | 301 | allow(Dir).to receive(:glob).with("app/views/**/*.haml").and_return([]) |
| 302 | + allow(Dir).to receive(:glob).with("app/views/**/*.slim").and_return([]) |
300 | 303 | allow(File).to receive(:exist?).with("app/views/layouts/application.html.erb").and_return(true) |
301 | 304 | allow(File).to receive(:read).with("app/views/layouts/application.html.erb") |
302 | 305 | .and_return('<%= javascript_pack_tag "app", async: true %>') |
|
315 | 318 | allow(Dir).to receive(:glob).with("app/views/**/*.erb") |
316 | 319 | .and_return(["app/views/layouts/application.html.erb"]) |
317 | 320 | allow(Dir).to receive(:glob).with("app/views/**/*.haml").and_return([]) |
| 321 | + allow(Dir).to receive(:glob).with("app/views/**/*.slim").and_return([]) |
318 | 322 | allow(File).to receive(:exist?).with("app/views/layouts/application.html.erb").and_return(true) |
319 | 323 | allow(File).to receive(:read).with("app/views/layouts/application.html.erb") |
320 | 324 | .and_return('<%= javascript_pack_tag "app", defer: "async" %>') |
|
331 | 335 | allow(Dir).to receive(:glob).with("app/views/**/*.erb") |
332 | 336 | .and_return(["app/views/layouts/application.html.erb"]) |
333 | 337 | allow(Dir).to receive(:glob).with("app/views/**/*.haml").and_return([]) |
| 338 | + allow(Dir).to receive(:glob).with("app/views/**/*.slim").and_return([]) |
334 | 339 | allow(File).to receive(:exist?).with("app/views/layouts/application.html.erb").and_return(true) |
335 | 340 | allow(File).to receive(:read).with("app/views/layouts/application.html.erb") |
336 | 341 | .and_return('<%= javascript_pack_tag "app" %>') |
|
347 | 352 | allow(Dir).to receive(:glob).with("app/views/**/*.erb") |
348 | 353 | .and_return(["app/views/layouts/application.html.erb"]) |
349 | 354 | allow(Dir).to receive(:glob).with("app/views/**/*.haml").and_return([]) |
| 355 | + allow(Dir).to receive(:glob).with("app/views/**/*.slim").and_return([]) |
350 | 356 | allow(File).to receive(:exist?).with("app/views/layouts/application.html.erb").and_return(true) |
351 | 357 | allow(File).to receive(:read).with("app/views/layouts/application.html.erb") |
352 | 358 | .and_return('<%= javascript_pack_tag "app", defer: true %> |
|
364 | 370 | allow(Dir).to receive(:glob).with("app/views/**/*.erb") |
365 | 371 | .and_return(["app/views/layouts/application.html.erb"]) |
366 | 372 | allow(Dir).to receive(:glob).with("app/views/**/*.haml").and_return([]) |
| 373 | + allow(Dir).to receive(:glob).with("app/views/**/*.slim").and_return([]) |
367 | 374 | allow(File).to receive(:exist?).with("app/views/layouts/application.html.erb").and_return(true) |
368 | 375 | allow(File).to receive(:read).with("app/views/layouts/application.html.erb") |
369 | 376 | .and_return('<%# javascript_pack_tag "app", :async %>') |
|
380 | 387 | allow(Dir).to receive(:glob).with("app/views/**/*.erb").and_return([]) |
381 | 388 | allow(Dir).to receive(:glob).with("app/views/**/*.haml") |
382 | 389 | .and_return(["app/views/layouts/application.html.haml"]) |
| 390 | + allow(Dir).to receive(:glob).with("app/views/**/*.slim").and_return([]) |
383 | 391 | allow(File).to receive(:exist?).with("app/views/layouts/application.html.haml").and_return(true) |
384 | 392 | allow(File).to receive(:read).with("app/views/layouts/application.html.haml") |
385 | 393 | .and_return('-# javascript_pack_tag "app", :async') |
|
396 | 404 | allow(Dir).to receive(:glob).with("app/views/**/*.erb") |
397 | 405 | .and_return(["app/views/layouts/application.html.erb"]) |
398 | 406 | allow(Dir).to receive(:glob).with("app/views/**/*.haml").and_return([]) |
| 407 | + allow(Dir).to receive(:glob).with("app/views/**/*.slim").and_return([]) |
| 408 | + allow(Dir).to receive(:glob).with("app/views/**/*.slim").and_return([]) |
399 | 409 | allow(File).to receive(:exist?).with("app/views/layouts/application.html.erb").and_return(true) |
400 | 410 | allow(File).to receive(:read).with("app/views/layouts/application.html.erb") |
401 | 411 | .and_return('<!-- <%= javascript_pack_tag "app", :async %> -->') |
|
407 | 417 | end |
408 | 418 | end |
409 | 419 |
|
| 420 | + context "when async is only in Slim comments" do |
| 421 | + before do |
| 422 | + allow(Dir).to receive(:glob).with("app/views/**/*.erb").and_return([]) |
| 423 | + allow(Dir).to receive(:glob).with("app/views/**/*.haml").and_return([]) |
| 424 | + allow(Dir).to receive(:glob).with("app/views/**/*.slim").and_return([]) |
| 425 | + allow(Dir).to receive(:glob).with("app/views/**/*.slim") |
| 426 | + .and_return(["app/views/layouts/application.html.slim"]) |
| 427 | + allow(File).to receive(:exist?).with("app/views/layouts/application.html.slim").and_return(true) |
| 428 | + allow(File).to receive(:read).with("app/views/layouts/application.html.slim") |
| 429 | + .and_return('/ = javascript_pack_tag "app", :async') |
| 430 | + end |
| 431 | + |
| 432 | + it "returns empty array" do |
| 433 | + files = doctor.send(:scan_view_files_for_async_pack_tag) |
| 434 | + expect(files).to be_empty |
| 435 | + end |
| 436 | + end |
| 437 | + |
| 438 | + context "when view files contain Slim javascript_pack_tag with :async" do |
| 439 | + before do |
| 440 | + allow(Dir).to receive(:glob).with("app/views/**/*.erb").and_return([]) |
| 441 | + allow(Dir).to receive(:glob).with("app/views/**/*.haml").and_return([]) |
| 442 | + allow(Dir).to receive(:glob).with("app/views/**/*.slim").and_return([]) |
| 443 | + allow(Dir).to receive(:glob).with("app/views/**/*.slim") |
| 444 | + .and_return(["app/views/layouts/application.html.slim"]) |
| 445 | + allow(File).to receive(:exist?).with("app/views/layouts/application.html.slim").and_return(true) |
| 446 | + allow(File).to receive(:read).with("app/views/layouts/application.html.slim") |
| 447 | + .and_return('= javascript_pack_tag "app", :async') |
| 448 | + allow(doctor).to receive(:relativize_path).with("app/views/layouts/application.html.slim") |
| 449 | + .and_return("app/views/layouts/application.html.slim") |
| 450 | + end |
| 451 | + |
| 452 | + it "returns files with async" do |
| 453 | + files = doctor.send(:scan_view_files_for_async_pack_tag) |
| 454 | + expect(files).to include("app/views/layouts/application.html.slim") |
| 455 | + end |
| 456 | + end |
| 457 | + |
410 | 458 | context "when javascript_pack_tag spans multiple lines" do |
411 | 459 | before do |
412 | 460 | allow(Dir).to receive(:glob).with("app/views/**/*.erb") |
413 | 461 | .and_return(["app/views/layouts/application.html.erb"]) |
414 | 462 | allow(Dir).to receive(:glob).with("app/views/**/*.haml").and_return([]) |
| 463 | + allow(Dir).to receive(:glob).with("app/views/**/*.slim").and_return([]) |
415 | 464 | allow(File).to receive(:exist?).with("app/views/layouts/application.html.erb").and_return(true) |
416 | 465 | allow(File).to receive(:read).with("app/views/layouts/application.html.erb") |
417 | 466 | .and_return("<%= javascript_pack_tag \"app\",\n :async %>") |
|
0 commit comments