Skip to content
Browse files

Remove the tmp_dir before each spec run to avoid inconsistent runs

  • Loading branch information...
1 parent 247eb7c commit 8979215c22a60ed66d6f91b68d821bbf078f13dc @halorgium halorgium committed with Carl Lerche
View
12 spec/bundler/cli_spec.rb
@@ -2,9 +2,7 @@
describe "Bundler::CLI" do
describe "it working" do
- before(:all) do
- reset!
-
+ before(:each) do
build_manifest <<-Gemfile
sources.clear
source "file://#{gem_repo1}"
@@ -64,9 +62,7 @@
end
describe "it working without rubygems" do
- before(:all) do
- reset!
-
+ before(:each) do
build_manifest <<-Gemfile
sources.clear
source "file://#{gem_repo1}"
@@ -102,9 +98,7 @@
end
describe "it working with requiring rubygems automatically" do
- before(:all) do
- reset!
-
+ before(:each) do
build_manifest <<-Gemfile
sources.clear
source "file://#{gem_repo1}"
View
13 spec/bundler/dsl_spec.rb
@@ -2,10 +2,6 @@
describe "Bundling DSL" do
- before(:all) do
- reset!
- end
-
it "allows specifying the path to bundle gems to" do
build_manifest.gem_path.should == tmp_file("vendor", "gems")
end
@@ -60,13 +56,10 @@
end
it "loads the manifest from a file" do
- File.open(tmp_file("manifest.rb"), 'w') do |file|
- file.puts <<-DSL
- gem "rails"
- DSL
- end
+ manifest = build_manifest(tmp_file("manifest.rb"), <<-DSL)
+ gem "rails"
+ DSL
- manifest = Bundler::ManifestFile.load(tmp_file("manifest.rb"))
manifest.dependencies.first.name.should == "rails"
end
View
2 spec/bundler/finder_spec.rb
@@ -1,7 +1,7 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "Finder" do
- before(:all) do
+ before(:each) do
index = build_index do
add_spec "activemerchant", "1.4.1" do
runtime "activesupport", ">= 1.4.1"
View
7 spec/bundler/installer_spec.rb
@@ -2,13 +2,12 @@
describe "Bundler::Installer" do
- before(:all) do
+ before(:each) do
@finder = Bundler::Finder.new("file://#{gem_repo1}", "file://#{gem_repo2}")
end
describe "without native gems" do
- before(:all) do
- FileUtils.rm_rf(tmp_dir)
+ before(:each) do
@bundle = @finder.resolve(build_dep('rails', '>= 0'))
@bundle.download(tmp_dir)
end
@@ -65,7 +64,7 @@
describe "after installing gems" do
- before(:all) do
+ before(:each) do
@environment = Bundler::Installer.install(tmp_dir)
end
View
3 spec/bundler/manifest_file_spec.rb
@@ -1,9 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "Bundler::Manifest" do
- before(:each) do
- reset!
- end
it "finds the default manifest file" do
build_manifest_file
View
10 spec/bundler/manifest_spec.rb
@@ -6,7 +6,7 @@ def dep(name, version, options = {})
Bundler::Dependency.new(name, {:version => version}.merge(options))
end
- before(:all) do
+ before(:each) do
@sources = %W(file://#{gem_repo1} file://#{gem_repo2})
@deps = []
@deps << dep("rails", "2.3.2")
@@ -16,7 +16,6 @@ def dep(name, version, options = {})
describe "Manifest with dependencies" do
before(:each) do
- reset!
@manifest = build_manifest <<-Gemfile
sources.clear
source "file://#{gem_repo1}"
@@ -141,10 +140,6 @@ def dep(name, version, options = {})
end
describe "runtime" do
- before(:each) do
- FileUtils.rm_rf(tmp_dir)
- FileUtils.mkdir_p(tmp_dir)
- end
it "makes gems available via Manifest#activate" do
m = build_manifest <<-Gemfile
@@ -182,8 +177,7 @@ def dep(name, version, options = {})
end
describe "environments" do
- before(:all) do
- reset!
+ before(:each) do
@manifest = build_manifest <<-Gemfile
sources.clear
source "file://#{gem_repo1}"
View
11 spec/spec_helper.rb
@@ -68,13 +68,13 @@ def build_manifest(*args)
FileUtils.mkdir_p(path.dirname)
Dir.chdir(path.dirname) do
build_manifest_file(path, str)
- Bundler::ManifestFile.load
+ Bundler::ManifestFile.load(path)
end
end
def reset!
- FileUtils.rm_rf(tmp_dir)
- FileUtils.mkdir_p(tmp_dir)
+ tmp_dir.rmtree if tmp_dir.exist?
+ tmp_dir.mkdir
end
end
end
@@ -86,14 +86,13 @@ def reset!
original_wd = Dir.pwd
- config.before(:all) do
+ config.before(:each) do
@log_output = StringIO.new
Bundler.logger.instance_variable_set("@logdev", Logger::LogDevice.new(@log_output))
+ reset!
end
config.after(:each) do
- @log_output.rewind
- @log_output.string.replace ""
Dir.chdir(original_wd)
end
end

0 comments on commit 8979215

Please sign in to comment.
Something went wrong with that request. Please try again.