Skip to content

Commit

Permalink
Removed redundant TestResource class code.
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhu-das committed Jan 8, 2014
1 parent 21d9310 commit 125140b
Showing 1 changed file with 1 addition and 31 deletions.
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

0 comments on commit 125140b

Please sign in to comment.