Sha256: ec01e36de6088b6133cb89aed288f0d36853aae9fa358dd1f946f7370a439c37

Contents?: true

Size: 1.48 KB

Versions: 2

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

require "spec_helper"

module CulqiHelper
  def setup_culqi_gateway
    Solidus::Gateway::CulqiGateway.create!(
      name: "Culqi",
      preferred_secret_key: "sk_test_SpwICNI4YT0OSLHY",
      preferred_public_key: "pk_test_CaY0noGVG8ohIj4P"
    )
  end

  def checkout_until_payment(product, user = nil)
    visit spree.product_path(product)
    click_button "Add To Cart"

    expect(page).to have_current_path("/cart")
    click_button "Checkout"

    # Address
    if user
      expect(page).to have_current_path("/checkout/address")
    else
      within("#guest_checkout") do
        find('#order_email')
        fill_in "Email", with: "han@example.com"
        click_button "Continue"
      end
      expect(page).to have_current_path("/checkout")
    end

    country = Spree::Country.first
    within("#billing") do
      fill_in "First Name", with: "Han"
      fill_in "Last Name", with: "Solo"
      fill_in "Street Address", with: "YT-1300"
      fill_in "City", with: "Mos Eisley"
      select "United States of America", from: "Country"
      select country.states.first, from: "order_bill_address_attributes_state_id"
      fill_in "Zip", with: "12010"
      fill_in "Phone", with: "(555) 555-5555"
    end
    click_on "Save and Continue"

    # Delivery
    expect(page).to have_current_path("/checkout/delivery")
    # expect(page).to have_content("UPS Ground")
    click_on "Save and Continue"

    expect(page).to have_current_path("/checkout/payment")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solidus_culqi-0.1.1 spec/support/culqi_helper.rb
solidus_culqi-0.1.0 spec/support/culqi_helper.rb