Skip to content

Commit

Permalink
Removed final global test helper from test/test_helper.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Oct 4, 2010
1 parent 3fe785a commit 12b769c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,5 +1,6 @@
## 0.6.4 (unreleased)

- Added method to `TestHelpers` to assist with testing new downloaders.
- `up --no-provision` works again. This disables provisioning during the
boot process.
- Action warden doesn't do recovery process on `SystemExit` exceptions,
Expand Down
13 changes: 13 additions & 0 deletions lib/vagrant/test_helpers.rb
Expand Up @@ -55,6 +55,19 @@ def vagrant_box(name)
result
end

# Returns an instantiated downloader with a mocked tempfile
# which can be passed into it.
#
# @param [Class] klass The downloader class
# @return [Array] Returns an array of `downloader` `tempfile`
def vagrant_mock_downloader(klass)
tempfile = mock("tempfile")
tempfile.stubs(:write)

_, env = action_env
[klass.new(env), tempfile]
end

# Returns a blank app (callable) and action environment with the
# given vagrant environment. This allows for testing of middlewares.
def action_env(v_env = nil)
Expand Down
9 changes: 0 additions & 9 deletions test/test_helper.rb
Expand Up @@ -22,14 +22,5 @@

class Test::Unit::TestCase
include Vagrant::TestHelpers

# Sets up the mocks and stubs for a downloader
def mock_downloader(downloader_klass)
tempfile = mock("tempfile")
tempfile.stubs(:write)

_, env = action_env
[downloader_klass.new(env), tempfile]
end
end

2 changes: 1 addition & 1 deletion test/vagrant/downloaders/file_test.rb
Expand Up @@ -2,7 +2,7 @@

class FileDownloaderTest < Test::Unit::TestCase
setup do
@downloader, @tempfile = mock_downloader(Vagrant::Downloaders::File)
@downloader, @tempfile = vagrant_mock_downloader(Vagrant::Downloaders::File)
@uri = "foo.box"
end

Expand Down
2 changes: 1 addition & 1 deletion test/vagrant/downloaders/http_test.rb
Expand Up @@ -2,7 +2,7 @@

class HttpDownloaderTest < Test::Unit::TestCase
setup do
@downloader, @tempfile = mock_downloader(Vagrant::Downloaders::HTTP)
@downloader, @tempfile = vagrant_mock_downloader(Vagrant::Downloaders::HTTP)
@downloader.stubs(:report_progress)
@downloader.stubs(:complete_progress)
@uri = "http://google.com/"
Expand Down

0 comments on commit 12b769c

Please sign in to comment.