Skip to content

Instantly share code, notes, and snippets.

View cored's full-sized avatar
🐔
Debugging Everything

Rafael George cored

🐔
Debugging Everything
View GitHub Profile
context "when there are shipments that have bundleable products" do
let(:shipments_in) { [shipment1, shipment2] }
let(:shipment1) { build(:shipment, products: [product_a]) }
let(:shipment2) { build(:shipment, products: [product_b]) }
it "returns the bundling product instead of the bundleable ones" do
expect(shipments_out.first.products).to match_array(product_c)
end
it "does not return the unused shipment" do
[41] pry(main)> person
=> {:pounds=>135, :kcal=>1500}
[42] pry(main)> macros
=> [{:protein_per_pound=>0.36, :fat_per_pound=>0.5, :daily_carbs=>255}]
[43] pry(main)> oatmeal_macros
=> {:cup=>{:protein=>5.9, :fat=>3.6, :carbs=>28.1}}
[44] pry(main)> raisins_macros
=> {:cup=>{:protein=>0.0, :fat=>0.0, :carbs=>33}}
[45] pry(main)> person = macros.reduce(person) do |person, macro|
[45] pry(main)* person = person.merge({protein_needed: person[:pounds] * macro[:protein_per_pound]})
package main
import (
"os"
"fmt"
"gitlab.com/george.rafael/restaurant-gr/internal/restaurant"
"gitlab.com/george.rafael/restaurant-gr/internal/stats"
)
@cored
cored / build.rb
Created September 14, 2018 15:16
# frozen_string_literal: true
module Shipments
class Build
def self.shipments_for(shipments_payload:)
shipments_payload.map do |shipment_payload|
call(payload: shipment_payload)
end
end
# frozen_string_literal: true
require "rails_helper"
RSpec.describe Groupments::OrderSerializer do
subject(:payload) do
described_class.new(
grouped_shipments: shipments,
unused_shipment_numbers: unused_shipment_numbers,
order_number: order_number
# frozen_string_literal: true
require "timecop"
require "active_support/all"
require_relative "../../../../app/services/flexe/notification_handlers/retail_fulfillment_order_info"
describe Flexe::NotificationHandlers::RetailFulfillmentOrderInfo do
subject(:retail_fulfillment_order_info) do
described_class.for(attrs)
end
# frozen_string_literal: true
require "timecop"
require "active_support/all"
require_relative "../../../../app/services/flexe/notification_handlers/retail_fulfillment_order_info"
describe Flexe::NotificationHandlers::RetailFulfillmentOrderInfo do
subject(:retail_fulfillment_order_info) do
described_class.for(attrs)
end
# frozen_string_literal: true
require "rails_helper"
describe Bedpost::Orders::ReadyToGroup, type: :consumer do
subject(:process_ready_to_group) { described_class.new.process(payload) }
let(:shipments_message) do
{
shipments: fixtures_for_shipments(shipments),
require "minitest/autorun"
require "minitest/pride"
module ParenthesisValidator
extend self
OPENERS = %w|( { [|
def call(code)
return false if code.size == 1
openers = []
# frozen_string_literal: true
module Groupments
class GroupShipments
def self.call(shipments:)
new(shipments: shipments).call.grouped_shipments
end
attr_reader :grouped_shipments