[rspec-users] need some advice on the best way to structure testable shared methods
Patrick J. Collins
patrick at collinatorstudios.com
Mon Nov 14 21:42:12 EST 2011
> 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 functionality.
The .new(nil, nil) is because the initialize method of the classes that include
the module have expected arguments... I supposed I could have done
def initialize(arg1 = nil, arg2 = nil)
to prevent having to do Bar.new(nil, nil) in the test, but I actually would
rather the init method have actual argument expectations.
Patrick J. Collins
http://collinatorstudios.com
More information about the rspec-users
mailing list