factory_trace icon indicating copy to clipboard operation
factory_trace copied to clipboard

[WIP] Add `enum` support

Open chubchenko opened this issue 2 years ago • 2 comments

FB_TRACE_FILE=integration-test-results.txt bundle exec rspec spec/factory_trace/integration_tests/empty_spec.rb
An error occurred in an `after(:suite)` hook.
Failure/Error: return if trait.has_prioritized_status?(status)

NoMethodError:
  undefined method `has_prioritized_status?' for nil:NilClass
# ./lib/factory_trace/processors/find_unused.rb:90:in `mark_trait'
# ./lib/factory_trace/processors/find_unused.rb:47:in `block (2 levels) in mark_as_used'
# ./lib/factory_trace/processors/find_unused.rb:45:in `each'
# ./lib/factory_trace/processors/find_unused.rb:45:in `block in mark_as_used'
# ./lib/factory_trace/processors/find_unused.rb:41:in `each'
# ./lib/factory_trace/processors/find_unused.rb:41:in `mark_as_used'
# ./lib/factory_trace/processors/find_unused.rb:14:in `call'
# ./lib/factory_trace.rb:56:in `stop'
# ./lib/integrations/rspec.rb:5:in `block (2 levels) in <top (required)>'
FactoryTrace
  uses nothing (FAILED - 1)

Failures:

  1) FactoryTrace uses nothing
     Failure/Error:
       def initialize(name, definition_path, &block)
         @definition_path = definition_path
         super(name, &block)
       end

     ArgumentError:
       wrong number of arguments (given 1, expected 2)
     # ./lib/factory_trace/monkey_patches/trait.rb:8:in `initialize'
     # gems/factory_bot-6.2.0/lib/factory_bot/enum.rb:22:in `new'
     # gems/factory_bot-6.2.0/lib/factory_bot/enum.rb:22:in `build_trait'
     # gems/factory_bot-6.2.0/lib/factory_bot/enum.rb:11:in `block in build_traits'
     # gems/factory_bot-6.2.0/lib/factory_bot/enum.rb:10:in `each'
     # gems/factory_bot-6.2.0/lib/factory_bot/enum.rb:10:in `map'
     # gems/factory_bot-6.2.0/lib/factory_bot/enum.rb:10:in `build_traits'
     # gems/factory_bot-6.2.0/lib/factory_bot/definition.rb:168:in `block in expand_enum_traits'
     # gems/factory_bot-6.2.0/lib/factory_bot/definition.rb:167:in `each'
     # gems/factory_bot-6.2.0/lib/factory_bot/definition.rb:167:in `expand_enum_traits'
     # gems/factory_bot-6.2.0/lib/factory_bot/definition.rb:50:in `compile'
     # gems/factory_bot-6.2.0/lib/factory_bot/factory.rb:87:in `compile'
     # gems/factory_bot-6.2.0/lib/factory_bot/factory_runner.rb:14:in `run'
     # gems/factory_bot-6.2.0/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method'
     # ./spec/factory_trace/integration_tests/empty_spec.rb:5:in `block (2 levels) in <top (required)>'

chubchenko avatar May 09 '22 13:05 chubchenko

Also, I would like to mention that this PR is still in progress. At that moment I'm still getting an error which is in the PR title. But to figure out the problem I need some time since we are having a big amount of factories and tests and it takes some time.

chubchenko avatar May 18 '22 09:05 chubchenko

Also, I would like to mention that this PR is still in progress. At that moment I'm still getting an error which is in the PR title. But to figure out the problem I need some time since we are having a big amount of factories and tests and it takes some time.

I see, thank you for doing such a great work! Let me know if I can anyhow help you, I'll do my best to find time for that.

djezzzl avatar May 18 '22 13:05 djezzzl

Hello!

Just sharing with you that this issue shouldn't be a problem anymore with version 1.1.0 I have just released.

Please let me know if it still fails for you. Meanwhile, I'm closing the PR.

djezzzl avatar Jun 11 '23 13:06 djezzzl