diff --git a/test/sweet_notifications_test.rb b/test/sweet_notifications_test.rb
index <HASH>..<HASH> 100644
--- a/test/sweet_notifications_test.rb
+++ b/test/sweet_notifications_test.rb
@@ -57,11 +57,8 @@ describe SweetNotifications do
     end
 
     it 'binds to current Rails app directly when the app is initialized' do
-      module ::Rails
-        def self.application
-          Struct.new(:initialized?).new(true)
-        end
-      end
+      mock_app = Struct.new(:initialized?).new(true)
+      Rails.instance_variable_set(:@application, mock_app)
 
       railtie, = SweetNotifications.subscribe 'sweet' do
         event :direct do |event|
Fix warning "method redefined;" in tests

sweet_notifications/test/sweet_notifications_test.rb:<I>: warning: method redefined; discarding old application
ruby-<I>/gems/railties-<I>/lib/rails.rb:<I>: warning: previous definition of application was here