thor 0.18.1 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +13 -7
  3. data/Thorfile +4 -5
  4. data/bin/thor +1 -1
  5. data/lib/thor.rb +78 -67
  6. data/lib/thor/actions.rb +57 -56
  7. data/lib/thor/actions/create_file.rb +33 -35
  8. data/lib/thor/actions/create_link.rb +2 -3
  9. data/lib/thor/actions/directory.rb +37 -38
  10. data/lib/thor/actions/empty_directory.rb +67 -69
  11. data/lib/thor/actions/file_manipulation.rb +17 -15
  12. data/lib/thor/actions/inject_into_file.rb +27 -29
  13. data/lib/thor/base.rb +193 -189
  14. data/lib/thor/command.rb +20 -23
  15. data/lib/thor/core_ext/hash_with_indifferent_access.rb +21 -24
  16. data/lib/thor/core_ext/io_binary_read.rb +2 -4
  17. data/lib/thor/core_ext/ordered_hash.rb +9 -11
  18. data/lib/thor/error.rb +5 -1
  19. data/lib/thor/group.rb +53 -54
  20. data/lib/thor/invocation.rb +44 -38
  21. data/lib/thor/line_editor.rb +17 -0
  22. data/lib/thor/line_editor/basic.rb +35 -0
  23. data/lib/thor/line_editor/readline.rb +88 -0
  24. data/lib/thor/parser.rb +4 -4
  25. data/lib/thor/parser/argument.rb +28 -29
  26. data/lib/thor/parser/arguments.rb +102 -98
  27. data/lib/thor/parser/option.rb +26 -22
  28. data/lib/thor/parser/options.rb +86 -86
  29. data/lib/thor/rake_compat.rb +9 -10
  30. data/lib/thor/runner.rb +141 -141
  31. data/lib/thor/shell.rb +27 -34
  32. data/lib/thor/shell/basic.rb +91 -63
  33. data/lib/thor/shell/color.rb +44 -43
  34. data/lib/thor/shell/html.rb +59 -60
  35. data/lib/thor/util.rb +24 -27
  36. data/lib/thor/version.rb +1 -1
  37. data/spec/actions/create_file_spec.rb +25 -27
  38. data/spec/actions/create_link_spec.rb +19 -18
  39. data/spec/actions/directory_spec.rb +31 -31
  40. data/spec/actions/empty_directory_spec.rb +18 -18
  41. data/spec/actions/file_manipulation_spec.rb +38 -28
  42. data/spec/actions/inject_into_file_spec.rb +13 -13
  43. data/spec/actions_spec.rb +43 -43
  44. data/spec/base_spec.rb +45 -38
  45. data/spec/command_spec.rb +13 -14
  46. data/spec/core_ext/hash_with_indifferent_access_spec.rb +19 -19
  47. data/spec/core_ext/ordered_hash_spec.rb +6 -6
  48. data/spec/exit_condition_spec.rb +4 -4
  49. data/spec/fixtures/invoke.thor +19 -0
  50. data/spec/fixtures/script.thor +1 -1
  51. data/spec/group_spec.rb +30 -24
  52. data/spec/helper.rb +28 -15
  53. data/spec/invocation_spec.rb +39 -19
  54. data/spec/line_editor/basic_spec.rb +28 -0
  55. data/spec/line_editor/readline_spec.rb +69 -0
  56. data/spec/line_editor_spec.rb +43 -0
  57. data/spec/parser/argument_spec.rb +12 -12
  58. data/spec/parser/arguments_spec.rb +11 -11
  59. data/spec/parser/option_spec.rb +33 -25
  60. data/spec/parser/options_spec.rb +66 -52
  61. data/spec/quality_spec.rb +75 -0
  62. data/spec/rake_compat_spec.rb +10 -10
  63. data/spec/register_spec.rb +60 -30
  64. data/spec/runner_spec.rb +67 -62
  65. data/spec/sandbox/application.rb +2 -0
  66. data/spec/sandbox/app{1}/README +3 -0
  67. data/spec/sandbox/bundle/execute.rb +6 -0
  68. data/spec/sandbox/bundle/main.thor +1 -0
  69. data/spec/sandbox/command.thor +10 -0
  70. data/spec/sandbox/doc/%file_name%.rb.tt +1 -0
  71. data/spec/sandbox/doc/COMMENTER +11 -0
  72. data/spec/sandbox/doc/README +3 -0
  73. data/spec/sandbox/doc/block_helper.rb +3 -0
  74. data/spec/sandbox/doc/config.rb +1 -0
  75. data/spec/sandbox/doc/config.yaml.tt +1 -0
  76. data/spec/sandbox/doc/excluding/%file_name%.rb.tt +1 -0
  77. data/spec/sandbox/enum.thor +10 -0
  78. data/spec/sandbox/group.thor +128 -0
  79. data/spec/sandbox/invoke.thor +131 -0
  80. data/spec/sandbox/path with spaces b/data/spec/sandbox/path with → spaces +0 -0
  81. data/spec/sandbox/preserve/script.sh +3 -0
  82. data/spec/sandbox/script.thor +220 -0
  83. data/spec/sandbox/subcommand.thor +17 -0
  84. data/spec/shell/basic_spec.rb +107 -86
  85. data/spec/shell/color_spec.rb +32 -8
  86. data/spec/shell/html_spec.rb +3 -4
  87. data/spec/shell_spec.rb +7 -7
  88. data/spec/subcommand_spec.rb +20 -2
  89. data/spec/thor_spec.rb +111 -97
  90. data/spec/util_spec.rb +30 -30
  91. data/thor.gemspec +14 -14
  92. metadata +69 -25
@@ -1,4 +1,4 @@
1
- require 'thor/shell/basic'
1
+ require "thor/shell/basic"
2
2
 
3
3
  class Thor
4
4
  module Shell
@@ -10,38 +10,38 @@ class Thor
10
10
  BOLD = "font-weight: bold"
11
11
 
12
12
  # Set the terminal's foreground HTML color to black.
13
- BLACK = 'color: black'
13
+ BLACK = "color: black"
14
14
  # Set the terminal's foreground HTML color to red.
15
- RED = 'color: red'
15
+ RED = "color: red"
16
16
  # Set the terminal's foreground HTML color to green.
17
- GREEN = 'color: green'
17
+ GREEN = "color: green"
18
18
  # Set the terminal's foreground HTML color to yellow.
19
- YELLOW = 'color: yellow'
19
+ YELLOW = "color: yellow"
20
20
  # Set the terminal's foreground HTML color to blue.
21
- BLUE = 'color: blue'
21
+ BLUE = "color: blue"
22
22
  # Set the terminal's foreground HTML color to magenta.
23
- MAGENTA = 'color: magenta'
23
+ MAGENTA = "color: magenta"
24
24
  # Set the terminal's foreground HTML color to cyan.
25
- CYAN = 'color: cyan'
25
+ CYAN = "color: cyan"
26
26
  # Set the terminal's foreground HTML color to white.
27
- WHITE = 'color: white'
27
+ WHITE = "color: white"
28
28
 
29
29
  # Set the terminal's background HTML color to black.
30
- ON_BLACK = 'background-color: black'
30
+ ON_BLACK = "background-color: black"
31
31
  # Set the terminal's background HTML color to red.
32
- ON_RED = 'background-color: red'
32
+ ON_RED = "background-color: red"
33
33
  # Set the terminal's background HTML color to green.
34
- ON_GREEN = 'background-color: green'
34
+ ON_GREEN = "background-color: green"
35
35
  # Set the terminal's background HTML color to yellow.
36
- ON_YELLOW = 'background-color: yellow'
36
+ ON_YELLOW = "background-color: yellow"
37
37
  # Set the terminal's background HTML color to blue.
38
- ON_BLUE = 'background-color: blue'
38
+ ON_BLUE = "background-color: blue"
39
39
  # Set the terminal's background HTML color to magenta.
40
- ON_MAGENTA = 'background-color: magenta'
40
+ ON_MAGENTA = "background-color: magenta"
41
41
  # Set the terminal's background HTML color to cyan.
42
- ON_CYAN = 'background-color: cyan'
42
+ ON_CYAN = "background-color: cyan"
43
43
  # Set the terminal's background HTML color to white.
44
- ON_WHITE = 'background-color: white'
44
+ ON_WHITE = "background-color: white"
45
45
 
46
46
  # Set color by using a string or one of the defined constants. If a third
47
47
  # option is set to true, it also adds bold to the string. This is based
@@ -67,61 +67,60 @@ class Thor
67
67
  # ask("What is your name?")
68
68
  #
69
69
  # TODO: Implement #ask for Thor::Shell::HTML
70
- def ask(statement, color=nil)
71
- raise NotImplementedError, "Implement #ask for Thor::Shell::HTML"
70
+ def ask(statement, color = nil)
71
+ fail NotImplementedError, "Implement #ask for Thor::Shell::HTML"
72
72
  end
73
73
 
74
- protected
74
+ protected
75
75
 
76
- def can_display_colors?
77
- true
78
- end
76
+ def can_display_colors?
77
+ true
78
+ end
79
79
 
80
- # Overwrite show_diff to show diff with colors if Diff::LCS is
81
- # available.
82
- #
83
- def show_diff(destination, content) #:nodoc:
84
- if diff_lcs_loaded? && ENV['THOR_DIFF'].nil? && ENV['RAILS_DIFF'].nil?
85
- actual = File.binread(destination).to_s.split("\n")
86
- content = content.to_s.split("\n")
80
+ # Overwrite show_diff to show diff with colors if Diff::LCS is
81
+ # available.
82
+ #
83
+ def show_diff(destination, content) #:nodoc:
84
+ if diff_lcs_loaded? && ENV["THOR_DIFF"].nil? && ENV["RAILS_DIFF"].nil?
85
+ actual = File.binread(destination).to_s.split("\n")
86
+ content = content.to_s.split("\n")
87
87
 
88
- Diff::LCS.sdiff(actual, content).each do |diff|
89
- output_diff_line(diff)
90
- end
91
- else
92
- super
88
+ Diff::LCS.sdiff(actual, content).each do |diff|
89
+ output_diff_line(diff)
93
90
  end
91
+ else
92
+ super
94
93
  end
94
+ end
95
95
 
96
- def output_diff_line(diff) #:nodoc:
97
- case diff.action
98
- when '-'
99
- say "- #{diff.old_element.chomp}", :red, true
100
- when '+'
101
- say "+ #{diff.new_element.chomp}", :green, true
102
- when '!'
103
- say "- #{diff.old_element.chomp}", :red, true
104
- say "+ #{diff.new_element.chomp}", :green, true
105
- else
106
- say " #{diff.old_element.chomp}", nil, true
107
- end
96
+ def output_diff_line(diff) #:nodoc:
97
+ case diff.action
98
+ when "-"
99
+ say "- #{diff.old_element.chomp}", :red, true
100
+ when "+"
101
+ say "+ #{diff.new_element.chomp}", :green, true
102
+ when "!"
103
+ say "- #{diff.old_element.chomp}", :red, true
104
+ say "+ #{diff.new_element.chomp}", :green, true
105
+ else
106
+ say " #{diff.old_element.chomp}", nil, true
108
107
  end
108
+ end
109
109
 
110
- # Check if Diff::LCS is loaded. If it is, use it to create pretty output
111
- # for diff.
112
- #
113
- def diff_lcs_loaded? #:nodoc:
114
- return true if defined?(Diff::LCS)
115
- return @diff_lcs_loaded unless @diff_lcs_loaded.nil?
110
+ # Check if Diff::LCS is loaded. If it is, use it to create pretty output
111
+ # for diff.
112
+ #
113
+ def diff_lcs_loaded? #:nodoc:
114
+ return true if defined?(Diff::LCS)
115
+ return @diff_lcs_loaded unless @diff_lcs_loaded.nil?
116
116
 
117
- @diff_lcs_loaded = begin
118
- require 'diff/lcs'
119
- true
120
- rescue LoadError
121
- false
122
- end
117
+ @diff_lcs_loaded = begin
118
+ require "diff/lcs"
119
+ true
120
+ rescue LoadError
121
+ false
123
122
  end
124
-
123
+ end
125
124
  end
126
125
  end
127
126
  end
@@ -1,4 +1,4 @@
1
- require 'rbconfig'
1
+ require "rbconfig"
2
2
 
3
3
  class Thor
4
4
  module Sandbox #:nodoc:
@@ -15,9 +15,7 @@ class Thor
15
15
  # Thor::Util.load_thorfile("~/.thor/foo")
16
16
  #
17
17
  module Util
18
-
19
18
  class << self
20
-
21
19
  # Receives a namespace and search for it in the Thor::Base subclasses.
22
20
  #
23
21
  # ==== Parameters
@@ -25,7 +23,7 @@ class Thor
25
23
  #
26
24
  def find_by_namespace(namespace)
27
25
  namespace = "default#{namespace}" if namespace.empty? || namespace =~ /^:/
28
- Thor::Base.subclasses.find { |klass| klass.namespace == namespace }
26
+ Thor::Base.subclasses.detect { |klass| klass.namespace == namespace }
29
27
  end
30
28
 
31
29
  # Receives a constant and converts it to a Thor namespace. Since Thor
@@ -57,7 +55,7 @@ class Thor
57
55
  # ==== Returns
58
56
  # Array[Object]
59
57
  #
60
- def namespaces_in_content(contents, file=__FILE__)
58
+ def namespaces_in_content(contents, file = __FILE__)
61
59
  old_constants = Thor::Base.subclasses.dup
62
60
  Thor::Base.subclasses.clear
63
61
 
@@ -66,7 +64,7 @@ class Thor
66
64
  new_constants = Thor::Base.subclasses.dup
67
65
  Thor::Base.subclasses.replace(old_constants)
68
66
 
69
- new_constants.map!{ |c| c.namespace }
67
+ new_constants.map! { |c| c.namespace }
70
68
  new_constants.compact!
71
69
  new_constants
72
70
  end
@@ -77,7 +75,7 @@ class Thor
77
75
  stringfied_constants = klass.constants.map { |c| c.to_s }
78
76
  Thor::Base.subclasses.select do |subclass|
79
77
  next unless subclass.name
80
- stringfied_constants.include?(subclass.name.gsub("#{klass.name}::", ''))
78
+ stringfied_constants.include?(subclass.name.gsub("#{klass.name}::", ""))
81
79
  end
82
80
  end
83
81
 
@@ -91,8 +89,8 @@ class Thor
91
89
  #
92
90
  def snake_case(str)
93
91
  return str.downcase if str =~ /^[A-Z_]+$/
94
- str.gsub(/\B[A-Z]/, '_\&').squeeze('_') =~ /_*(.*)/
95
- return $+.downcase
92
+ str.gsub(/\B[A-Z]/, '_\&').squeeze("_") =~ /_*(.*)/
93
+ $+.downcase
96
94
  end
97
95
 
98
96
  # Receives a string and convert it to camel case. camel_case returns CamelCase.
@@ -105,7 +103,7 @@ class Thor
105
103
  #
106
104
  def camel_case(str)
107
105
  return str if str !~ /_/ && str =~ /[A-Z]+.*/
108
- str.split('_').map { |i| i.capitalize }.join
106
+ str.split("_").map { |i| i.capitalize }.join
109
107
  end
110
108
 
111
109
  # Receives a namespace and tries to retrieve a Thor or Thor::Group class
@@ -131,7 +129,7 @@ class Thor
131
129
  # namespace<String>
132
130
  #
133
131
  def find_class_and_command_by_namespace(namespace, fallback = true)
134
- if namespace.include?(?:) # look for a namespaced command
132
+ if namespace.include?(":") # look for a namespaced command
135
133
  pieces = namespace.split(":")
136
134
  command = pieces.pop
137
135
  klass = Thor::Util.find_by_namespace(pieces.join(":"))
@@ -141,21 +139,21 @@ class Thor
141
139
  end
142
140
  if !klass && fallback # try a command in the default namespace
143
141
  command = namespace
144
- klass = Thor::Util.find_by_namespace('')
142
+ klass = Thor::Util.find_by_namespace("")
145
143
  end
146
- return klass, command
144
+ [klass, command]
147
145
  end
148
- alias find_class_and_task_by_namespace find_class_and_command_by_namespace
146
+ alias_method :find_class_and_task_by_namespace, :find_class_and_command_by_namespace
149
147
 
150
148
  # Receives a path and load the thor file in the path. The file is evaluated
151
149
  # inside the sandbox to avoid namespacing conflicts.
152
150
  #
153
- def load_thorfile(path, content=nil, debug=false)
151
+ def load_thorfile(path, content = nil, debug = false)
154
152
  content ||= File.binread(path)
155
153
 
156
154
  begin
157
155
  Thor::Sandbox.class_eval(content, path)
158
- rescue Exception => e
156
+ rescue StandardError => e
159
157
  $stderr.puts("WARNING: unable to load thorfile #{path.inspect}: #{e.message}")
160
158
  if debug
161
159
  $stderr.puts(*e.backtrace)
@@ -165,7 +163,7 @@ class Thor
165
163
  end
166
164
  end
167
165
 
168
- def user_home
166
+ def user_home # rubocop:disable MethodLength
169
167
  @@user_home ||= if ENV["HOME"]
170
168
  ENV["HOME"]
171
169
  elsif ENV["USERPROFILE"]
@@ -190,7 +188,7 @@ class Thor
190
188
  # Returns the root where thor files are located, depending on the OS.
191
189
  #
192
190
  def thor_root
193
- File.join(user_home, ".thor").gsub(/\\/, '/')
191
+ File.join(user_home, ".thor").gsub(/\\/, "/")
194
192
  end
195
193
 
196
194
  # Returns the files in the thor root. On Windows thor_root will be something
@@ -218,17 +216,17 @@ class Thor
218
216
  # Return the path to the ruby interpreter taking into account multiple
219
217
  # installations and windows extensions.
220
218
  #
221
- def ruby_command
219
+ def ruby_command # rubocop:disable MethodLength
222
220
  @ruby_command ||= begin
223
- ruby_name = RbConfig::CONFIG['ruby_install_name']
224
- ruby = File.join(RbConfig::CONFIG['bindir'], ruby_name)
225
- ruby << RbConfig::CONFIG['EXEEXT']
221
+ ruby_name = RbConfig::CONFIG["ruby_install_name"]
222
+ ruby = File.join(RbConfig::CONFIG["bindir"], ruby_name)
223
+ ruby << RbConfig::CONFIG["EXEEXT"]
226
224
 
227
225
  # avoid using different name than ruby (on platforms supporting links)
228
- if ruby_name != 'ruby' && File.respond_to?(:readlink)
226
+ if ruby_name != "ruby" && File.respond_to?(:readlink)
229
227
  begin
230
- alternate_ruby = File.join(RbConfig::CONFIG['bindir'], 'ruby')
231
- alternate_ruby << RbConfig::CONFIG['EXEEXT']
228
+ alternate_ruby = File.join(RbConfig::CONFIG["bindir"], "ruby")
229
+ alternate_ruby << RbConfig::CONFIG["EXEEXT"]
232
230
 
233
231
  # ruby is a symlink
234
232
  if File.symlink? alternate_ruby
@@ -237,7 +235,7 @@ class Thor
237
235
  # symlink points to 'ruby_install_name'
238
236
  ruby = alternate_ruby if linked_ruby == ruby_name || linked_ruby == ruby
239
237
  end
240
- rescue NotImplementedError
238
+ rescue NotImplementedError # rubocop:disable HandleExceptions
241
239
  # just ignore on windows
242
240
  end
243
241
  end
@@ -264,7 +262,6 @@ class Thor
264
262
  def escape_globs(path)
265
263
  path.to_s.gsub(/[*?{}\[\]]/, '\\\\\\&')
266
264
  end
267
-
268
265
  end
269
266
  end
270
267
  end
@@ -1,3 +1,3 @@
1
1
  class Thor
2
- VERSION = "0.18.1"
2
+ VERSION = "0.19.0"
3
3
  end
@@ -1,17 +1,17 @@
1
- require 'helper'
2
- require 'thor/actions'
1
+ require "helper"
2
+ require "thor/actions"
3
3
 
4
4
  describe Thor::Actions::CreateFile do
5
5
  before do
6
+ @silence = false
6
7
  ::FileUtils.rm_rf(destination_root)
7
8
  end
8
9
 
9
- def create_file(destination=nil, config={}, options={})
10
- @base = MyCounter.new([1, 2], options, { :destination_root => destination_root })
11
- @base.stub!(:file_name).and_return('rdoc')
10
+ def create_file(destination = nil, config = {}, options = {})
11
+ @base = MyCounter.new([1, 2], options, :destination_root => destination_root)
12
+ allow(@base).to receive(:file_name).and_return("rdoc")
12
13
 
13
- @action = Thor::Actions::CreateFile.new(@base, destination, "CONFIGURATION",
14
- { :verbose => !@silence }.merge(config))
14
+ @action = Thor::Actions::CreateFile.new(@base, destination, "CONFIGURATION", {:verbose => !@silence}.merge(config))
15
15
  end
16
16
 
17
17
  def invoke!
@@ -30,13 +30,13 @@ describe Thor::Actions::CreateFile do
30
30
  it "creates a file" do
31
31
  create_file("doc/config.rb")
32
32
  invoke!
33
- expect(File.exists?(File.join(destination_root, "doc/config.rb"))).to be_true
33
+ expect(File.exist?(File.join(destination_root, "doc/config.rb"))).to be true
34
34
  end
35
35
 
36
36
  it "does not create a file if pretending" do
37
37
  create_file("doc/config.rb", {}, :pretend => true)
38
38
  invoke!
39
- expect(File.exists?(File.join(destination_root, "doc/config.rb"))).to be_false
39
+ expect(File.exist?(File.join(destination_root, "doc/config.rb"))).to be false
40
40
  end
41
41
 
42
42
  it "shows created status to the user" do
@@ -59,7 +59,7 @@ describe Thor::Actions::CreateFile do
59
59
  it "converts encoded instructions" do
60
60
  create_file("doc/%file_name%.rb.tt")
61
61
  invoke!
62
- expect(File.exists?(File.join(destination_root, "doc/rdoc.rb.tt"))).to be_true
62
+ expect(File.exist?(File.join(destination_root, "doc/rdoc.rb.tt"))).to be true
63
63
  end
64
64
 
65
65
  describe "when file exists" do
@@ -78,7 +78,7 @@ describe Thor::Actions::CreateFile do
78
78
 
79
79
  describe "and is not identical" do
80
80
  before do
81
- File.open(File.join(destination_root, 'doc/config.rb'), 'w'){ |f| f.write("FOO = 3") }
81
+ File.open(File.join(destination_root, "doc/config.rb"), "w") { |f| f.write("FOO = 3") }
82
82
  end
83
83
 
84
84
  it "shows forced status to the user if force is given" do
@@ -101,34 +101,32 @@ describe Thor::Actions::CreateFile do
101
101
  expect(invoke!).to eq(" skip doc/config.rb\n")
102
102
  end
103
103
 
104
- it "shows conflict status to ther user" do
104
+ it "shows conflict status to the user" do
105
+ file = File.join(destination_root, "doc/config.rb")
105
106
  expect(create_file("doc/config.rb")).not_to be_identical
106
- $stdin.should_receive(:gets).and_return('s')
107
- file = File.join(destination_root, 'doc/config.rb')
107
+ expect(Thor::LineEditor).to receive(:readline).with("Overwrite #{file}? (enter \"h\" for help) [Ynaqdh] ", anything).and_return("s")
108
108
 
109
109
  content = invoke!
110
110
  expect(content).to match(/conflict doc\/config\.rb/)
111
- expect(content).to match(/Overwrite #{file}\? \(enter "h" for help\) \[Ynaqdh\]/)
112
111
  expect(content).to match(/skip doc\/config\.rb/)
113
112
  end
114
113
 
115
114
  it "creates the file if the file collision menu returns true" do
116
115
  create_file("doc/config.rb")
117
- $stdin.should_receive(:gets).and_return('y')
116
+ expect(Thor::LineEditor).to receive(:readline).and_return("y")
118
117
  expect(invoke!).to match(/force doc\/config\.rb/)
119
118
  end
120
119
 
121
120
  it "skips the file if the file collision menu returns false" do
122
121
  create_file("doc/config.rb")
123
- $stdin.should_receive(:gets).and_return('n')
122
+ expect(Thor::LineEditor).to receive(:readline).and_return("n")
124
123
  expect(invoke!).to match(/skip doc\/config\.rb/)
125
124
  end
126
125
 
127
126
  it "executes the block given to show file content" do
128
127
  create_file("doc/config.rb")
129
- $stdin.should_receive(:gets).and_return('d')
130
- $stdin.should_receive(:gets).and_return('n')
131
- @base.shell.should_receive(:system).with(/diff -u/)
128
+ expect(Thor::LineEditor).to receive(:readline).and_return("d", "n")
129
+ expect(@base.shell).to receive(:system).with(/diff -u/)
132
130
  invoke!
133
131
  end
134
132
  end
@@ -140,31 +138,31 @@ describe Thor::Actions::CreateFile do
140
138
  create_file("doc/config.rb")
141
139
  invoke!
142
140
  revoke!
143
- expect(File.exists?(@action.destination)).to be_false
141
+ expect(File.exist?(@action.destination)).to be false
144
142
  end
145
143
 
146
144
  it "does not raise an error if the file does not exist" do
147
145
  create_file("doc/config.rb")
148
146
  revoke!
149
- expect(File.exists?(@action.destination)).to be_false
147
+ expect(File.exist?(@action.destination)).to be false
150
148
  end
151
149
  end
152
150
 
153
151
  describe "#exists?" do
154
152
  it "returns true if the destination file exists" do
155
153
  create_file("doc/config.rb")
156
- expect(@action.exists?).to be_false
154
+ expect(@action.exists?).to be false
157
155
  invoke!
158
- expect(@action.exists?).to be_true
156
+ expect(@action.exists?).to be true
159
157
  end
160
158
  end
161
159
 
162
160
  describe "#identical?" do
163
- it "returns true if the destination file and is identical" do
161
+ it "returns true if the destination file exists and is identical" do
164
162
  create_file("doc/config.rb")
165
- expect(@action.identical?).to be_false
163
+ expect(@action.identical?).to be false
166
164
  invoke!
167
- expect(@action.identical?).to be_true
165
+ expect(@action.identical?).to be true
168
166
  end
169
167
  end
170
168
  end