 		it "should be signed correctly", ->
 			signed = @signature.split("|")[0]
 			query = @signature.split("|")[1]
-			crypto.createHmac("sha1", Settings.apis.recurly.privateKey).update(query).digest("hex").should.equal signed
+			crypto.createHmac("sha1", @settings.apis.recurly.privateKey).update(query).digest("hex").should.equal signed
 
 		it "should be url escaped", ->
 			query = @signature.split("|")[1]

				data.subscription.unit_amount_in_cents.should.equal 800
				data.subscription.currency.should.equal "EUR"
				data.subscription.quantity.should.equal 1
				data.subscription.activated_at.should.deep.equal new Date("2011-05-27T07:00:00Z")
				should.equal data.subscription.canceled_at, null
				should.equal data.subscription.expires_at, null
				data.subscription.current_period_started_at.should.deep.equal new Date("2011-06-27T07:00:00Z")
				data.subscription.current_period_ends_at.should.deep.equal new Date("2011-07-27T07:00:00Z")
				should.equal data.subscription.trial_started_at, null
				should.equal data.subscription.trial_ends_at, null
				data.subscription.subscription_add_ons.should.deep.equal [{
					add_on_code: "ipaddresses"
					quantity: "10"
					unit_amount_in_cents: "150"
				}]
				data.subscription.account.url.should.equal "https://api.recurly.com/v2/accounts/1"
				data.subscription.url.should.equal "https://api.recurly.com/v2/subscriptions/44f83d7cba354d5b84812419f923ea96"
				data.subscription.plan.url.should.equal "https://api.recurly.com/v2/plans/gold"
				done()
	
	describe "getSubscription", ->
		describe "with proper subscription id", ->
			before ->
				@apiRequest = sinon.stub(RecurlyWrapper, "apiRequest", mockApiRequest)
				RecurlyWrapper.getSubscription "44f83d7cba354d5b84812419f923ea96", (error, recurlySubscription) =>
					@recurlySubscription = recurlySubscription
			after ->
				RecurlyWrapper.apiRequest.restore()
			
			it "should look up the subscription at the normal API end point", ->
				@apiRequest.args[0][0].url.should.equal "subscriptions/44f83d7cba354d5b84812419f923ea96"



		describe "with ReculyJS token", ->
			before ->
				@apiRequest = sinon.stub(@RecurlyWrapper, "apiRequest", mockApiRequest)
				@RecurlyWrapper.getSubscription "70db44b10f5f4b238669480c9903f6f5", {recurlyJsResult: true}, (error, recurlySubscription) =>
					@recurlySubscription = recurlySubscription
			after ->
				@RecurlyWrapper.apiRequest.restore()

			it "should return the subscription", ->
				@recurlySubscription.uuid.should.equal "44f83d7cba354d5b84812419f923ea96"

