spec/models/spree/calculator/shipping/quoted_for_label_spec.rb
# I generally dislike stubbing in testing but without it in this case the
# complexity of the tests would exceed the complexity of the code we are
# testing. So a small bit of stubbing is the lesser of two evils.
I generally dislike stubbing in testing but without it in this case the
complexity of the tests would exceed the complexity of the code we are
testing. So a small bit of stubbing is the lesser of two evils.
I generally dislike stubbing in testing but without it in this case the complexity of the tests would exceed the complexity of the code we are testing . So a small bit of stubbing is the lesser of two evils .
def stub_estimation_response value
    package.singleton_class.send :define_method, :preferred_package_type do |provider_name, service_type|
      p = Object.new
      p.singleton_class.send :define_method, :provider do
        pkg = Object.new
        pkg.singleton_class.send :define_method, :estimate do |service_type, package_type, package|
          value
        end
        pkg
      end
      p
    end
  end
def stub_estimation_response value package . singleton_class . send :define_method , :preferred_package_type do | provider_name , service_type | p = Object . new p . singleton_class . send :define_method , :provider do pkg = Object . new pkg . singleton_class . send :define_method , :estimate do | service_type , package_type , package | value end pkg end p end end
I generally dislike stubbing in testing but without it in this case the
complexity of the tests would exceed the complexity of the code we are
testing.
I generally dislike stubbing in testing but without it in this case the complexity of the tests would exceed the complexity of the code we are testing .
value