RSpec 3 syntax is more verbose.
About twice as many characters to type to stub something:
obj.stub(client: client) # old
allow(obj).to receive(:client).and_return(client) # new
allow(obj).to receive(client: client) # possible? still much longer
allow(obj, client: client) # I might wrap it in this
More characters to type for every single assertion (multiply by number of assertions desired):
obj.should == value
expect(obj).to eq value # +4 characters
obj.should_receive(:method)
expect(obj).to receive(:method) # +4 characters
expect(obj, eq value) # +2 characters and doesn't read as well
# old frowned upon "its" extension, but look how few keystrokes, and how DRY
its(:body) { should include(text) }
# new (via transpec)
describe '#body' do
subject { super().body } # jon would disapprove of this anyway?
it { is_expected.to include(text) } # why is there one _ and one . (says my don't make me think brain)
end
its(:body) { is_expected.to include(text) }
I think there are more examples too.
But you know, I don't so much mind the extra typing, it's probably having to type (
that bugs me. That character is significantly harder to type than .
and ==
.
Was the less metaprogramming, less magical solution worth it?
I have no easy solution to this by the way. Just trying to communicate something I expressed in 140 characters better.
BTW, please ping me on twitter when you reply. I don't seem to get email notification for gist comments. (Not sure why).