diff --git a/lib/flickwerk/patch_finder.rb b/lib/flickwerk/patch_finder.rb index 47a997a..ec18090 100644 --- a/lib/flickwerk/patch_finder.rb +++ b/lib/flickwerk/patch_finder.rb @@ -2,7 +2,7 @@ module Flickwerk class PatchFinder - DECORATED_CLASS_PATTERN = /(?:::)?(?[\w.:]+)\.prepend[\s(]/ + DECORATED_CLASS_PATTERN = /(?:::)?(?[\w.:]+?)(?:\.singleton_class)?\.prepend[\s(]/ attr_reader :path, :autoloader diff --git a/test/dummy_app/app/patches/models/user_class_methods_patch.rb b/test/dummy_app/app/patches/models/user_class_methods_patch.rb new file mode 100644 index 0000000..6a61116 --- /dev/null +++ b/test/dummy_app/app/patches/models/user_class_methods_patch.rb @@ -0,0 +1,7 @@ +module UserClassMethodsPatch + def address + "The outer rim" + end + + DummyApp.user_class.singleton_class.prepend(self) +end diff --git a/test/test_flickwerk.rb b/test/test_flickwerk.rb index f547c72..b9b47fa 100644 --- a/test/test_flickwerk.rb +++ b/test/test_flickwerk.rb @@ -69,4 +69,11 @@ def boot assert UI::Button.new.respond_to?(:click) assert_equal "Button clicked!", UI::Button.new.click end + + test "singleton classes can be patched" do + boot + + assert User + assert "The outer rim", User.address + end end