Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OC 10878 openstack test fix for knife-cloud change. #79

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/functional/server_list_func_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
]
instance.stub(:query_resource).and_return(@resources)
instance.stub(:puts)
instance.stub(:create_service_instance).and_return(Chef::Knife::Cloud::Service.new)
instance.stub(:create_service_instance).and_return(Chef::Knife::Cloud::FogService.new)
instance.stub(:validate!)
end

Expand Down
32 changes: 1 addition & 31 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
require "securerandom"
require 'knife-openstack/version'
require 'test/knife-utils/test_bed'
require 'resource_spec_helper'

def find_instance_id(instance_name, file)
file.lines.each do |line|
Expand Down Expand Up @@ -61,34 +62,3 @@ def init_openstack_test
puts "Error while creating file - incorrect_openstack.pem"
end
end

# TODO - we should use factory girl or fixtures for this as part of test utils.
# Creates a resource class that can dynamically add attributes to
# instances and set the values
module JSONModule
def to_json
hash = {}
self.instance_variables.each do |var|
hash[var] = self.instance_variable_get var
end
hash.to_json
end
def from_json! string
JSON.load(string).each do |var, val|
self.instance_variable_set var, val
end
end
end

class TestResource
include JSONModule
def initialize(*args)
args.each do |arg|
arg.each do |key, value|
add_attribute = "class << self; attr_accessor :#{key}; end"
eval(add_attribute)
eval("@#{key} = value")
end
end
end
end