4 ms·
I'd be very interested to know what you mean by "nothing short of magic". I've had a quick look at the rspec documentation and as a Python dev this looks very s
by fred123 9y ago
I'd be very interested to know what you mean by "nothing short of magic". I've had a quick look at the rspec documentation and as a Python dev this looks very similar to what's in the Python standard library. Would that be considered magic as well or does rspec have some cool features that I have missed?
- chrisseaton 9y agorspec’s internal DSL is based on Ruby’s multi-line anonymous functions. I don’t know how you achieve a similar design in Python where you don’t have those in the same way. How do you write the equivalent of ‘it ‘does something’ do ... end’ in Python syntax?
- pmontra 9y agoThis seems a good starting point https://stackoverflow.com/questions/37334668/is-there-a-python-equivalent-for-rspec-to-do-tdd https://stackoverflow.com/questions/37334668/is-there-a-pyth... TLDR: not as nice as RSpec but close.
- chrisseaton 9y ago> not as nice as RSpec Right, well that probably answers the question about what they thought the magic is.
- WJW 9y agoNote how I said compiled languages, I expect Python to have some very similar capabilities. :) But as an example, take the cleanness of the following mock: allow_any_instance_of(Set).to receive(:member?).and_return(true) <rest of test code> Contrast this for example with testing IO monad code in Haskell, where the best practice is to define a new monad 'underneath' your original monad stack, rewrite all your functions signatures to have a type constraint (of your new MonadIO type) and then switch out functions for their mocked equivalent as required by the test. Rspec can do the same switching out on any object or class, without any code required outside the test code. (Although as far as "handle with care" goes, monkeypatching the 'send' method has to score pretty high)