diff --git a/spec/functional/server_list_func_spec.rb b/spec/functional/server_list_func_spec.rb index e4c00fdd..5820221a 100644 --- a/spec/functional/server_list_func_spec.rb +++ b/spec/functional/server_list_func_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index af5a8c11..67cc108c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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| @@ -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