<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>David Chelimsky: Tag nesting</title>
    <link>http://blog.davidchelimsky.net/articles/tag/nesting?tag=nesting</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>on software in process and practice</description>
    <item>
      <title>RSpec 1.1</title>
      <description>&lt;p&gt;The RSpec Development Team is pleased as glug (that&amp;#8217;s kind of like punch, but more festive) to announce RSpec-1.1.0.&lt;/p&gt;


	&lt;p&gt;Thanks to all who have contributed patches over the last few months. Big thanks to Dan North and Brian Takita for their important work on this release. Dan contributed his rbehave framework which is now the Story Runner. Brian patiently did a &lt;span class="caps"&gt;TON&lt;/span&gt; of refactoring around interoperability with Test::Unit, and the result is a much cleaner RSpec core, and a clean adapter model that gets loaded when Test::Unit is on the path.&lt;/p&gt;


	&lt;p&gt;RSpec 1.1 brings four significant changes for RSpec users:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;The RSpec Story Runner&lt;/li&gt;
		&lt;li&gt;Nested Example Groups&lt;/li&gt;
		&lt;li&gt;Support for Rails 2.0.1&lt;/li&gt;
		&lt;li&gt;Test::Unit interoperability&lt;/li&gt;
	&lt;/ul&gt;


	&lt;h4&gt;Story Runner&lt;/h4&gt;


	&lt;p&gt;The RSpec Story Runner is Dan North&amp;#8217;s rbehave framework merged into RSpec. The Story Runner is a framework for expressing high level requirements in the form of executable User Stories with Scenarios that represent Customer Acceptance Tests.&lt;/p&gt;


	&lt;p&gt;RSpec 1.1 also ships with a Ruby on Rails extension called RailsStory, which lets you write executable user stories for your rails apps as well.&lt;/p&gt;


	&lt;h4&gt;Nested Example Groups&lt;/h4&gt;


	&lt;p&gt;Now you can nest groups to organize things a bit better:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
describe RubyDeveloper do

  before(:each) do
    @ruby_developer = RubyDeveloper.new
  end

  describe "using RSpec 1.1.0" do

    before(:each) do
      @ruby_developer.use_rspec('1.1.0')
    end

    it "should be able to nest example groups" do
      @ruby_developer.should be_able_to_nest_example_groups
    end

  end

  describe "using RSpec 1.0.1" do

    before(:each) do
      @ruby_developer.use_rspec('1.0.8')
    end

    it "should not be able to nest example groups" do
      @ruby_developer.should_not be_able_to_nest_example_groups
    end

  end

end
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Running this outputs:&lt;/p&gt;


&lt;pre&gt;
RubyDeveloper using RSpec 1.1.0
- should be able to nest example groups

RubyDeveloper using RSpec 1.0.8
- should not be able to nest example groups
&lt;/pre&gt;

	&lt;p&gt;== Support for Rails 2.0.1&lt;/p&gt;


&lt;pre&gt;
gem install rails
rails myapp
ruby script/plugin install http://rspec.rubyforge.org/svn/tags/REL_1_1_0/rspec
ruby script/plugin install http://rspec.rubyforge.org/svn/tags/REL_1_1_0/rspec_on_rails
script/generate rspec
&lt;/pre&gt;

	&lt;h4&gt;Test::Unit Interoperability&lt;/h4&gt;


	&lt;p&gt;Contrary to popular belief, Spec::Rails, RSpec&amp;#8217;s Ruby on Rails plugin, has been a Test::Unit wrapper since the the 0.7 release in November of 2006. RSpec 1.1 ups the ante though, offering a smooth transition from Test::Unit to RSpec with or without Rails:&lt;/p&gt;


	&lt;p&gt;1. Start with a TestCase:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
require 'test/unit'

class TransitionTest &amp;lt; Test::Unit::TestCase
  def test_should_be_smooth
    transition = Transition.new(
      :from =&amp;gt; "Test::Unit::TestCase",
      :to =&amp;gt; "Spec::ExampleGroup" 
    )
    assert_equal "really smooth", transition.in_practice
  end
end
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;2. Require &amp;#8216;spec&amp;#8217;&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
require 'test/unit'
require 'spec'

class TransitionTest &amp;lt; Test::Unit::TestCase
  def test_should_be_smooth
    transition = Transition.new(
      :from =&amp;gt; "Test::Unit::TestCase",
      :to =&amp;gt; "Spec::ExampleGroup" 
    )
    assert_equal "really smooth", transition.in_practice
  end
end
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;3. Convert TestCase to ExampleGroup&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
require 'test/unit'
require 'spec'

describe "transitioning from TestCase to ExampleGroup" do
  def test_should_be_smooth
    transition = Transition.new(
      :from =&amp;gt; "Test::Unit::TestCase",
      :to =&amp;gt; "Spec::ExampleGroup" 
    )
    assert_equal "really smooth", transition.in_practice
  end
end
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;4. Convert test methods to examples&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
require 'test/unit'
require 'spec'

describe "transitioning from TestCase to ExampleGroup" do
  it "should be smooth" do
    transition = Transition.new(
      :from =&amp;gt; "Test::Unit::TestCase",
      :to =&amp;gt; "Spec::ExampleGroup" 
    )
    assert_equal "really smooth", transition.in_practice
  end
end
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;5. Convert assertions to expectations&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
require 'test/unit'
require 'spec'

describe "transitioning from TestCase to ExampleGroup" do
  it "should be smooth" do
    transition = Transition.new(
      :from =&amp;gt; "Test::Unit::TestCase",
      :to =&amp;gt; "Spec::ExampleGroup")
    transition.in_practice.should == "really smooth" 
  end
end
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;6. Un-require test/unit&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
require 'spec'

describe "transitioning from TestCase to ExampleGroup" do
  it "should be smooth" do
    transition = Transition.new(
      :from =&amp;gt; "Test::Unit::TestCase",
      :to =&amp;gt; "Spec::ExampleGroup" 
    )
    transition.in_practice.should == "really smooth" 
  end
end
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;At every one of these steps after step 2, you can run the file with the ruby command and you&amp;#8217;ll be getting RSpec&amp;#8217;s developer friendly output. This means that you can transition things as gradually as you like: no wholesale changes.&lt;/p&gt;


	&lt;p&gt;That&amp;#8217;s the story. Thanks again to all who contributed and to all who continue do so.&lt;/p&gt;</description>
      <pubDate>Fri, 14 Dec 2007 01:54:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:b6a53656-3940-4e59-9441-6cfbf21ff18d</guid>
      <author>David</author>
      <link>http://blog.davidchelimsky.net/articles/2007/12/14/rspec-1-1</link>
      <category>rspec</category>
      <category>bdd</category>
      <category>nesting</category>
      <category>rails</category>
      <category>testunit</category>
    </item>
    <item>
      <title>Nested Example Groups</title>
      <description>&lt;p&gt;Since rspec first appeared on the scene, users have been asking for nested example groups. Well it has finally arrived. RSpec 1.1.0 will ship with support for nesting, so you&amp;#8217;ll be able to do things like this:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
describe RSpec do
  before(:each) do
    @rspec = RSpec.new
  end

  describe "at release 1.0.8" do
    before(:each) do
      @rspec.version = "1.0.8" 
    end

    it "should not support nested example groups" do
      @rspec.should_not support_nested_example_groups
    end
  end

  describe "at release 1.1.0" do
    before(:each) do
      @rspec.version = "1.1.0" 
    end

    it "should support nested example groups" do
      @rspec.should support_nested_example_groups
    end
  end
end
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;This will output:&lt;/p&gt;


&lt;pre&gt;
RSpec at release 1.0.8
- should not support nested example groups

RSpec at release 1.1.0
- should support nested example groups
&lt;/pre&gt;

	&lt;p&gt;If you&amp;#8217;re using trunk, you can do this now with revision 3009 or later.&lt;/p&gt;


	&lt;p&gt;Happy nesting!&lt;/p&gt;</description>
      <pubDate>Thu, 29 Nov 2007 03:58:18 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:58d65c28-96b2-4df5-8a23-a83da13a0147</guid>
      <author>David</author>
      <link>http://blog.davidchelimsky.net/articles/2007/11/29/nested-example-groups</link>
      <category>rspec</category>
      <category>bdd</category>
      <category>nesting</category>
      <category>1.1.0</category>
    </item>
  </channel>
</rss>
