Sometimes I don’t have a full need to make a class to do something,
yet I want something readable and concise. This is influenced from the
joys of JavaScript.
Today I made this happen. Love it, like it, hate it, WDYT?
Sometimes I don’t have a full need to make a class to do something,
How’s that essentially different from making a class or extending an
existing class? I am not knowledgeable enough to “just see” it, and
becaus I can’t understand the motivation, I’m bound to hate it.
There is nothing wrong with this, but there are times when it feels
dirty and unnecessary to create yet another class with some methods
The proposed solution looks very nice, but I’ve never been convinced by
the
“yet another class” argument. It’s not like you’re only allowed a
certain
number.
That hasn’t always been the case, however. When I worked at Sierra
On-Line
in the early '90s, I broke the compiler of our proprietary OOP language
because I exceeded its maximum class count. Those were the days…
Sometimes I don’t have a full need to make a class to do something,
How’s that essentially different from making a class or extending an
existing class? I am not knowledgeable enough to “just see” it, and
becaus I can’t understand the motivation, I’m bound to hate it.
The biggest difference is that you can pass the whole thing as an
argument into the method you’re calling (reduce noise, increase
clarity). If you used something like OpenStruct you couldn’t do it,
because in Ruby you can’t force invocation of a Proc object (you have
to call “call” on it).
For example, this wouldn’t work using an OpenStruct:
There is nothing wrong with this, but there are times when it feels
dirty and unnecessary to create yet another class with some methods,
just so the thing can be instantiated one time and passed in as an
argument. That’s why I decided to throw together a little
FunctionalStruct, so if Proc objects got passed in they would be
invokable.
Here’s a more specific example of the different between OpenStruct and
FunctionalStruct:
One thing I miss from JavaScript is that functions are truly first
class citizens. The beauty of Ruby is that I can mimic that by writing
something like FunctionalStruct.
Sometimes I don’t have a full need to make a class to do something,
yet I want something readable and concise. This is influenced from the
joys of JavaScript.
Today I made this happen. Love it, like it, hate it, WDYT?
As mentioned earlier on the RSpec development list, we’re considering
replacing the Story runner with a new implementation:
There is nothing wrong with this, but there are times when it feels
dirty and unnecessary to create yet another class with some methods
The proposed solution looks very nice, but I’ve never been convinced by
the
“yet another class” argument. It’s not like you’re only allowed a
certain
number.
That hasn’t always been the case, however. When I worked at Sierra
On-Line
in the early '90s, I broke the compiler of our proprietary OOP language
because I exceeded its maximum class count. Those were the days…
On Wed, Aug 13, 2008 at 8:29 AM, aslak hellesoy [email protected] wrote:
end
After(:all) do
end
(per-scenarion Before/After is already implemented).
When you say “rather see a similar construct” – are you referring to
having the Before(:all) and After(:all) capability that you posted, or
something similar to what I posted with using a FuncionalStruct as an
argument to register a listener on the existing StoryRunner (a
clear/concise way to hook-in with those one off listeners) ?
As mentioned earlier on the RSpec development list, we’re considering
having the Before(:all) and After(:all) capability that you posted, or
something similar to what I posted with using a FuncionalStruct as an
argument to register a listener on the existing StoryRunner (a
clear/concise way to hook-in with those one off listeners) ?
By “similar construct” I meant something that achievs the same goal
(running pieces of code at different times during the run).
On Wed, Aug 13, 2008 at 11:00 AM, aslak hellesoy [email protected] wrote:
When you say “rather see a similar construct” – are you referring to
)
My suggestion:
Before(:all) do # We can pass args to the block if we want to
Generate.user(:login => “normal user”)
end
Before/After is definitely much cleaner, although I’m not a fan of
more global namespace pollution, but it may not be a problem in
practice (and/or maybe it’s scoped in to another namespace like
Feature::Before(:all))
Are you thinking of allowing for multiple Before/After(:all) blocks?
Today I made this happen. Love it, like it, hate it, WDYT?
I’d rather see a similar construct for Cucumber, which already is
Generate.user(:login => “normal user”)
more global namespace pollution, but it may not be a problem in
practice (and/or maybe it’s scoped in to another namespace like
Feature::Before(:all))
I’ve thought about that a bit, and decided that I want to keep it
global (because it means less typing and looks nicer) until it poses a
problem to someone.
Are you thinking of allowing for multiple Before/After(:all) blocks?