require 'spec_helper' require 'action_controller/railtie' require 'justlogging/railtie' describe Justlogging::Railtie do before :all do MyApp::Application.initialize! end it "should have set the justlogging subscriber" do Justlogging.subscriber.should be_a ActiveSupport::Notifications::Fanout::Subscriber end it "should have added the middleware for exceptions" do MyApp::Application.middleware.middlewares.should include Justlogging::Middleware end context "non action_controller event" do it "should call add_event for non action_controller event" do current = stub current.should_receive(:add_event) Justlogging::Transaction.should_receive(:current).twice.and_return(current) end after do ActiveSupport::Notifications.instrument 'query.mongoid' end end context "action_controller event" do it "should call set_log_entry for action_controller event" do current = stub current.should_receive(:set_log_entry) Justlogging::Transaction.should_receive(:current).twice.and_return(current) end after do ActiveSupport::Notifications.instrument 'process_action.action_controller' end end end