<?xml version="1.0" encoding="UTF-8"?>
<wiki>
  <body>&lt;ul&gt;
	&lt;li&gt;Flows move through a Site&amp;#8217;s Pages&lt;/li&gt;
	&lt;li&gt;Flows help &lt;span class=&quot;caps&quot;&gt;DRY&lt;/span&gt; up test code&lt;/li&gt;
	&lt;li&gt;Flows can take a hash to pass in values&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you had the following code in a whole lot of places in your tests:&lt;pre&gt;&lt;code&gt;Google.new do |google|
  google.home_page do |home_page|
    home_page.search_field.set &quot;ruby ruby ruby&quot;
    home_page.search_button.click
  end
end&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then it would make sense to pull this out into a method, but methods could have multiple intentions. In this case the abstract intention is to move through the Google site. Taza provides the convention of flows. To pull out the above code into a flow perform the following steps(assuming you&amp;#8217;ve created a google [[Sites]] already):&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;&lt;code&gt;$ ./script/generate flow search google&lt;/code&gt;&lt;/li&gt;
	&lt;li&gt;open ./lib/sites/google/flows/search.rb&lt;/li&gt;
	&lt;li&gt;Do something like &lt;pre&gt;&lt;code&gt;module Google
  class Google &amp;lt; ::Taza::Site
    def search_flow(params={})
      home_page.search_field.set params[:query]
      home_page.search_button.click
    end
  end
end&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
	&lt;li&gt;Rip out the duplicated code and replace it with the flow call&lt;pre&gt;&lt;code&gt;Google.new do |google|
  google.search_flow :query =&amp;gt; &quot;ruby ruby ruby&quot;
end
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Notes&lt;/h3&gt;
&lt;p&gt;Flows tend to work best not to hide code or &lt;span class=&quot;caps&quot;&gt;DRY&lt;/span&gt; it up, but rather to express steps of a test which are not important to the actual tests assertion point. For example, if you want to test the Google Search Results page then it is important to know that a search must be performed but not necessarily how it is performed. Sometimes it is best to keep test code moist instead of completely &lt;span class=&quot;caps&quot;&gt;DRY&lt;/span&gt;.&lt;/p&gt;</body>
  <created-at type="datetime">2009-11-26T22:37:25-08:00</created-at>
  <id type="integer">85583</id>
  <permalink>flows</permalink>
  <repository-id type="integer">59892</repository-id>
  <title>Flows</title>
  <updated-at type="datetime">2009-02-26T12:31:30-08:00</updated-at>
  <user-id type="integer">58060</user-id>
</wiki>
