Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
require File.dirname(__FILE__) + '/../test_helper' def default_options(options = {}) { :user_id => 3829, :featured_by=> 2, :corkd_take => "Rules", :start_date => Date.today + 14, :end_date => Date.today + 21 }.merge(options) end context "A generic Featured User object" do specify "should return the correct user for today" do FeaturedUser.current.should.not.be.nil end specify "should return the correct user for another day" do FeaturedUser.featured_on(Date.today + 1).should.not.be.nil end specify "should return nil for a blank range" do FeaturedUser.featured_on(Date.today + 14).should.be.nil end specify "should get a list of days / users for a given month" do days_users = FeaturedUser.featured_for_month(Time.now.month, Time.now.year) # days_users.should.include? "simplebits" # days_users.index("simplebits").should.be Today.now.day end end context "A featured user creation attempt should fail" do setup do @featured_user = FeaturedUser.new(default_options) end specify "without a user_id" do @featured_user.user_id = nil @featured_user.should.not.validate end specify "without a featuring person" do @featured_user.featured_by = nil @featured_user.should.not.validate end specify "without a cork'd take" do @featured_user.corkd_take = nil @featured_user.should.not.validate end specify "without a start date" do @featured_user.start_date = nil @featured_user.should.not.validate end specify "without an end date" do @featured_user.end_date = nil @featured_user.should.not.validate end specify "with conflicting dates" do @featured_user.start_date = Time.now - 1.week @featured_user.should.not.validate end specify "with dates that are within another ranges dates" do @featured_user.start_date = Time.now - 1.week + 300 @featured_user.end_date = Time.now + 1.week - 300 @featured_user.should.not.validate end specify "with reversed dates" do @featured_user.start_date = Time.now + 2.weeks @featured_user.end_date = Time.now + 1.week @featured_user.should.not.validate end end context "A featured user creation attempt should succede" do setup do @featured_user = FeaturedUser.new(default_options) end specify "with everything as it should be" do @featured_user.should.validate end end
This paste will be private.
From the Design Piracy series on my blog: