spec/client_spec.rb in venice-0.4.2 vs spec/client_spec.rb in venice-0.4.3

- old
+ new

@@ -71,14 +71,10 @@ end end end context 'with a latest receipt info attribute' do - before do - client.stub(:json_response_from_verifying_data).and_return(response) - end - let(:response) do { 'status' => 0, 'receipt' => {}, 'latest_receipt' => '<encoded string>', @@ -106,13 +102,25 @@ ] } end it 'should create a latest receipt' do + client.stub(:json_response_from_verifying_data).and_return(response) receipt = client.verify! 'asdf' receipt.latest_receipt_info.should_not be_nil + receipt.latest_receipt_info.first.product_id.should eq 'com.ficklebits.nsscreencast.monthly_sub' end + + context 'when latest_receipt_info is a hash instead of an array' do + it 'should still create a latest receipt' do + response['latest_receipt_info'] = response['latest_receipt_info'].first + client.stub(:json_response_from_verifying_data).and_return(response) + receipt = client.verify! 'asdf' + receipt.latest_receipt_info.should_not be_nil + receipt.latest_receipt_info.first.product_id.should eq 'com.ficklebits.nsscreencast.monthly_sub' + end + end end context 'with an error response' do before do client.stub(:json_response_from_verifying_data).and_return(response) @@ -143,10 +151,10 @@ let(:response) do { 'status' => 21000, 'receipt' => {}, - 'is-retryable' => true + 'is_retryable' => true } end it 'raises a VerificationError' do expect do