unless defined?(INTEGRATION_SPEC_HELPER_LOADED) require File.dirname(__FILE__) + '/../spec_helper' require 'cgi' Cardflex::Configuration.environment = :test # use the testing api key Cardflex::Configuration.api_key = ENV['CARDFLEX_API_KEY'] || "2F822Rw39fx762MaV7Yy86jXGTC7sCDy" INTEGRATION_SPEC_HELPER_LOADED = true module SpecHelper # takes care of step 2, the form posting to the form_url # parses out the token_id and returns it def self.step_two(form_url, attrs={}) uri = URI(form_url) attrs.merge!({ 'billing-cc-number' => Cardflex::Test::Cards::Visa, 'billing-cc-exp' => Cardflex::Test::Cards::Expiration }) res = Net::HTTP.post_form(uri, attrs) CGI::parse(URI(res.header["Location"]).query)['token-id'][0] end end end