daily pastebin goal
83%
SHARE
TWEET

Untitled

a guest Jan 28th, 2016 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require 'features/spec_helper'
  2.  
  3. describe LoginApi do
  4.  
  5.   let(:params) do
  6.     {
  7.       email: 'testemail@aol.com',
  8.       password: 'Testing1'
  9.     }
  10.   end
  11.  
  12.   def validate_user(user, international: false)
  13.     service = LoginService.new(user, params)
  14.     objects = nil
  15.  
  16.     if international
  17.       expected_tags = ['international']
  18.       VCR.configure do |c|
  19.         c.hook_into :webmock
  20.         c.before_playback {|i| i.response.body.sub!("US", "CA") }
  21.       end
  22.     else
  23.       VCR.configure do |c|
  24.         c.clear_hooks
  25.       end
  26.       expected_tags = []
  27.     end
  28.  
  29.     VCR.use_cassette('LoginApi') do
  30.       objects = service.perform
  31.     end
  32.  
  33.     user = objects.first
  34.     profile = objects.second
  35.  
  36.     expect(user.email).to                               eq('testemail@aol.com')
  37.     expect(user.first_name).to                          eq('LILLIE')
  38.     expect(user.master_id).to                           eq('5555033010733')
  39.     expect(user.customer_id).to                         eq('1502711131400')
  40.     expect(user.billing_address.street).to              eq('130 Wanton Ln')
  41.     expect(user.billing_address.last_billed_at).to      be_truthy
  42.     expect(user.coupons.first.coupon_code).to           eq('SAVE10')
  43.     expect(profile.master_id).to                        eq(user.master_id)
  44.     expect(profile.customer_id).to                      eq(user.customer_id)
  45.  
  46.     cards = profile.credit_cards
  47.     expect(cards.size).to                               eq(2)
  48.     expect(cards.first.display_number).to               eq('3422')
  49.     expect(cards.first.ads_card.credit_brand).to        eq('W')
  50.     expect(cards.first.ads_card.loyalty_rewards).to     eq(4312)
  51.     expect(cards.second.display_number).to              eq('4321')
  52.     expect(cards.second.ads_card.credit_brand).to       eq('R')
  53.     expect(cards.second.ads_card.loyalty_rewards).to    eq(4315)
  54.  
  55.     expect(user.tags).to                                eq(expected_tags)
  56.   end
  57.  
  58.   context "creates user" do
  59.     let (:user) { nil }
  60.  
  61.     it 'without international tag', focus: true do
  62.       validate_user(user)
  63.     end
  64.  
  65.     it 'with international tag' do
  66.       validate_user(user, international: true)
  67.     end
  68.   end
  69.  
  70.   context "updates user" do
  71.     let(:user) { create_user(email:  'fbbrands01@fbbrands.com') }
  72.  
  73.     it 'without international tag' do
  74.       validate_user(user)
  75.     end
  76.  
  77.     it 'with international tag' do
  78.       validate_user(user, international: true)
  79.     end
  80.   end
  81. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top