require 'spec_helper' module Recurly describe Transparent do # version accounts based on this current files modification dates timestamp = File.mtime(__FILE__).to_i describe ".url" do use_vcr_cassette "transparent/post-url/#{timestamp}" it "should not change after calling account.find()" do original_transparent_url = "#{Recurly::Base.site}/transparent/#{Recurly.subdomain}/subscription" Transparent.url.should == original_transparent_url account_code = "account-get-#{timestamp}" Factory.create_account("account-get-#{timestamp}") r = Account.find("account-get-#{timestamp}") Transparent.url.should == original_transparent_url end end it "should parse errors on nested objects" do response_xml = < 2345 12345 verena@test.com Verena Test User false abcd1234123412341234123412341234 2011-07-20T01:49:24Z active 12345 Verena Test User 127.0.0.1 7 2011 2011-07-20T01:49:35Z is required is required gold-plan Gold Plan pending 1 1200 2011-07-20T01:49:35Z 2011-07-20T01:49:35Z END response = mock response.should_receive(:[]).at_least(:once).with('Content-Length').and_return '123' response.should_receive(:body).at_least(:once).and_return response_xml subscription = Subscription.new.from_transparent_results(response) subscription.account.billing_info.credit_card.errors[:number].should_not be_empty subscription.account.billing_info.credit_card.errors[:number].should include('is required') subscription.account.billing_info.credit_card.errors[:verification_value].should_not be_empty subscription.account.billing_info.credit_card.errors[:verification_value].should include('is required') end end end