[rspec-users] (no subject)

rupert rupert_apsc at rupespad.com
Tue Aug 14 16:46:58 EDT 2007


On 14/8/07 21:30, "Scott Taylor" <mailing_lists at railsnewbie.com> wrote:
 > How would you spec out something like the following:
 >
 > def a_method
 >    x = Class.new do
 >      include Enumerable
 >    end
 >
 >    # do something here with x
 > end
 >
 >
 > describe "The Anonymous Class" do
 >
 >    before :each do
 >      @anonymous_class = mock Class
 >      Class.stub!(:new).and_return @anonymous_class
 >    end
 >
 >    it "should create a new anonymous class" do
 >      Class.should_receive(:new)
 >      a_method
 >    end
 >
 >    it "should include Enumerable" do
 >      #... what goes here?
 >    end
 >
 > end

Not being an expert, so apply the relevant pinches of salt! ...but if  
you're including enumerable, then it must be so that you can  
enumerate the class, so would the behavior driven approach be that  
you would test the enumerable behavior you wish the class to exhibit  
rather than the implementation of enabling this behavior by including  
the enumerable module.

Cheers

Rupert


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070814/0379a970/attachment-0001.html 


More information about the rspec-users mailing list