3 ms·
As a Ruby/RoR noob and Python/JS slightly-better-than-noob, I felt a flicker of recognition reading this. One of my bigger WTF? moments going through that Hartl
by tragic 13y ago
As a Ruby/RoR noob and Python/JS slightly-better-than-noob, I felt a flicker of recognition reading this. One of my bigger WTF? moments going through that Hartl book recently (which I enjoyed and found very helpful) was, to adapt the author's example (excuse the half remembered syntax)
let(:burger) { Burger.new }
expect(burger.sauce).to .....
Where'd the bloody colon go? I said let(:burger), not let(burger). What happened to my burger? I'm most comfortable with Python, I should say, but I still think that's rather confusing wherever you come from. When I let something represent an object, I expect it to be that something, not a slightly different something. (Beginner-level tutorials on Ruby/Rails, generally, tend to glide neatly over what symbols are - which doesn't help, although it's perfectly googlable.)
Generally with these Ruby DSLs I have the problem that it's 'read-only code': the more they try to look like natural language, the more fiddly it is to write. is it "should not_have" or "should_not have"? I don't know, and nothing I know about the natural English it's supposed to resemble will tell me where the underscore goes, or what bit of the overall statement should be in parentheses. It's far less intuitive than just writing run-of-the-mill code. I suppose it's fine, once you're used to it. And I count myself among those who pine for a Python RSpec, so whatever.