8 ms·
Ruby's optional parenthesis for function calls. Makes beautiful DSLs like RSpec - describe UsersController do before do allow(controller).to receiv
by amthewiz 8y ago
Ruby's optional parenthesis for function calls. Makes beautiful DSLs like RSpec -
describe UsersController do
before do
allow(controller).to receive(:current_user).and_return(nil)
end
describe "GET #new" do
subject { get :new }
it "returns success" do
expect(subject).to be_success
end
end
end
- kjeetgill 8y agoBut I love the brace free dsl. It's pretty. How van you tell how many tokens it takes? Describe or subject take? It's a bit hard to parse, but I don't know Ruby. Coming from Python the end end end hurts though. Why not just use braces then?