Sha256: 7bdda0f0242d5062b2b367d833004acdb01301671f544984c86dfeafe28f89ec

Contents?: true

Size: 1.9 KB

Versions: 7

Compression:

Stored size: 1.9 KB

Contents

<% if %w[selenium watir].include?(automation) && visual_automation == true %>
# frozen_string_literal: true

require_relative 'base_spec'
require_relative '../page_objects/pages/login_page'
require_relative '../page_objects/pages/app_page'

describe 'Login Page' do
  let(:app_page) { AppPage.new(<% if automation == 'watir' -%>browser<% else -%>driver<% end -%>) }
  let(:login_page) { LoginPage.new(<% if automation == 'watir' -%>browser<% else -%>driver<% end -%>) }

  before do
    login_page.visit
  end

  it 'looks as expected' do
    check_page login_page
    login_page.login
    check_page app_page
  end
end
<%- elsif %w[selenium watir].include? automation -%>
# frozen_string_literal: true

require_relative 'base_spec'
require_relative '../models/model_factory'
require_relative '../page_objects/pages/login_page'

describe 'Login' do
  subject(:header) { login_page.header.customer_name }

  let(:user) { ModelFactory.for('users')['Agustin'] }
  let(:login_page) { LoginPage.new(<% if automation == 'watir' -%>browser<% else -%>driver<% end -%>) }

  before do
    login_page.visit
    login_page.login(user['username'], password)
  end

  context 'with right credentials' do
    let(:password) { user['password'] }

    it 'can successfully log in' do
      expect(header).to eq "Welcome back #{user['name']}"
    end
  end

  context 'with wrong credentials' do
    let(:password) { 'wrongPassword' }

    it 'cannot login in' do
      expect(header).to be_empty
    end
  end
end
<%- else -%>
require_relative '../page_objects/pages/home_page'
require_relative 'base_spec'
require_relative '../page_objects/pages/pdp_page'

class PdpSpec < BaseSpec
  describe 'PDP page' do

    let(:home_page) { HomePage.new(driver) }
    let(:pdp_page) { PdpPage.new(driver) }

    it 'shows add to cart button' do
      home_page.go_to_backpack_pdp
      expect(pdp_page.add_to_cart_text).to eq 'Add To Cart'
    end
  end
end
<%- end -%>

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ruby_raider-0.6.7 lib/generators/rspec/templates/spec.tt
ruby_raider-0.6.6 lib/generators/rspec/templates/spec.tt
ruby_raider-0.6.5 lib/generators/rspec/templates/spec.tt
ruby_raider-0.6.4 lib/generators/rspec/templates/spec.tt
ruby_raider-0.6.3 lib/generators/rspec/templates/spec.tt
ruby_raider-0.6.2 lib/generators/rspec/templates/spec.tt
ruby_raider-0.6.1 lib/generators/rspec/templates/spec.tt