Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds spec for issue with memoization and dynamic methods #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alxberardi
Copy link

Hi @dkubb ,

I think I might have found an issue with memoization.

Apparently, when memoizing a method which initialises objects that define methods dynamically, the dynamic methods on the object are no longer public.

Please see the spec I added to replicate the problem.

When running the spec, this is the output I get (stripped of non relevant lines):

bundle exec rspec spec/unit/adamantium/dynamic_methods_memoize_spec.rb 

FF...

Failures:

  1) Adamantium memoizing methods that initialize objects with dynamically defined methods a composed instance its composed should respond to #test
     Failure/Error: it      { is_expected.to respond_to(:test) }
       expected #<Component:0x007f85f399b5a8 @test=true> to respond to :test
     # ./spec/unit/adamantium/dynamic_methods_memoize_spec.rb:47:in `block (4 levels) in <top (required)>'
     # ./vendor/ruby/2.2.0/bundler/gems/devtools-8d492930b9a5/lib/devtools/project/initializer/rspec.rb:48:in `block in enable_unit_test_timeout'

  2) Adamantium memoizing methods that initialize objects with dynamically defined methods a composed instance its composed 
     Failure/Error: specify { expect(subject.test).to eq true }

     NoMethodError:
       private method `test' called for #<Component:0x007f85f1283f88 @test=true>
     # ./spec/unit/adamantium/dynamic_methods_memoize_spec.rb:48:in `block (4 levels) in <top (required)>'
     # ./vendor/ruby/2.2.0/bundler/gems/devtools-8d492930b9a5/lib/devtools/project/initializer/rspec.rb:48:in `block in enable_unit_test_timeout'

Finished in 0.01913 seconds (files took 0.46045 seconds to load)
5 examples, 2 failures

Failed examples:

rspec ./spec/unit/adamantium/dynamic_methods_memoize_spec.rb:47 # Adamantium memoizing methods that initialize objects with dynamically defined methods a composed instance its composed should respond to #test
rspec ./spec/unit/adamantium/dynamic_methods_memoize_spec.rb:48 # Adamantium memoizing methods that initialize objects with dynamically defined methods a composed instance its composed 

I apologise for not having provided a solution, unfortunately I do not have the time to investigate the issue any further at this moment, but I hope that the spec I provided might help you investigate the issue for future releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant