diff --git a/lib/warden/test/helpers.rb b/lib/warden/test/helpers.rb index cecbc1b..760e5ba 100644 --- a/lib/warden/test/helpers.rb +++ b/lib/warden/test/helpers.rb @@ -11,6 +11,10 @@ def self.included(_base) ::Warden.test_mode! end + def self.extended(_base) + ::Warden.test_mode! + end + # A helper method that will perform a login of a user in warden for the next request. # Provide it the same options as you would to Warden::Proxy#set_user # @see Warden::Proxy#set_user diff --git a/spec/warden/test/helpers_spec.rb b/spec/warden/test/helpers_spec.rb index 187bbd3..579dfd6 100644 --- a/spec/warden/test/helpers_spec.rb +++ b/spec/warden/test/helpers_spec.rb @@ -4,6 +4,20 @@ before{ $captures = [] } after{ Warden.test_reset! } + describe ".included" do + it "should prepare Warden for testing" do + expect(Warden).to receive(:test_mode!) + Class.new { include(Warden::Test::Helpers) } + end + end + + describe ".extended" do + it "should prepare Warden for testing" do + expect(Warden).to receive(:test_mode!) + Object.new.extend(Warden::Test::Helpers) + end + end + it "should log me in as a user" do user = "A User" login_as user