Skip to content

Commit b3dc948

Browse files
authored
Merge pull request #713 from pvdb/simplify_standard_system_dir
Dedupe and simplify `standard_system_dir`
2 parents 4c01004 + 496e60d commit b3dc948

2 files changed

Lines changed: 41 additions & 5 deletions

File tree

lib/rake/application.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -754,12 +754,10 @@ def system_dir # :nodoc:
754754
end
755755

756756
# The standard directory containing system wide rake files.
757-
if Win32.windows?
758-
def standard_system_dir #:nodoc:
757+
def standard_system_dir #:nodoc:
758+
if windows?
759759
File.join(Dir.home, "Rake")
760-
end
761-
else
762-
def standard_system_dir #:nodoc:
760+
else
763761
File.join(Dir.home, ".rake")
764762
end
765763
end

test/test_rake_application.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,44 @@ def @app.standard_system_dir
365365
flunk "failed to find system rakefile"
366366
end
367367

368+
def test_load_from_calculated_system_rakefile_on_windows
369+
rakefile_default
370+
def @app.windows?
371+
true
372+
end
373+
374+
@app.instance_eval do
375+
handle_options []
376+
options.silent = true
377+
options.load_system = true
378+
options.rakelib = []
379+
load_rakefile
380+
end
381+
382+
assert_equal File.join(Dir.home, "Rake"), @app.system_dir
383+
rescue SystemExit
384+
flunk "failed to find system rakefile"
385+
end
386+
387+
def test_load_from_calculated_system_rakefile_on_unix
388+
rakefile_default
389+
def @app.windows?
390+
false
391+
end
392+
393+
@app.instance_eval do
394+
handle_options []
395+
options.silent = true
396+
options.load_system = true
397+
options.rakelib = []
398+
load_rakefile
399+
end
400+
401+
assert_equal File.join(Dir.home, ".rake"), @app.system_dir
402+
rescue SystemExit
403+
flunk "failed to find system rakefile"
404+
end
405+
368406
def test_terminal_columns
369407
old_rake_columns = ENV["RAKE_COLUMNS"]
370408

0 commit comments

Comments
 (0)