edraut / coney_island

An industrial-strength background worker system for Rails using RabbitMQ.
MIT License
7 stars 0 forks source link

Settings class inheritance #4

Closed darkside closed 9 years ago

darkside commented 9 years ago

Right now defining set_background_defaults on a base class doesn't stick for their subclasses. We need to make the coney_settings hash a proper class attribute. This PR aims to fix that by allowing defaults to be passed on a base class and optionally refining these on subclasses, so something like this would work:

class MyWorker
  set_background_defaults work_queue: "my-queue", timeout: 30
end

class MyOtherWorker < MyWorker
  set_background_defaults timeout: 10
end
darkside commented 9 years ago

@edraut @gomayonqui can you guys take a look at this failure? I've been debugging for hours, can't for the life of me figure out where the [] is coming from, it seems it doesn't even pass by the MySingleton#perform

1) Error: async methods#test_0003_responds to async methods on singletons: MockExpectationError: expected perform("interesting stuff") => nil, got [] minitest (5.5.1) lib/minitest/mock.rb:100:in block (2 levels) in verify' minitest (5.5.1) lib/minitest/mock.rb:96:ineach' minitest (5.5.1) lib/minitest/mock.rb:96:in block in verify' minitest (5.5.1) lib/minitest/mock.rb:95:ineach' minitest (5.5.1) lib/minitest/mock.rb:95:in verify' /home/darkside/work/staunchrobots/coney_island/test/performer_test.rb:90:inblock (2 levels) in class:PerformerTest' minitest (5.5.1) lib/minitest/test.rb:108:in block (3 levels) in run' minitest (5.5.1) lib/minitest/test.rb:206:incapture_exceptions' minitest (5.5.1) lib/minitest/test.rb:105:in block (2 levels) in run' minitest (5.5.1) lib/minitest/test.rb:258:intime_it' minitest (5.5.1) lib/minitest/test.rb:104:in block in run' minitest (5.5.1) lib/minitest.rb:327:inon_signal' minitest (5.5.1) lib/minitest/test.rb:278:in with_info_handler' minitest (5.5.1) lib/minitest/test.rb:103:inrun' minitest (5.5.1) lib/minitest.rb:774:in run_one_method' minitest (5.5.1) lib/minitest.rb:301:inrun_one_method' minitest (5.5.1) lib/minitest.rb:289:in block (2 levels) in run' minitest (5.5.1) lib/minitest.rb:288:ineach' minitest (5.5.1) lib/minitest.rb:288:in block in run' minitest (5.5.1) lib/minitest.rb:327:inon_signal' minitest (5.5.1) lib/minitest.rb:314:in with_info_handler' minitest (5.5.1) lib/minitest.rb:287:inrun' minitest (5.5.1) lib/minitest.rb:150:in block in __run' minitest (5.5.1) lib/minitest.rb:150:inmap' minitest (5.5.1) lib/minitest.rb:150:in __run' minitest (5.5.1) lib/minitest.rb:127:inrun' minitest (5.5.1) lib/minitest.rb:56:in `block in autorun'

edraut commented 9 years ago

@darkside, I believe the error message for expectations is cryptic. I can't recall exactly, but when it says it got [] it probably doesn't mean what you think. The empty array represents the params that should have been passed into the method, I think. ie. the call was made but with no params or the wrong params?

edraut commented 9 years ago

this is super weird. Tomorrow I'm going to do a live test of the same scenario and see if I can get it to break or work.

darkside commented 9 years ago

@edraut but this is the return value, isn't it? The perform is just an empty method, it should be returning nil. I even pried #perform and it never gets called, I am at a loss.

We can try to debug this together tomorrow.

edraut commented 9 years ago

:+1: