Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
# decribe_model_factory(model) # {{{ # # Ensures that a Factory for the specified model can build and create instances of that model. # # Arguments: # -The 'model' arg must be a model class. # # An exception is raised if an argument is invalid. # # Example call: # describe_model_factory User # def describe_model_factory(model) raise 'The 1st argument (model) must be a Model class' unless model.is_a? Class describe model, "factory" do it "should build a valid #{model}" do built_model = Object.send "build_#{model.to_s.downcase}" built_model.should be_valid end it "should create a valid #{model}" do created_model = Object.send "create_#{model.to_s.downcase}" created_model.should be_valid created_model.should == model.find(created_model.id) created_model.destroy end end end # }}}
This paste will be private.
From the Design Piracy series on my blog: