cucumber / cucumber-rails

Rails Generators for Cucumber with special support for Capybara and DatabaseCleaner
https://github.com/cucumber/cucumber-rails
MIT License
1.02k stars 327 forks source link

Bug on 2.3.0 and MacOS BigSur message formatter not found #514

Closed tclaus closed 1 year ago

tclaus commented 3 years ago

On My Mac (11.3.1, Intel) and "cucumber-rails", "2.3.0"

running cucumber fails with

undefined method "reject" for #<Cucumber::Configuration:0x00007ff87ceac2f8>
Error creating formatter: message (NoMethodError)
/Users/user/.rvm/gems/ruby-2.6.5@diaspora/gems/attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb:28:in "perform_attribute_assignment"
/Users/user/.rvm/gems/ruby-2.6.5@diaspora/gems/attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb:36:in "assign_attributes"
/Users/user/.rvm/gems/ruby-2.6.5@diaspora/gems/activerecord-5.2.5/lib/active_record/core.rb:315:in "initialize"
/Users/user/.rvm/gems/ruby-2.6.5@diaspora/gems/activerecord-5.2.5/lib/active_record/inheritance.rb:66:in "new"
/Users/user/.rvm/gems/ruby-2.6.5@diaspora/gems/activerecord-5.2.5/lib/active_record/inheritance.rb:66:in "new"
/Users/user/.rvm/gems/ruby-2.6.5@diaspora/gems/cucumber-5.3.0/lib/cucumber/runtime.rb:206:in "create_formatter"
/Users/user/.rvm/gems/ruby-2.6.5@diaspora/gems/cucumber-5.3.0/lib/cucumber/runtime.rb:195:in "block in formatters"
/Users/user/.rvm/gems/ruby-2.6.5@diaspora/gems/cucumber-5.3.0/lib/cucumber/configuration.rb:209:in "block in formatter_factories"
/Users/user/.rvm/gems/ruby-2.6.5@diaspora/gems/cucumber-5.3.0/lib/cucumber/configuration.rb:207:in "map"<
/Users/user/.rvm/gems/ruby-2.6.5@diaspora/gems/cucumber-5.3.0/lib/cucumber/configuration.rb:207:in "formatter_factories"
/Users/user/.rvm/gems/ruby-2.6.5@diaspora/gems/cucumber-5.3.0/lib/cucumber/runtime.rb:194:in "formatters"
/Users/user/.rvm/gems/ruby-2.6.5@diaspora/gems/cucumber-5.3.0/lib/cucumber/runtime.rb:174:in "report"
/Users/user/.rvm/gems/ruby-2.6.5@diaspora/gems/cucumber-5.3.0/lib/cucumber/runtime.rb:76:in "run!"
/Users/user/.rvm/gems/ruby-2.6.5@diaspora/gems/cucumber-5.3.0/lib/cucumber/cli/main.rb:29:in "execute!"
/Users/user/.rvm/gems/ruby-2.6.5@diaspora/gems/cucumber-5.3.0/bin/cucumber:9:in "<top (required)>"
/Users/user/.rvm/gems/ruby-2.6.5@diaspora/bin/cucumber:23:in "load"
/Users/user/.rvm/gems/ruby-2.6.5@diaspora/bin/cucumber:23:in "<main>"
/Users/user/.rvm/gems/ruby-2.6.5@diaspora/bin/ruby_executable_hooks:24:in "eval"

With gem "cucumber-rails", "2.1.0" cucumber runs fine.

Between 2.1.0 and 2.2 the cucumber-messages switched from 12.4.0 to 13.2.1. Maybe this is a hint.

luke-hill commented 3 years ago

Few questions) Are you using a custom formatter you've wrote or one built in? Is your formatter fairly rudimentary or is it more complex. Can you produce an MVCE as a github repo>? Or push a failing test to this repo?

tclaus commented 3 years ago

No, no custom formatter, just built in Pretty and Message. An MVCE runs surprisingly - it must be a setting in our (larger) software. So on my side something is misconfigured. (For reference: it is this project: https://github.com/diaspora/diaspora

But I found out that I've enabled the cucumber Reporting by setting the CUCUMBER_PUBLISH_TOKEN environment var. Without this set, this works.

It works and reports with a lower version than 2.320.

luke-hill commented 3 years ago

Can you create an MVCE on this repo with the variable set? It could be a bug when we are using the cucumber reports functionality.

aurelien-reeves commented 3 years ago

@mattwynne would you have the possibility to reproduce on your own Mac BigSur?

aslakhellesoy commented 3 years ago

This is the last line executed in Cucumber (from the stack trace above):

https://github.com/cucumber/cucumber-ruby/blob/612b07b7e668f9631bd072d611a1265ec7993762/lib/cucumber/runtime.rb#L206

From there it seems to go into some kind of Rails monkey patching for constructors.

https://github.com/rails/rails/blob/cb0a558f42fc6957fac4d2daa16771b72ff7da6e/activerecord/lib/active_record/inheritance.rb#L66

I'm not sure how or why one Cucumber's own classes has extended the ActiveRecord::Inheritance::ClassMethods module. I think understanding this could help fix this bug.

mattwynne commented 3 years ago

It doesn't look to me like the OS has anything to do with this @aurelien-reeves. A Ruby runtime environment should behave the same on any platform, no?

aurelien-reeves commented 3 years ago

It doesn't look to me like the OS has anything to do with this @aurelien-reeves. A Ruby runtime environment should behave the same on any platform, no?

That would be a bug in the Ruby runtime environment 😅

Here as @tclaus and @aslakhellesoy have already noticed, it seems to relate on @tclaus project if I understood well.

mathieujobin commented 3 years ago

@tclaus can you modify cucumber-5.3.0/lib/cucumber/configuration.rb between line 208 and 209 you could add a puts to ensure which formatter class is used here.

puts [format, factory].inspect

tclaus commented 3 years ago

I will try this. Stand bye.

luke-hill commented 3 years ago

@tclaus I had a similar issue as did another user, and we "think" that the auto-inclusion of AS with some of our code may have impacted things.

If you try using cucumber v7+ and cucumber rails 2.4 It could make a difference (Note if you still need AS helpers, you'll need to re-include them).

tclaus commented 3 years ago

With adding the puts line suggested by @mathieujobin I get this output:

["pretty", Cucumber::Formatter::Pretty] Factory: Cucumber::Formatter::Pretty Formatter_options: {} Path: # ["message", Message(id: integer, conversation_id: integer, author_id: integer, guid: string, text: text, created_at: datetime, updated_at: datetime)] Factory: Message Formatter_options: {} Path: https://messages.cucumber.io/api/reports -X GET -H "Authorization: Bearer 8462dbd3-XXX-XXX-YYY.." undefined method `reject' for #

tclaus commented 3 years ago

Same effect on cucumber-rails 2.4.0

luke-hill commented 3 years ago

Can you confirm that you also upgraded to cucumber v7+

luke-hill commented 2 years ago

ping @tclaus did you ever get around to creating an MVCE for this. I know you confirmed this is a bug on cucumber-rails 2.4.0