From 22441de0983918a22f305a5e5f8446cab1c363f3 Mon Sep 17 00:00:00 2001 From: Myron Marston Date: Thu, 4 Sep 2014 19:25:53 -0700 Subject: [PATCH 1/8] Update maintenance branch file. --- maintenance-branch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maintenance-branch b/maintenance-branch index 8b25206ff..a922f886c 100644 --- a/maintenance-branch +++ b/maintenance-branch @@ -1 +1 @@ -master \ No newline at end of file +3-1-maintenance From e1debddd19e45880b242e6fab3263d746aff2104 Mon Sep 17 00:00:00 2001 From: Scott Archer Date: Sun, 7 Sep 2014 14:36:35 -0500 Subject: [PATCH 2/8] Fixed a bug related to making a directory structure on windows --- lib/rspec/support/directory_maker.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/rspec/support/directory_maker.rb b/lib/rspec/support/directory_maker.rb index f65f60eba..e45081eec 100644 --- a/lib/rspec/support/directory_maker.rb +++ b/lib/rspec/support/directory_maker.rb @@ -9,10 +9,9 @@ class DirectoryMaker # # Implements nested directory construction def self.mkdir_p(path) - stack = path.start_with?(File::SEPARATOR) ? File::SEPARATOR : "." + stack = generate_stack(path) path.split(File::SEPARATOR).each do |part| stack = File.join(stack, part) - begin Dir.mkdir(stack) unless directory_exists?(stack) rescue Errno::ENOTDIR => e @@ -20,11 +19,20 @@ def self.mkdir_p(path) end end end - + if RUBY_PLATFORM =~ /mswin|mingw/ + def self.generate_stack(path) + (path.start_with?(File::SEPARATOR) || path[1] == ':') ? '' : '.' + end + else + def self.generate_stack(path) + path.start_with?(File::SEPARATOR) ? File::SEPARATOR : "." + end + end def self.directory_exists?(dirname) File.exist?(dirname) && File.directory?(dirname) end private_class_method :directory_exists? + private_class_method :generate_stack end end end From d5e5159b9d60b5eb68480e0abcd26c3f6e92b6b4 Mon Sep 17 00:00:00 2001 From: Myron Marston Date: Sun, 7 Sep 2014 19:43:36 -0700 Subject: [PATCH 3/8] Changelog for #108. [ci skip] --- Changelog.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Changelog.md b/Changelog.md index fe1107a5b..4a5660895 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,12 @@ +### 3.1.1 Development +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.1.0...3-1-maintenance) + +Bug Fixes: + +* Fix `RSpec::Support::DirectoryMaker` (used by `rspec --init` and + `rails generate rspec:install`) so that it detects absolute paths + on Windows properly. (Scott Archer, #108) + ### 3.1.0 / 2014-09-04 [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.0.4...v3.1.0) From 3b9e832786684e3c1f2f3d524f2336d948f0f0b5 Mon Sep 17 00:00:00 2001 From: Scott Archer Date: Mon, 8 Sep 2014 00:09:18 -0500 Subject: [PATCH 4/8] Updated DirectoryMaker to properly generate and create directories on windows --- lib/rspec/support/directory_maker.rb | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/rspec/support/directory_maker.rb b/lib/rspec/support/directory_maker.rb index e45081eec..c068dd77e 100644 --- a/lib/rspec/support/directory_maker.rb +++ b/lib/rspec/support/directory_maker.rb @@ -11,7 +11,7 @@ class DirectoryMaker def self.mkdir_p(path) stack = generate_stack(path) path.split(File::SEPARATOR).each do |part| - stack = File.join(stack, part) + stack = generate_path(stack, part) begin Dir.mkdir(stack) unless directory_exists?(stack) rescue Errno::ENOTDIR => e @@ -19,20 +19,39 @@ def self.mkdir_p(path) end end end - if RUBY_PLATFORM =~ /mswin|mingw/ + if RUBY_PLATFORM =~ /mswin|mingw|java/ def self.generate_stack(path) - (path.start_with?(File::SEPARATOR) || path[1] == ':') ? '' : '.' + if path.start_with?(File::SEPARATOR) + File::SEPARATOR + elsif path[1] == ':' + '' + else + '.' + end + end + def self.generate_path(stack, part) + if stack == '' + part + elsif stack == File::SEPARATOR + File.join('', part) + else + File.join(stack, part) + end end else def self.generate_stack(path) path.start_with?(File::SEPARATOR) ? File::SEPARATOR : "." end + def self.generate_path(stack, part) + File.join(stack, part) + end end def self.directory_exists?(dirname) File.exist?(dirname) && File.directory?(dirname) end private_class_method :directory_exists? private_class_method :generate_stack + private_class_method :generate_path end end end From ef74031de8765f19291be594e9e5e35cdec01702 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Mon, 22 Sep 2014 16:27:47 +1000 Subject: [PATCH 5/8] Merge pull request #110 from rspec/os_support Add support for os specific feature detection Conflicts: lib/rspec/support/directory_maker.rb --- lib/rspec/support/directory_maker.rb | 6 ++++- lib/rspec/support/os.rb | 18 ++++++++++++++ spec/rspec/support/os_spec.rb | 36 ++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 lib/rspec/support/os.rb create mode 100644 spec/rspec/support/os_spec.rb diff --git a/lib/rspec/support/directory_maker.rb b/lib/rspec/support/directory_maker.rb index c068dd77e..c4d5ad254 100644 --- a/lib/rspec/support/directory_maker.rb +++ b/lib/rspec/support/directory_maker.rb @@ -1,3 +1,5 @@ +RSpec::Support.require_rspec_support 'os' + module RSpec module Support # @api private @@ -19,7 +21,8 @@ def self.mkdir_p(path) end end end - if RUBY_PLATFORM =~ /mswin|mingw|java/ + + if OS.windows_file_path? def self.generate_stack(path) if path.start_with?(File::SEPARATOR) File::SEPARATOR @@ -46,6 +49,7 @@ def self.generate_path(stack, part) File.join(stack, part) end end + def self.directory_exists?(dirname) File.exist?(dirname) && File.directory?(dirname) end diff --git a/lib/rspec/support/os.rb b/lib/rspec/support/os.rb new file mode 100644 index 000000000..c17542ad1 --- /dev/null +++ b/lib/rspec/support/os.rb @@ -0,0 +1,18 @@ +module RSpec + module Support + # @api private + # + # Provides query methods for different OS or OS features. + module OS + def windows? + RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/ + end + module_function :windows? + + def windows_file_path? + ::File::ALT_SEPARATOR == ":" + end + module_function :windows_file_path? + end + end +end diff --git a/spec/rspec/support/os_spec.rb b/spec/rspec/support/os_spec.rb new file mode 100644 index 000000000..1043ae4fb --- /dev/null +++ b/spec/rspec/support/os_spec.rb @@ -0,0 +1,36 @@ +require 'rspec/support/os' + +module RSpec + module Support + describe OS do + + describe ".windows?" do + %w[cygwin mswin mingw bccwin wince emx].each do |fragment| + it "returns true when host os is #{fragment}" do + stub_const("RbConfig::CONFIG", 'host_os' => fragment) + expect(OS).to be_windows + end + end + + %w[darwin linux].each do |fragment| + it "returns false when host os is #{fragment}" do + stub_const("RbConfig::CONFIG", 'host_os' => fragment) + expect(OS).to_not be_windows + end + end + end + + describe ".windows_file_path?" do + it "returns true when the file alt seperator is a colon" do + stub_const("File::ALT_SEPARATOR", ":") unless OS.windows? + expect(OS).to be_windows_file_path + end + + it "returns false when file alt seperator is not present" do + stub_const("File::ALT_SEPARATOR", nil) if OS.windows? + expect(OS).to_not be_windows_file_path + end + end + end + end +end From fec948375b072ab978069e1bf82f27eda655788e Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 23 Sep 2014 15:32:26 +1000 Subject: [PATCH 6/8] Merge pull request #113 from rspec/correct_alt_seperator use correct alt seperator --- lib/rspec/support/os.rb | 2 +- spec/rspec/support/os_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rspec/support/os.rb b/lib/rspec/support/os.rb index c17542ad1..82f53f1cc 100644 --- a/lib/rspec/support/os.rb +++ b/lib/rspec/support/os.rb @@ -10,7 +10,7 @@ def windows? module_function :windows? def windows_file_path? - ::File::ALT_SEPARATOR == ":" + ::File::ALT_SEPARATOR == '\\' end module_function :windows_file_path? end diff --git a/spec/rspec/support/os_spec.rb b/spec/rspec/support/os_spec.rb index 1043ae4fb..ad76055f6 100644 --- a/spec/rspec/support/os_spec.rb +++ b/spec/rspec/support/os_spec.rb @@ -22,7 +22,7 @@ module Support describe ".windows_file_path?" do it "returns true when the file alt seperator is a colon" do - stub_const("File::ALT_SEPARATOR", ":") unless OS.windows? + stub_const("File::ALT_SEPARATOR", "\\") unless OS.windows? expect(OS).to be_windows_file_path end From 009572cc38f8658c54fc91aac5e085bfd6a606a9 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Fri, 26 Sep 2014 17:20:44 +1000 Subject: [PATCH 7/8] changelog fixup [skip ci] --- Changelog.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Changelog.md b/Changelog.md index 4a5660895..984eae1e5 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,9 +3,9 @@ Bug Fixes: -* Fix `RSpec::Support::DirectoryMaker` (used by `rspec --init` and - `rails generate rspec:install`) so that it detects absolute paths - on Windows properly. (Scott Archer, #108) +* Fix `RSpec::Support::DirectoryMaker` (used by `rspec --init` and │ + `rails generate rspec:install`) so that it detects absolute paths │ use correct alt seperator + on Windows properly. (Scott Archer, #107, #108, #109) (Jon Rowe, #110) ### 3.1.0 / 2014-09-04 [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.0.4...v3.1.0) From 9e86d06c47798c2d6c5499af62b6be57d0e6d158 Mon Sep 17 00:00:00 2001 From: Myron Marston Date: Fri, 26 Sep 2014 09:42:37 -0700 Subject: [PATCH 8/8] Release 3.1.1. --- Changelog.md | 8 ++++---- lib/rspec/support/version.rb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Changelog.md b/Changelog.md index 984eae1e5..066ace019 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,10 +1,10 @@ -### 3.1.1 Development -[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.1.0...3-1-maintenance) +### 3.1.1 / 2014-09-26 +[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.1.0...v3.1.1) Bug Fixes: -* Fix `RSpec::Support::DirectoryMaker` (used by `rspec --init` and │ - `rails generate rspec:install`) so that it detects absolute paths │ use correct alt seperator +* Fix `RSpec::Support::DirectoryMaker` (used by `rspec --init` and + `rails generate rspec:install`) so that it detects absolute paths on Windows properly. (Scott Archer, #107, #108, #109) (Jon Rowe, #110) ### 3.1.0 / 2014-09-04 diff --git a/lib/rspec/support/version.rb b/lib/rspec/support/version.rb index 6b106b675..39a5b622d 100644 --- a/lib/rspec/support/version.rb +++ b/lib/rspec/support/version.rb @@ -1,7 +1,7 @@ module RSpec module Support module Version - STRING = '3.1.0' + STRING = '3.1.1' end end end