Guest User

Untitled

a guest
Apr 27th, 2018
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. From 547c3a7792f01c680c8324d929537c4190b53563 Mon Sep 17 00:00:00 2001
  2. From: Luis Lavena <luislavena@gmail.com>
  3. Date: Fri, 1 Jan 2010 22:49:36 -0300
  4. Subject: [PATCH 2/3] Ensure specs use proper file reading meachanism.
  5.  
  6. ---
  7. spec/actions/file_manipulation_spec.rb | 20 ++++++++++----------
  8. 1 files changed, 10 insertions(+), 10 deletions(-)
  9.  
  10. diff --git a/spec/actions/file_manipulation_spec.rb b/spec/actions/file_manipulation_spec.rb
  11. index 0ccd71a..79632aa 100644
  12. --- a/spec/actions/file_manipulation_spec.rb
  13. +++ b/spec/actions/file_manipulation_spec.rb
  14. @@ -179,18 +179,18 @@ describe Thor::Actions do
  15. describe "#gsub_file" do
  16. it "replaces the content in the file" do
  17. action :gsub_file, "doc/README", "__start__", "START"
  18. - File.open(file).read.must == "START\nREADME\n__end__\n"
  19. + File.binread(file).must == "START\nREADME\n__end__\n"
  20. end
  21.  
  22. it "does not replace if pretending" do
  23. runner(:pretend => true)
  24. action :gsub_file, "doc/README", "__start__", "START"
  25. - File.open(file).read.must == "__start__\nREADME\n__end__\n"
  26. + File.binread(file).must == "__start__\nREADME\n__end__\n"
  27. end
  28.  
  29. it "accepts a block" do
  30. action(:gsub_file, "doc/README", "__start__"){ |match| match.gsub('__', '').upcase }
  31. - File.open(file).read.must == "START\nREADME\n__end__\n"
  32. + File.binread(file).must == "START\nREADME\n__end__\n"
  33. end
  34.  
  35. it "logs status" do
  36. @@ -205,12 +205,12 @@ describe Thor::Actions do
  37. describe "#append_file" do
  38. it "appends content to the file" do
  39. action :append_file, "doc/README", "END\n"
  40. - File.open(file).read.must == "__start__\nREADME\n__end__\nEND\n"
  41. + File.binread(file).must == "__start__\nREADME\n__end__\nEND\n"
  42. end
  43.  
  44. it "accepts a block" do
  45. action(:append_file, "doc/README"){ "END\n" }
  46. - File.open(file).read.must == "__start__\nREADME\n__end__\nEND\n"
  47. + File.binread(file).must == "__start__\nREADME\n__end__\nEND\n"
  48. end
  49.  
  50. it "logs status" do
  51. @@ -221,12 +221,12 @@ describe Thor::Actions do
  52. describe "#prepend_file" do
  53. it "prepends content to the file" do
  54. action :prepend_file, "doc/README", "START\n"
  55. - File.open(file).read.must == "START\n__start__\nREADME\n__end__\n"
  56. + File.binread(file).must == "START\n__start__\nREADME\n__end__\n"
  57. end
  58.  
  59. it "accepts a block" do
  60. action(:prepend_file, "doc/README"){ "START\n" }
  61. - File.open(file).read.must == "START\n__start__\nREADME\n__end__\n"
  62. + File.binread(file).must == "START\n__start__\nREADME\n__end__\n"
  63. end
  64.  
  65. it "logs status" do
  66. @@ -241,12 +241,12 @@ describe Thor::Actions do
  67.  
  68. it "appends content to a class" do
  69. action :inject_into_class, "application.rb", Application, " filter_parameters :password\n"
  70. - File.open(file).read.must == "class Application < Base\n filter_parameters :password\nend\n"
  71. + File.binread(file).must == "class Application < Base\n filter_parameters :password\nend\n"
  72. end
  73.  
  74. it "accepts a block" do
  75. action(:inject_into_class, "application.rb", Application){ " filter_parameters :password\n" }
  76. - File.open(file).read.must == "class Application < Base\n filter_parameters :password\nend\n"
  77. + File.binread(file).must == "class Application < Base\n filter_parameters :password\nend\n"
  78. end
  79.  
  80. it "logs status" do
  81. @@ -255,7 +255,7 @@ describe Thor::Actions do
  82.  
  83. it "does not append if class name does not match" do
  84. action :inject_into_class, "application.rb", "App", " filter_parameters :password\n"
  85. - File.open(file).read.must == "class Application < Base\nend\n"
  86. + File.binread(file).must == "class Application < Base\nend\n"
  87. end
  88. end
  89. end
  90. --
  91. 1.6.4.msysgit.0
Add Comment
Please, Sign In to add comment