<?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: Plain Text Stories on Rails</title>
    <link>http://blog.davidchelimsky.net/articles/2007/10/22/plain-text-stories-on-rails</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>on software in process and practice</description>
    <item>
      <title>Plain Text Stories on Rails</title>
      <description>&lt;p&gt;Since my last post on &lt;a href="http://blog.davidchelimsky.net/articles/2007/10/21/story-runner-in-plain-english"&gt;plain text stories&lt;/a&gt;, there have already been a few improvements, not the least of which is that it will now work with Rails. Again, this is trunk (rev 2769+) only and experimental.&lt;/p&gt;


	&lt;p&gt;Here&amp;#8217;s a working example from an app that I&amp;#8217;m working on:&lt;/p&gt;


stories/login
&lt;pre&gt;Story: registered user logs in
  As a registered user
  I want to have to log in
  So that only other registered users can see my data

  Scenario: user logs in and sees welcome page
    Given a user registered with login: foo and password: test
    When user logs in with login: foo and password: test
    Then user should see the welcome page

  Scenario: user logs in with wrong password
    Given a user registered with login: foo and password: test
    When user logs in with login: foo and password: wrong
    Then user should see the login form
    And page should include text: There was an error logging in.

  Scenario: user logs in with wrong login name
    Given a user registered with login: foo and password: test
    When user logs in with login: wrong and password: test
    Then user should see the login form
    And page should include text: There was an error logging in.
&lt;/pre&gt;

	&lt;p&gt;&lt;span style="color:red;"&gt;[Update: modified to use runner.steps instead of runner.step_matchers]&lt;/span&gt;&lt;/p&gt;


stories/login.rb
&lt;pre&gt;&lt;code&gt;require File.join(File.dirname(__FILE__), *%w[helper])

run_story :type =&amp;gt; RailsStory do |runner|
  runner.steps &amp;lt;&amp;lt; LoginSteps.new
  runner.steps &amp;lt;&amp;lt; NavigationSteps.new
  runner.load File.expand_path(__FILE__).gsub(".rb","")
end
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Here&amp;#8217;s what&amp;#8217;s new in this example:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;run_story is added to the main object so you don&amp;#8217;t have to remember that silly path to the PlainTextStoryRunner which will undoutedbly change!&lt;/li&gt;
		&lt;li&gt;run_story accepts arguments, including an options hash, which it will pass to the constructor of the PlainTextStoryRunner (in this case, :type =&amp;gt; RailsStory)&lt;/li&gt;
		&lt;li&gt;run_story yields the runner, which now supports a load method which you use to tell it where to find the plain text story file.&lt;/li&gt;
		&lt;li&gt;run_story &amp;#8230; runs the story&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Keep your eyes peeled for more updates in the coming days.&lt;/p&gt;</description>
      <pubDate>Mon, 22 Oct 2007 23:44:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:fd13e429-85d4-48d5-977b-c84c525bdffd</guid>
      <author>David</author>
      <link>http://blog.davidchelimsky.net/articles/2007/10/22/plain-text-stories-on-rails</link>
      <category>rspec</category>
      <category>bdd</category>
      <category>stories</category>
      <category>rails</category>
    </item>
    <item>
      <title>"Plain Text Stories on Rails" by Hussein Morsy</title>
      <description>&lt;p&gt;Realy awesome work !!!.&lt;/p&gt;


	&lt;p&gt;Does the new plain text story funktion in trunk support other languanges than english ?&lt;/p&gt;</description>
      <pubDate>Wed, 24 Oct 2007 10:31:15 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:8d4adf5e-9f57-4f7c-9503-19158988c16b</guid>
      <link>http://blog.davidchelimsky.net/articles/2007/10/22/plain-text-stories-on-rails#comment-342</link>
    </item>
    <item>
      <title>"Plain Text Stories on Rails" by Aslak HellesÃ¸y</title>
      <description>&lt;p&gt;The story continues: &lt;a href="http://blog.aslakhellesoy.com/2007/10/24/in-browser-editor-for-rspec-stories" rel="nofollow"&gt;In-browser editor for RSpec stories&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 24 Oct 2007 04:25:40 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:c5d4a19c-606d-483f-8d44-528dc3843000</guid>
      <link>http://blog.davidchelimsky.net/articles/2007/10/22/plain-text-stories-on-rails#comment-341</link>
    </item>
    <item>
      <title>"Plain Text Stories on Rails" by David Chelimsky</title>
      <description>&lt;p&gt;Pat &amp;#8211; good point.&lt;/p&gt;</description>
      <pubDate>Tue, 23 Oct 2007 13:31:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:0ef3d7e0-69e7-402a-83e3-2a9ec857613b</guid>
      <link>http://blog.davidchelimsky.net/articles/2007/10/22/plain-text-stories-on-rails#comment-338</link>
    </item>
    <item>
      <title>"Plain Text Stories on Rails" by Pat Maddox</title>
      <description>&lt;p&gt;hrm&amp;#8230;in the case of AdminStepMatchers, I would think you should require login_step_matchers.rb (or whatever) inside the file that defines AdminStepMatchers&lt;/p&gt;</description>
      <pubDate>Tue, 23 Oct 2007 13:17:10 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:db9fb181-66b6-4f20-bc80-23537fbae812</guid>
      <link>http://blog.davidchelimsky.net/articles/2007/10/22/plain-text-stories-on-rails#comment-337</link>
    </item>
    <item>
      <title>"Plain Text Stories on Rails" by David Chelimsky</title>
      <description>&lt;p&gt;Andy: That&amp;#8217;s a good suggestion, but it presents a couple of problems.&lt;/p&gt;


	&lt;p&gt;For one, it imposes a convention of calling the subdirectory steps (really, they are step_matchers) and assuming that it is flat. I&amp;#8217;m using step_matchers and I&amp;#8217;m already playing w/ directory hierarchies below that.&lt;/p&gt;


	&lt;p&gt;So we definitely wouldn&amp;#8217;t want to do this until a convention emerges definitively.&lt;/p&gt;


	&lt;p&gt;Even then, there&amp;#8217;s another, more substantial problem: because you can create hierarchies of StepMatchers (which I&amp;#8217;ve been doing with some success &amp;#8211; admittedly only for a day, but success none-the-less), load order is meaningful. As soon as AdminStepMatchers extends LoginStepMatchers, we need to ensure that LoginStepMatchers loads first.&lt;/p&gt;</description>
      <pubDate>Tue, 23 Oct 2007 10:06:45 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:25072aa0-46ae-4ec4-bfce-67e0f074505d</guid>
      <link>http://blog.davidchelimsky.net/articles/2007/10/22/plain-text-stories-on-rails#comment-336</link>
    </item>
    <item>
      <title>"Plain Text Stories on Rails" by Andy Watts</title>
      <description>&lt;p&gt;Thanks again David.  Works great!&lt;/p&gt;


	&lt;p&gt;Minor gotcha.  For requiring the step libraries, I added the following to my stories/helper.rb&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;Dir[File.join(File.dirname(&lt;i&gt;FILE&lt;/i&gt;), &amp;#8220;steps/*.rb&amp;#8221;)].each do |file|
  require file
end&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;Should &lt;i&gt;&amp;#8216;ruby script/generate rspec&amp;#8217;&lt;/i&gt;  do this?&lt;/p&gt;</description>
      <pubDate>Tue, 23 Oct 2007 08:47:10 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:4ca5623c-c8b8-41c1-99ba-0e668ffd05d9</guid>
      <link>http://blog.davidchelimsky.net/articles/2007/10/22/plain-text-stories-on-rails#comment-335</link>
    </item>
    <item>
      <title>"Plain Text Stories on Rails" by Pat Maddox</title>
      <description>&lt;p&gt;David will you adopt me?&lt;/p&gt;</description>
      <pubDate>Tue, 23 Oct 2007 01:59:57 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:1239903f-7ffd-4003-acea-b3b93cfce734</guid>
      <link>http://blog.davidchelimsky.net/articles/2007/10/22/plain-text-stories-on-rails#comment-333</link>
    </item>
  </channel>
</rss>
