Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'features/spec_helper'
- describe LoginApi do
- let(:params) do
- {
- email: 'testemail@aol.com',
- password: 'Testing1'
- }
- end
- def validate_user(user, international: false)
- service = LoginService.new(user, params)
- objects = nil
- if international
- expected_tags = ['international']
- VCR.configure do |c|
- c.hook_into :webmock
- c.before_playback {|i| i.response.body.sub!("US", "CA") }
- end
- else
- VCR.configure do |c|
- c.clear_hooks
- end
- expected_tags = []
- end
- VCR.use_cassette('LoginApi') do
- objects = service.perform
- end
- user = objects.first
- profile = objects.second
- expect(user.email).to eq('testemail@aol.com')
- expect(user.first_name).to eq('LILLIE')
- expect(user.master_id).to eq('5555033010733')
- expect(user.customer_id).to eq('1502711131400')
- expect(user.billing_address.street).to eq('130 Wanton Ln')
- expect(user.billing_address.last_billed_at).to be_truthy
- expect(user.coupons.first.coupon_code).to eq('SAVE10')
- expect(profile.master_id).to eq(user.master_id)
- expect(profile.customer_id).to eq(user.customer_id)
- cards = profile.credit_cards
- expect(cards.size).to eq(2)
- expect(cards.first.display_number).to eq('3422')
- expect(cards.first.ads_card.credit_brand).to eq('W')
- expect(cards.first.ads_card.loyalty_rewards).to eq(4312)
- expect(cards.second.display_number).to eq('4321')
- expect(cards.second.ads_card.credit_brand).to eq('R')
- expect(cards.second.ads_card.loyalty_rewards).to eq(4315)
- expect(user.tags).to eq(expected_tags)
- end
- context "creates user" do
- let (:user) { nil }
- it 'without international tag', focus: true do
- validate_user(user)
- end
- it 'with international tag' do
- validate_user(user, international: true)
- end
- end
- context "updates user" do
- let(:user) { create_user(email: 'fbbrands01@fbbrands.com') }
- it 'without international tag' do
- validate_user(user)
- end
- it 'with international tag' do
- validate_user(user, international: true)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement