4 ms·
Spec-me-maybe: Introduces the “maybe” syntax to RSpec
- jordanwallwork 12y agoIs this serious or a joke? If its serious I seems like a bloody awful idea!! What is the point of a maybe test??
- artursapek 12y agoThe epitome of programming in Ruby.
- eric_h 12y agoOh for goodness sake. It's a joke.
- artursapek 12y agohttp://api.rubyonrails.org/classes/ActiveSupport/HashWithIndifferentAccess.html http://api.rubyonrails.org/classes/ActiveSupport/HashWithInd...
- akerl_ 12y agoYou may want to further expand whatever point you're trying to make. That seems like a perfectly reasonable class; there are plenty of times where I'm receiving input from multiple sources, such as combining default options where keys are symbols with human input where keys are strings.
- bronson 12y agoYou're not making any sense.
- rubiquity 12y agoThis has to be a joke. I'm fond of TDD just as much as the next person, but seriously, some of you RSpec fanatics have lost your minds.
- speric 12y agoPretty sure it's a joke.
- rubiquity 12y agoThank god.
- stevewilhelm 12y agoSorry, it has to be said: After some inspection, maybe it passes for a joke.
- rubiquity 12y agoMaybe.
- btables 12y agoI promise its a joke. I work with this gent and we were frustrated with some specs so he said he was going to make this. haha.
- ZirconCode 12y agoI find it quite funny that people cannot tell whether this is a joke or not, just says something about the state of things...
- andreasklinger 12y agoIf people don't get it we should maybe just retry it.
- gavingmiller 12y agoIt does; considering situations where this would be seen as a realistic/novel approach for fixing flapping tests. No need to examine root cause! sigh
- rubiquity 12y agoIt does. Especially considering the fact that RSpec itself was created as a joke solution to the "I wish my tests were more human readable" meme several years ago. Hopefully that sheds some light on why some of us might be hyper-sensitive about it.
- srbaker 12y agoThat's not quite true. I created RSpec (in early 2005) to draw people's attention away from the word "test" because it was a huge hangup while I was teaching TDD. I kept hearing "You can't test something that doesn't exist, therefore your entire idea is bunk." I wanted to introduce TDD to people without ever using the word "test", and then switch them to using xUnit instead. Not a joke, but I guess you could reasonably describe RSpec as a tool for performing a good old fashioned bait and switch. In a classroom. (I never intended for it to be used outside of a classroom setting.) Around the time I was looking for ways to "teach TDD without using the word", Aslak Hellesøy introduced me to Dan North's ideas of Behaviour Driven Development. That's where the word "should" came from. I don't know if it was actually Aslak or Dan (or possibly even Liz Keogh) that first used the word "should", but that wasn't my idea. Also, I'll point out that mixing #should onto Object wasn't my fault. The original syntax looked very close to the expect().to() syntax of today. It was actually assert(foo).does_equal(bar) at one point, and this was the syntax I was most fond of. I tried dozens of different combinations. "#should" was one of many, and I didn't like it. It got released this way because I was talked into it after that variant was demonstrated (by someone else) to a positive audience. People liked it. RSpec took off. Whoops. I later said on twitter, jokingly, that RSpec was a huge troll. That was kind of a joke on a joke. RSpec wasn't a joke, but I didn't build it for actual use. That was a happy accident. That said, it's a great tool these days, if a bit heavy. And it has certainly served my original wish of teaching many people TDD very well. My $0.02 on the "maybe" syntax: if you need this, I suspect your problems are a lot larger than whether or not an assertion will pass or fail. It's symptom solving.
- jxf 12y agoWhile this is obviously a joke, I can see it having a limited amount of practical value. Imagine, for example, being tasked with updating a poorly-maintained legacy code base with a large number of indeterminately failing specs containing order dependencies. You could `RSpec::Maybe` everything until you're sure you have the order dependencies resolved, then convert to regular `RSpec::Expectation`s.
- Dorian-Marie 12y agoThat's the usecase of `pending`
- shawabawa3 12y agopending might as well not be there. how many maybes passed could be useful information - perhaps 80% is good enough to be confident it works, but if it's 20% something's gone wrong
- steveklabnik 12y agoPending is really useful: it can also tell you if a test that you expected to be passing is now failing. It's also useful for hiding output for tests that are temporarily failing, until you fix them all. I'll often spec out a whole behavior, with ten or fifteen tests, and then mark all but one pending, make that one pass, unmark another one, make that pass, unmark another... it's easier to focus on just the one you're working on rather than 19 other failing outputs. Committing a pending test? yeah, that's bad.
- deleted 12y ago[deleted]
- bryanlarsen 12y agoThis may be a joke, but there are valid scenarios for this sort of thing, which is why rspec has pending and skipped tests: https://relishapp.com/rspec/rspec-core/v/3-1/docs/pending-and-skipped-examples https://relishapp.com/rspec/rspec-core/v/3-1/docs/pending-an...
- michaelmior 12y agoThere are valid scenarios for having a test which is expected to fail in some settings. But of course you should always know why a test might fail and be explicit. (Which is exactly what pending and skipped tests are for.)
- shittyanalogy 12y agoI can see wondering if this was a joke as 'maybe' is mildly reminiscent of promise[1] and the like but if you got to .on_my_machine and still couldn't figure it out, you got some 'splainin to do. :) [1] http://blogs.msdn.com/b/ie/archive/2011/09/11/asynchronous-programming-in-javascript-with-promises.aspx http://blogs.msdn.com/b/ie/archive/2011/09/11/asynchronous-p...
- pluma 12y agoThere's also the Maybe monad, which is a good substitute for null.
- adamors 12y agoThis is really funny, thanks for sharing.
- harrylove 12y agoit 'probably should not raise any sort of error' do maybe { user }.will_not raise_error end I snorted on that one.
- btables 12y agoI promise its a joke. I work with this gent and we were frustrated with some specs so he said he was going to make this. haha.
- tvon 12y agoEverything should also take `.maybe.it_wont` at the end, for completeness.
- davidcelis 12y agoseems legit. i'll take a look at it, maybe
- thekylemontag 12y agomaybe(test).will be_success.on_my_machine I can’t stop laughing right now. Well done boys, well done.
- ubertaco 12y agoLove the build status badge. Nice touch.
- deleted 12y ago[deleted]