Sha256: f70232d189badee1cb60a22b07e9c2a45ce9ac324c3dcf5a6bc90fe481a0c3a5

Contents?: true

Size: 1.71 KB

Versions: 3

Compression:

Stored size: 1.71 KB

Contents

require 'rails_helper'

RSpec.feature 'Settings Page', type: :feature do
  let(:address) { create(:address) }

  before { login_as(address.user, scope: :user) }

  describe 'address tab' do
    before { visit '/settings/address' }

    scenario 'show user address parametrs' do
      expect(page).to have_field('First Name', with: address.first_name)
      expect(page).to have_field('Last Name', with: address.last_name)
      expect(page).to have_field('Address', with: address.address)
      expect(page).to have_field('City', with: address.city)
      expect(page).to have_field('Zip', with: address.zip)
      expect(page).to have_field('Phone', with: address.phone)
    end

    scenario 'update fields with valid values' do
      within '#billing' do
        fill_in 'First Name', with: 'Loker'
        fill_in 'City', with: 'Jitomir city'
        fill_in 'Zip', with: '123'
        click_button('Save')
      end
      expect(page).to have_field('First Name', with: 'Loker')
      expect(page).to have_field('City', with: 'Jitomir city')
      expect(page).to have_field('Zip', with: '123')
    end

    scenario 'try update fields with invalid values' do
      within '#billing' do
        fill_in 'First Name', with: '123'
        fill_in 'City', with: ''
        fill_in 'Zip', with: 'qqq'
        click_button('Save')
      end
      expect(page).to have_css('div.has-error')
      expect(page).to have_content('must consist of only letters')
      expect(page).to have_content("can't be blank")
      expect(page).to have_content('must consist of only digits')
      expect(page).to have_field('First Name', with: '123')
      expect(page).to have_field('Zip', with: 'qqq')
      expect(page).to have_field('City', with: '')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
loker-shopping-cart-0.1.3 spec/features/shopping_cart/settings_spec.rb
loker-shopping-cart-0.1.2 spec/features/shopping_cart/settings_spec.rb
loker-shopping-cart-0.1.1 spec/features/shopping_cart/settings_spec.rb