-
-
Save pnomolos/fb7dd1c04cb7f6daefb794fe536d4594 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe Dry::Types::Rails::Railtie do | |
it "re-registers type subclasses" do | |
old_klass = SchemaStruct | |
class SchemaStruct | |
def self.bob | |
"bob" | |
end | |
end | |
expect(Dry::Types[SchemaStruct].primitive).to eq(SchemaStruct) | |
expect(SchemaStruct).to respond_to(:bob) | |
expect(Dry::Types[SchemaStruct].primitive).to respond_to(:bob) | |
expect(ActiveSupport::Dependencies.autoloaded?(:SchemaStruct)).to be_truthy | |
ActionDispatch::Reloader.prepare! | |
ActiveSupport::Dependencies.clear | |
SchemaStruct | |
expect(ActiveSupport::Dependencies.autoloaded?(:SchemaStruct)).to be_truthy | |
expect(SchemaStruct).to_not respond_to(:bob) | |
# The following fails | |
expect(Dry::Types[SchemaStruct].primitive).to_not respond_to(:bob) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is autoloaded by the Rails autoloader | |
class SchemaStruct < Dry::Types::Struct | |
constructor_type :schema | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment