check_key(the_key, key_name = "")
click to toggle source
def check_key(the_key, key_name = "")
the_key.should_not be_nil
the_key.id.should be_a(String)
the_key.id.should eql(key_name)
the_key.actions.should_not be_nil
the_key.actions.size.should eql(1)
the_key.actions.first[0].should eql("destroy")
the_key.actions.first[1].should eql("#{API_URL}/keys/#{key_name}")
the_key.fingerprint.should_not be_nil
the_key.fingerprint.should be_a(String)
the_key.pem.should_not be_nil
the_key.pem.first.should be_a(String)
end
clean_fixtures()
click to toggle source
def clean_fixtures
FileUtils.rm_rf( File.dirname( __FILE__ ) + '/data' )
end
client()
click to toggle source
def client
RestClient::Resource.new(API_URL)
end
create_key_if_necessary(client, key_name)
click to toggle source
def create_key_if_necessary(client, key_name)
the_key = client.key(key_name)
unless the_key
client.create_key()
end
end
includes_transition( transitions, action, to )
click to toggle source
def includes_transition( transitions, action, to )
found = transitions.find{|e| e.action.to_s == action.to_s && e.to.to_s == to.to_s }
! found.nil?
end
invalid_usage(error_msg='')
click to toggle source
def invalid_usage(error_msg='')
puts "\n ERROR: #{error_msg} \n\n"
puts @optparse
exit(1)
end
prop_check(prop, value_class)
click to toggle source
def prop_check(prop, value_class)
if prop.present?
prop.value.should_not be_nil
prop.value.should be_a(value_class)
end
end
reload_fixtures()
click to toggle source
def reload_fixtures
clean_fixtures
FileUtils.cp_r( File.dirname( __FILE__) + '/fixtures', File.dirname( __FILE__ ) + '/data' )
end