Conversation
|
I think this is better suited as a plugin gem. I'd be happy to help you get that started if you'd like. After, please send a pull request listing the new gem in the readme and I'll merge and republish my doco so people can find it easier. |
|
@zenspider well, I decided that this can live as a method in SimpleForm specs. Not sure this one little feature deserve a gem :) |
|
Just out of curiosity @zenspider , what is the reason for not having this in the core? I understand that we can't put everything in core but I would find it more useful to have this method instead of some shortcuts like This is not a rant by the way, I am pretty sure there is a reason, like a downside or something and I'd like to know what it is. Cheers, |
|
@mig-hub and you can have that method... as a plugin. |
|
@zenspider, yes I know there is a plugin, I use it sometimes. Believe it or not, I am hoping to learn something from you. I'd like to know if you would use this plugin for your own test or not for example. Or maybe you think it is not necessarily a good way to test in the first place, and that would interest me as well. The thing is that minitest is very simple to understand indeed and at the end of the day, knowing what to test and how to test it is a much harder task, at least for me. I realised that people (including me) often end up wanting more features because they don't necessarily use their tool in the best way possible. This is the reason why I try to read the tests of minitest itself a lot. Could you please give me your insight on this subject? Cheers, |
|
It's not a move, because it was never added. Personally, I never use mocks and I almost never use stubs (and when I do, it's most often via |
|
I share @zenspider's opinion that Even if you do use mocks, you should be able to inject a mock and control what's happening. |
|
Thank you so much @zenspider and @zamith, this exactly the kind of answer I was after. Mainly because I started to have doubts about it. There are some edge cases where define_method(name) do |*args|
if val_or_callable.respond_to? :call then
instance_exec(*args, &val_or_callable)
else
val_or_callable
end
endIt breaks because the mocked method responds to I find the balance between testing only one thing at a time and not testing the implementation very hard. I probably would trade any testing framework for a good book which contains the truth about testing. Only half joking here, but this is why I value the code maintainers' vision as much as the code itself. Anyway, sorry for keeping this outdated thread alive. Thank you guys for taking the time to answer my questions. |
Because sometimes we want to stub some method on all instances of the class.
@zenspider wdyt? Should this be in minitest or it can live as a helper or something? (we have it as helper already in SimpleForm)