Giter Club home page Giter Club logo

Comments (2)

adomokos avatar adomokos commented on May 28, 2024

Absolutely. The LightService::Context is just a hash with a few additional features.

Here is an Action, the context is LightService::Context:

module Services
  class SendsNotifivationEmail
    def self.execute(context)
       return context if context.failure?
       admin = context.fetch :admin

       UserMailer.send_order_notification(admin)

       context
    end
  end
end

And this is how I'd test it (note that I have to stub the failure? message):

describe MakesOrderAction do
  let(:admin) { double(:admin) }

   it "sends notification user to admin" do
     context = {:admin => admin} 
     context.stub(:failure? => false) # The method failure? needs to be stubbed on the hash
     UserMailer.should_receive(:send_order_notification) \
                     .with(admin)

     MakesOrderAction.execute(context)      
  end
end

Let me know if this did not answer your question.

from light-service.

ngpestelos avatar ngpestelos commented on May 28, 2024

Thanks! Stubbing :failure? helped a lot.

from light-service.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.