Skip to content

Commit 6124f01

Browse files
committed
fix initializing with unknown options
1 parent f8c4c7a commit 6124f01

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/thor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def stop_on_unknown_option!(*command_names)
314314
end
315315

316316
def stop_on_unknown_option?(command) #:nodoc:
317-
!!@stop_on_unknown_option && @stop_on_unknown_option.include?(command.name.to_sym)
317+
command && !@stop_on_unknown_option.nil? && @stop_on_unknown_option.include?(command.name.to_sym)
318318
end
319319

320320
protected

spec/thor_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ def boring(*args)
153153
expect(klass.stop_on_unknown_option?(mock :name => "baz")).to be_false
154154
end
155155
end
156+
157+
it "doesn't break new" do
158+
expect(my_script.new).to be_a(Thor)
159+
end
156160
end
157161

158162
describe "#map" do

0 commit comments

Comments
 (0)