Skip to content

Instantly share code, notes, and snippets.

@datapimp
Created February 7, 2011 04:29
Show Gist options
  • Select an option

  • Save datapimp/813995 to your computer and use it in GitHub Desktop.

Select an option

Save datapimp/813995 to your computer and use it in GitHub Desktop.
require 'wmx/sandbox'
require 'wmx/client/request'
require 'json'
Given /an API client exists/ do
@api_client = WMX::Sandbox.new.create_client
@api_user = @api_client.user
@api_content_package = @api_client.content_package
end
Given /^I am constructing a (.+) request to the (.+) API$/ do |api_action, end_point|
puts "Attempting To Connect on #{ ENV['WMX_API_PORT']} to #{ ENV['WMX_API_HOST']}"
request_class = end_point.gsub(/\s+/,'_').camelize
@api_request = "WMX::Client::#{ request_class }".constantize.new :port => ENV['WMX_API_PORT'], :host => ENV['WMX_API_HOST']
@api_action = api_action.to_sym
end
When /I submit the request/ do
@results = @api_request.send(@api_action)
end
Then /^I should receive a list of (.+)$/ do |object|
object_class = object.gsub(/\s+/,'_').singularize.camelize.constantize
attributes = JSON.parse(object_class.new.to_json).keys
puts @results
@results.class.to_s.should == "Array"
@results.length.should >= 1
results_keys = @results.first.keys
attributes.each do |key|
results_keys.should include(key)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment