Permalink
Browse files

Enhanced guard for detecting :ruby, :ruby18, :ruby19 engines.

Changed dir specs to create the fixture directories with every
run to prevent pollution of the directories from causing spurious
errors.

Added spec/core/dir/fixtures/mock to .gitignore.
  • Loading branch information...
1 parent a6b07ec commit 8535481571712cf8c35f437c42ec53dcbfd44bc0 @brixen brixen committed Dec 25, 2007
Showing with 38 additions and 21 deletions.
  1. +1 −0 .gitignore
  2. +4 −2 mspec/runner/guards.rb
  3. +33 −19 spec/core/dir/fixtures/common.rb
View
1 .gitignore
@@ -14,6 +14,7 @@ tmtags
*.rbc
.spec/bm.yml
spec/core/kernel/fixtures/load/load_spec_rba.rba
+spec/core/dir/fixtures/mock
tmp
scratch
!runtime/stable/loader.rbc
View
6 mspec/runner/guards.rb
@@ -23,9 +23,11 @@ def self.engine?(name)
when :rbx, :rubinius
RUBY_NAME =~ /^rbx/
when :ruby
- RUBY_NAME =~ /^ruby(1\.[^9])?/
+ RUBY_NAME =~ /^ruby/
+ when :ruby18
+ RUBY_NAME =~ /^ruby(1.8)?/ and RUBY_VERSION =~ /^1.8/
when :ruby19
- RUBY_NAME == 'ruby1.9'
+ RUBY_NAME =~ /^ruby(1.9)?/ and RUBY_VERSION =~ /^1.9/
when :jruby
RUBY_NAME =~ /^jruby/
else
View
52 spec/core/dir/fixtures/common.rb
@@ -1,3 +1,5 @@
+require 'fileutils'
+
module DirSpecs
def DirSpecs.mock_dir
@mock_dir ||= Dir.chdir(File.dirname(__FILE__) + '/mock') { Dir.pwd }
@@ -18,23 +20,35 @@ def DirSpecs.clear_dirs
end
end
- %w[ spec/core/dir/fixtures/mock/.dotfile
- spec/core/dir/fixtures/mock/.dotsubdir/.dotfile
- spec/core/dir/fixtures/mock/.dotsubdir/nondotfile
- spec/core/dir/fixtures/mock/deeply/.dotfile
- spec/core/dir/fixtures/mock/deeply/nested/.dotfile.ext
- spec/core/dir/fixtures/mock/deeply/nested/directory/structure/.ext
- spec/core/dir/fixtures/mock/deeply/nested/directory/structure/bar
- spec/core/dir/fixtures/mock/deeply/nested/directory/structure/baz
- spec/core/dir/fixtures/mock/deeply/nested/directory/structure/file_one
- spec/core/dir/fixtures/mock/deeply/nested/directory/structure/file_one.ext
- spec/core/dir/fixtures/mock/deeply/nested/directory/structure/foo
- spec/core/dir/fixtures/mock/deeply/nondotfile
- spec/core/dir/fixtures/mock/file_one.ext
- spec/core/dir/fixtures/mock/file_two.ext
- spec/core/dir/fixtures/mock/nondotfile
- spec/core/dir/fixtures/mock/subdir_one/.dotfile
- spec/core/dir/fixtures/mock/subdir_one/nondotfile
- spec/core/dir/fixtures/mock/subdir_two/nondotfile
- spec/core/dir/fixtures/mock/subdir_two/nondotfile.ext]
+ def DirSpecs.create_mock_dirs
+ files = %w[ spec/core/dir/fixtures/mock/.dotfile
+ spec/core/dir/fixtures/mock/.dotsubdir/.dotfile
+ spec/core/dir/fixtures/mock/.dotsubdir/nondotfile
+ spec/core/dir/fixtures/mock/deeply/.dotfile
+ spec/core/dir/fixtures/mock/deeply/nested/.dotfile.ext
+ spec/core/dir/fixtures/mock/deeply/nested/directory/structure/.ext
+ spec/core/dir/fixtures/mock/deeply/nested/directory/structure/bar
+ spec/core/dir/fixtures/mock/deeply/nested/directory/structure/baz
+ spec/core/dir/fixtures/mock/deeply/nested/directory/structure/file_one
+ spec/core/dir/fixtures/mock/deeply/nested/directory/structure/file_one.ext
+ spec/core/dir/fixtures/mock/deeply/nested/directory/structure/foo
+ spec/core/dir/fixtures/mock/deeply/nondotfile
+ spec/core/dir/fixtures/mock/file_one.ext
+ spec/core/dir/fixtures/mock/file_two.ext
+ spec/core/dir/fixtures/mock/nondotfile
+ spec/core/dir/fixtures/mock/subdir_one/.dotfile
+ spec/core/dir/fixtures/mock/subdir_one/nondotfile
+ spec/core/dir/fixtures/mock/subdir_two/nondotfile
+ spec/core/dir/fixtures/mock/subdir_two/nondotfile.ext]
+
+ FileUtils.rm_rf 'spec/core/dir/fixtures/mock/'
+ files.each do |file|
+ FileUtils.mkdir_p File.dirname(file)
+ # eventually will be FileUtils.touch(File.basename(dir))
+ File.open(file, "w") { }
+ end
+ end
end
+
+# Create the fixture directories every time the specs are run
+DirSpecs.create_mock_dirs

0 comments on commit 8535481

Please sign in to comment.