Sha256: 05190bc512883753555d13076d72ac8f9244d72c6af12695f4d6eee12cc3ed3e
Contents?: true
Size: 1.18 KB
Versions: 48
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true require 'rails_helper' RSpec.describe Spree::Order::NumberGenerator do subject { described_class.new.generate } it { is_expected.to be_a(String) } describe 'length' do let(:default_length) do Spree::Order::ORDER_NUMBER_LENGTH + Spree::Order::ORDER_NUMBER_PREFIX.length end it { expect(subject.length).to eq default_length } context "when length option is 5" do let(:option_length) { 5 + Spree::Order::ORDER_NUMBER_PREFIX.length } subject { described_class.new(length: 5).generate } it "should be 5 plus default prefix length" do expect(subject.length).to eq option_length end end end context "when letters option is true" do subject { described_class.new(letters: true).generate } it "generates order number including letters" do is_expected.to match /[A-Z]/ end end describe 'prefix' do it { is_expected.to match /^#{Spree::Order::ORDER_NUMBER_PREFIX}/ } context "when prefix option is 'P'" do subject { described_class.new(prefix: 'P').generate } it "generates order number prefixed with 'P'" do is_expected.to match /^P/ end end end end
Version data entries
48 entries across 48 versions & 2 rubygems