From 98cb07f59d7fa6d8c2d381f77d0eb49905ef4e52 Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Thu, 13 Mar 2014 10:30:35 +0000 Subject: [PATCH] [Brightbox] Remove dependency on .fog in test This isolates the tests from the values in `Fog.credentials` which is based on the contents of `~/.fog` Underlying problem is that the code (and many others) rely on the Fog global making it too tightly coupled to the environment hence having to stub. Full issue: https://github.com/fog/fog/issues/1390 This will probably be a repeating pattern we need to work on to DRY up so every test from every provider doesn't include this setup workaround. --- .../test/fog/compute/brightbox_test.rb | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/providers/brightbox/test/fog/compute/brightbox_test.rb b/providers/brightbox/test/fog/compute/brightbox_test.rb index 023765053..a2e0ac41d 100644 --- a/providers/brightbox/test/fog/compute/brightbox_test.rb +++ b/providers/brightbox/test/fog/compute/brightbox_test.rb @@ -3,8 +3,24 @@ require "fog/brightbox" class Fog::Compute::BrightboxTest < Minitest::Test def setup - @arguments = {} - @service = Fog::Compute::Brightbox.new(@arguments) + @arguments = { + :brightbox_auth_url => "http://localhost", + :brightbox_api_url => "http://localhost", + :brightbox_client_id => "", + :brightbox_secret => "", + :brightbox_username => "", + :brightbox_password => "", + :brightbox_account => "" + } + + @credential_guard = Minitest::Mock.new + def @credential_guard.reject + {} + end + + Fog.stub :credentials, @credential_guard do + @service = Fog::Compute::Brightbox.new(@arguments) + end end def test_respond_to_request