Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 4 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Showing with 18 additions and 9 deletions.
  1. +5 −0 Changelog.md
  2. +6 −0 lib/rspec/core.rb
  3. +5 −7 lib/rspec/core/configuration.rb
  4. +2 −2 spec/rspec/core/configuration_spec.rb
View
5 Changelog.md
@@ -13,6 +13,11 @@ Enhancements
* thanks to Bradley Schaefer for suggesting it and Avdi Grimm for almost
suggesting it.
+Bug fixes
+
+* Support alternative path separators. For example, on Windows, you can now do
+ this: `rspec spec\subdir`. (Jarmo Pertman @jarmo)
+
### 2.10.1 / 2012-05-19
[full changelog](http://github.com/rspec/rspec-core/compare/v2.10.0...v2.10.1)
View
6 lib/rspec/core.rb
@@ -11,6 +11,7 @@ def require_rspec(path)
end
require 'set'
+require 'rbconfig'
require_rspec 'core/filter_manager'
require_rspec 'core/dsl'
require_rspec 'core/extensions'
@@ -100,6 +101,11 @@ def self.clear_remaining_example_groups
world.example_groups.clear
end
+ # @private
+ def self.windows_os?
+ /mswin|mingw/ === ::RbConfig::CONFIG['host_os']
+ end
+
module Core
end
end
View
12 lib/rspec/core/configuration.rb
@@ -1,4 +1,3 @@
-require "rbconfig"
require 'fileutils'
module RSpec
@@ -412,10 +411,9 @@ def color
end
def color=(bool)
- return unless bool
- @color = true
- if bool && ::RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
- unless ENV['ANSICON']
+ if bool
+ @color = true
+ if RSpec.windows_os? and not ENV['ANSICON']
warn "You must use ANSICON 1.31 or later (http://adoxa.110mb.com/ansicon/) to use colour on Windows"
@color = false
end
@@ -465,7 +463,7 @@ def line_numbers=(line_numbers)
def full_description=(description)
filter_run :full_description => Regexp.union(*Array(description).map {|d| Regexp.new(d) })
end
-
+
# @overload add_formatter(formatter)
#
# Adds a formatter to the formatters collection. `formatter` can be a
@@ -806,7 +804,7 @@ def randomize?
def get_files_to_run(paths)
patterns = pattern.split(",")
paths.map do |path|
- path = path.gsub(File::ALT_SEPARATOR, File::SEPARATOR)
+ path = path.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
File.directory?(path) ? gather_directories(path, patterns) : extract_location(path)
end.flatten
end
View
4 spec/rspec/core/configuration_spec.rb
@@ -296,12 +296,12 @@ module RSpec::Core
config.files_to_run.should eq([ "spec/rspec/core/resources/a_spec.rb"])
end
- it "loads files in Windows" do
+ it "loads files in Windows", :if => RSpec.windows_os? do
config.files_or_directories_to_run = "C:\\path\\to\\project\\spec\\sub\\foo_spec.rb"
config.files_to_run.should eq([ "C:/path/to/project/spec/sub/foo_spec.rb"])
end
- it "loads files in Windows when directory is specified" do
+ it "loads files in Windows when directory is specified", :if => RSpec.windows_os? do
config.files_or_directories_to_run = "spec\\rspec\\core\\resources"
config.files_to_run.should eq([ "spec/rspec/core/resources/a_spec.rb"])
end

No commit comments for this range

Something went wrong with that request. Please try again.