On Nov 14, 2011, at 4:57 PM, Patrick J. Collins wrote:
>
> Can anyone suggest a better way?
Really tough to follow that example, so apologies if I'm off.
I use the template method pattern for stuff like this. My shared example group
references a method that isn't implemented. Example groups tha
On Nov 14, 2011, at 11:59 PM, Patrick J. Collins wrote:
>> Use the described class:
>>
>> shared_examples "a nameable thingie" do |klass|
>> describe "#build_name" do
>>it "it adds the collection of arguments to the base components and
>> formats them for a form element name attribute" do
>
> Use the described class:
>
> shared_examples "a nameable thingie" do |klass|
> describe "#build_name" do
> it "it adds the collection of arguments to the base components and
> formats them for a form element name attribute" do
> described_class.new(nil,nil).build_name(:lol, :lollers
On Nov 14, 2011, at 6:57 PM, Patrick J. Collins wrote:
> So, I recognize that there are many different ways to accomplish what I am
> trying to do, but none of them seem to be as elegant as I would like.
>
> I have a few classes which need to have shared functionality...
>
> So I could do someth
> Having trouble following your example. Why do you have to pass
> Bar.new(nil, nil) for this test?
Because the shared example is testing the method #build_name from the module
that is included in the various classes-- it needs the object that #build_name
is attached to in order to test the funct
Quoting Patrick J. Collins :
> describe Bar do
> it_behaves_like "a nameable thingie", Bar.new(nil, nil)
> end
>
> Which I don't like, mainly because Foo & Bar's initialize methods require
> arguments, and I am having to do (nil, nil) which seems very uncool...
Having trouble following your exa
So, I recognize that there are many different ways to accomplish what I am
trying to do, but none of them seem to be as elegant as I would like.
I have a few classes which need to have shared functionality...
So I could do something like this:
module NameBuilder
def build_name(*args)
args