[rspec-users] Getting Class in Shared Behaviours

Ben Mabey ben at benmabey.com
Wed Nov 21 23:14:12 EST 2007


I like what Scott suggested.

it_should_behave_like "a foo", :with => { ... }

Might read a little better.  But I like the idea of it just taking a hash.

-Ben


Nathan Sutton wrote:
> Anyone else have any opinions on this?  I'd like to get some more input.
>
> Thanks,
>
> Nathan Sutton
> fowlduck at gmail.com
> rspec edge revision 2910
> rspec_on_rails edge revision 2909
> rails edge revision 8175
>
>
>
> On Nov 21, 2007, at 4:58 PM, Scott Taylor wrote:
>
>   
>> On Nov 21, 2007, at 5:42 PM, Nathan Sutton wrote:
>>
>>     
>>> Not even sure, what are your thoughts?
>>>
>>> Nathan Sutton
>>> fowlduck at gmail.com
>>> rspec edge revision 2910
>>> rspec_on_rails edge revision 2909
>>> rails edge revision 8175
>>>
>>>       
>> I'd like to see something like this:
>>
>>
>> it_should_behave_like "a foo", :variables => {
>>   :bar => "bar",
>>   :baz => "baz",
>>   :class => Object
>> }
>>
>>
>> describe "a foo", :shared => true do
>>
>>   it "should have the variable bar there, equal to bar" do
>>     bar.should == "bar"
>>   end
>>
>> end
>>
>> Conceivably, you could do some metaprogramming to define methods
>> "bar" and "baz" in the ExampleGroupClass (or whatever that thing is
>> called now) to return the values give in the hash.
>>
>> Scott
>>
>>
>>
>>
>>     
>>> On Nov 21, 2007, at 4:31 PM, Scott Taylor wrote:
>>>
>>>       
>>>> On Nov 21, 2007, at 5:16 PM, Nathan Sutton wrote:
>>>>
>>>>         
>>>>> Ooh, I totally want to do this, I'll work on it this week along  
>>>>> with
>>>>> my other patch i have yet to submit this week, unless Scott is
>>>>> partial
>>>>> to doing it.  Do you want it, Scott?
>>>>>           
>>>> Go for it.  Let me know if you don't want it.
>>>>
>>>> What is the syntax your thinking of?
>>>>
>>>> Scott
>>>>
>>>> _______________________________________________
>>>> rspec-users mailing list
>>>> rspec-users at rubyforge.org
>>>> http://rubyforge.org/mailman/listinfo/rspec-users
>>>>         
>>> _______________________________________________
>>> rspec-users mailing list
>>> rspec-users at rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/rspec-users
>>>       
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>>     
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>   



More information about the rspec-users mailing list