Upgrade.rdoc in rspec-1.2.8 vs Upgrade.rdoc in rspec-1.2.9

- old
+ new

@@ -1,5 +1,54 @@ += Upgrade to rspec-1.2.9 + +== What's new + +=== spec/spec.opts + +If you have a spec/spec.opts file, the spec command will now use that +automatically as long as you don't include any options on the command line. + +=== let() + +Writing specs tends to follow a regular pattern of using local variables, discovering duplication, and then having to convert to local variables to instance variables by adding an "@" symbol. The let() method assigns the result of a lazy eval'd block as the return value of an instance method using +the same name. This way you can go from this: + + describe Subscription do + it "does something" do + subscription = Subscription.create :limit => 1 + subscription... + end + + it "does something else" do + subscription = Subscription.create :limit => 1 + subscription... + end + end + +to this: + + describe Subscription do + let(:subscription) { Subscription.create :limit => 1 } + + it "does something" do + subscription... + end + + it "does something else" do + subscription... + end + end + +=== its() + +If you're in the habit of writing one-liners using implicit subject, this new +its() feature is for you. Here's the basic idea: + + describe Array do + its(:length) { should == 0 } + end + = Upgrade to rspec-1.2.3-1.2.7 == What's Changed === Matcher DSL @@ -15,15 +64,15 @@ If you're not familiar with this feature, don't worry about it. If you have anything that looks like this: predicate_matchers[:swim] = :can_swim? - + Or this config.predicate_matchers[:swim] = :can_swim? - + Change it to this: Spec::Matchers.define :swim do match do |potential_swimmer| potential_swimmer.can_swim? @@ -61,16 +110,16 @@ === The new matcher DSL works with test/unit (without the rest of rspec) We'll be separating this out to its own gem for rspec 2.0, but for now, just install rspec >= 1.2.1 and add the following to your <tt>test_helper</tt> file: - + require 'spec/expectations' class Test::Unit::TestCase include Spec::Matchers end - + This will add <tt>should()</tt> and <tt>should_not()</tt> to your objects, make all of rspec's built-in matchers available to your tests, INCLUDING rspec's DSL for creating matchers (see below, under Upgrade to rspec-1.2.0) === debugger @@ -79,15 +128,15 @@ in your code: # some code ..... debugger # some more code .... - + ... and using the <tt>--debugger</tt> or <tt>-u</tt> command line option. spec path/to/file.rb --debugger - + = Upgrade to rspec-1.2.0 == What's Changed === WARNINGS @@ -105,10 +154,10 @@ Test::Unit::TestCase as the base ExampleGroup class (which is implicit in rspec-rails) * The matcher protocol has been improved. The old protocol is still supported, but we added support for two new methods that speak a bit more clearly: - + failure_message => failure_message_for_should negative_failure_message => failure_message_for_should_not * All references to rubygems have been removed from within rspec's code.