Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
## spec/spec_helper.rb $:.unshift File.dirname(__FILE__) + "/../lib" require 'rubygems' require 'spec' require 'pp' module ZoneParserHax class ParserExampleGroup < Spec::Example::ExampleGroup class << self attr_reader :default_root def parse_from(root) @default_root = root end end attr_reader :parser def parse(input, options = {}) @parser = ZoneFileParser.new if root = (options[:root] || self.class.default_root) parser.root = root end unless options[:consume_all_input].nil? parser.consume_all_input = options.delete(:consume_all_input) end result = parser.parse(input, options) yield result if block_given? result end Spec::Example::ExampleGroupFactory.register(:zone_file_parser, self) end end ## spec/zone_file_parser/ipv4_address_spec.rb require File.dirname(__FILE__) + '/../spec_helper' require 'zone_file_parser' describe ZoneFileParser, "for ipv4_address" do parse_from :ipv4_address it "should return a v4 IPAddr for 202.50.176.19" do parse("202.50.176.19", :root => :ipv4_address) do |result| result.should_not be_nil result.value.should == IPAddr.new("202.50.176.19") end end end
This paste will be private.
From the Design Piracy series on my blog: