```ruby
module Spree::Shipping
  class RateBuilder

    def initialize(package, shipping_method, ship_time)
      @package = package
      @shipping_method = shipping_method
      @calculator = shipping_method.calculator
      @ship_time = ship_time
    end

    def rate
      shipping_method.shipping_rates.new(
        cost: package_cost,
        tax_rate: tax_rate,
        delivery_window_start: delivery_window.start,
        delivery_window_end: delivery_window.end
      )
    end

    private

    attr_reader :package, :shipping_method, :ship_time, :calculator

    def package_cost
      calculator.compute_package(package)
    end

    def tax_rate
      tax_category = shipping_method.tax_category
      if tax_category
        tax_category.tax_rates.detect do |rate|
          # If the rate's zone matches the order's zone, a positive adjustment will be applied.
          # If the rate is from the default tax zone, then a negative adjustment will be applied.
          # See the tests in shipping_rate_spec.rb for an example of this.d
          rate.zone == package.order.tax_zone || rate.zone.default_tax?
        end
      end
    end

    def delivery_window
      @delivery_window ||= begin
        if calculator.respond_to?(:estimate_delivery_window)
          calculator.estimate_delivery_window(package, ship_time)
        else
          DeliveryWindow.new(nil, nil)
        end
      end
    end
  end
end```

Fix rate builder to handle delivery window arrays with only one element
user
```ruby
module Spree::Shipping
  class RateBuilder

    def initialize(package, shipping_method, ship_time)
      @package = package
      @shipping_method = shipping_method
      @calculator = shipping_method.calculator
      @ship_time = ship_time
    end

    def rate
      shipping_method.shipping_rates.new(
        cost: package_cost,
        tax_rate: tax_rate,
        delivery_window_start: delivery_window.start,
        delivery_window_end: delivery_window.end
      )
    end

    private

    attr_reader :package, :shipping_method, :ship_time

    def package_cost
      calculator.compute_package(package)
    end

    def tax_rate
      tax_category = shipping_method.tax_category
      if tax_category
        tax_category.tax_rates.detect do |rate|
          # If the rate's zone matches the order's zone, a positive adjustment will be applied.
          # If the rate is from the default tax zone, then a negative adjustment will be applied.
          # See the tests in shipping_rate_spec.rb for an example of this.d
          rate.zone == package.order.tax_zone || rate.zone.default_tax?
        end
      end
    end

    def delivery_window
      @delivery_window ||= begin
        if calculator.respond_to?(:estimate_delivery_window)
          range = calculator.estimate_delivery_window(package, ship_time)
          if range.length == 1
            range.push(range[0])
          end
          DeliveryWindow.new(range[0], range[1])
        else
          DeliveryWindow.new(nil, nil)
        end
      end
    end
  end
end```
assistant