<?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>Wood for the Trees: Plugin Test Kit: Initial Release</title>
    <link>http://www.mathewabonyi.com/articles/2006/08/09/plugin-test-kit-initial-release</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>struggling to dig life</description>
    <item>
      <title>Plugin Test Kit: Initial Release</title>
      <description>&lt;h3&gt;PluginTestKit (a plugin test development kit)&lt;/h3&gt;


	&lt;p style="text-align:justify;"&gt;Plugins can and, I think, ought to be just like the main application part of your code. Just like your application, it ought to be self-sufficient. You should be able to run tests outside of a specific environment, allowing your plugin to be seen in its proper light. If it doesn&amp;#8217;t work in vacuo, it is prone to design flaws because it is relying on the application from which it came. This is at least the conclusion I came to in writing my own plugins and wanting to develop them outside the application proper. Plugins by their nature should be usable in other current or
future application with relative ease. Sounds too utopian? Maybe.&lt;/p&gt;


	&lt;h3&gt;Introduction&lt;/h3&gt;


	&lt;p style="text-align:justify;"&gt;Seeing as there is no standardised way to test a plugin using a Rails environment beyond directly including it within a Rails application, it is rather difficult to test plugins, whether they are in vacuo or in the vendor/plugins directory of an application. Plugin Test Kit provides the most common environment requirements or piece of environments you need to test your plugin.&lt;/p&gt;


	&lt;p style="text-align:justify;"&gt;There is a generator called plugin_test_kit which does all the library and template copying that you need from the plugin. Whenever you make a new plugin, just call the generator on it and away you go. To upgrade, just act as if you are installing for the first time &amp;#8211; be sure to back up any changes you have &amp;#8211; and overwrite the library files and whichever other files you wish to refresh. The generator can be called both from ./script/generate in a Rails app or from its own ./generate within the plugin&amp;#8217;s root directory.&lt;/p&gt;


	&lt;p style="text-align:justify;"&gt;This plugin will of course evolve as my own needs evolve, but if anyone has a particular assertion, requirement or other feature they would like to see, just ask. Also, any design changes which you&amp;#8217;d like to suggest, I&amp;#8217;m all ears. Most of the design I came up with while writing the &lt;span class="caps"&gt;README&lt;/span&gt;, so it is bound to have flaws.&lt;/p&gt;


	&lt;h3&gt;Installation&lt;/h3&gt;


	&lt;p style="text-align:justify;"&gt;You need to install Plugin Test Kit in your plugins directory. This can be your repository of plugins on which you are working, or the vendor/plugins directory of your Rails application. However, you must use a Rails application to install it first, just like every other plugin. After that point, &lt;span class="caps"&gt;PTK&lt;/span&gt; can start doing its thing.&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_shell "&gt;  $ ./script/plugin source http://mabs29.googlecode.com/svn/trunk/plugins
  $ ./script/plugin install plugin_test_kit

  If you want to move it to a repository of your plugins, outside a Rails app
  $ mv vendor/plugins/plugin_test_kit ../repository/plugins/&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p style="text-align:justify;"&gt;Now you can start using it.&lt;/p&gt;


	&lt;h3&gt;Usage&lt;/h3&gt;


	&lt;p style="text-align:justify;"&gt;You have two options for generating the files from the plugin_test_kit library. The first is using the in-built Rails ./script/generate.&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_shell "&gt;  user:~/ $ cd rails-app
  user:rails-app $ ./script/generate plugin_test_kit wild_chicken
        create  config
        create  fixtures
        create  lib
        create  lib/ptk
        ...
        readme  after_generation&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p style="text-align:justify;"&gt;You also have the option of using the generate script provided in plugin_test_kit. It has been removed of its dependency on a Rails application, allowing you to call it from a repository of plugins divorced from the root of a Rails application.&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_shell "&gt;  user:~/ $ cd repos/plugins/plugin_test_kit
  user:plugin_test_kit $ ./generate plugin_test_kit wild_chicken&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;h3&gt;Afterwards&lt;/h3&gt;


	&lt;p style="text-align:justify;"&gt;Once you have installed the libraries into your own plugin&amp;#8217;s test directory using the generator, you will be presented with additional customisations which you can make. The templates contain further instructions on how to customise each one. You may now treat your test environment pretty much as you would a normal Rails application test.&lt;/p&gt;


	&lt;h3&gt;Enjoy!&lt;/h3&gt;</description>
      <pubDate>Wed, 09 Aug 2006 13:00:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:727447e3-6c16-444c-9511-720e11f8e0ce</guid>
      <author>Mathew Abonyi</author>
      <link>http://www.mathewabonyi.com/articles/2006/08/09/plugin-test-kit-initial-release</link>
      <category>Rails</category>
      <trackback:ping>http://www.mathewabonyi.com/articles/trackback/18</trackback:ping>
    </item>
    <item>
      <title>"Plugin Test Kit: Initial Release" by Henrik N</title>
      <description>&lt;p&gt;Running into another issue:&lt;/p&gt;


	&lt;p&gt;Pretty minimal test case at  &lt;a href="http://pastie.textmate.org/90972.&lt;/p" rel="nofollow"&gt;http://pastie.textmate.org/90972.&lt;/a&gt;&lt;/p&gt;&gt;


	&lt;p&gt;In PTK&amp;#8217;s &lt;code&gt;route.rb&lt;/code&gt;, I do &lt;code&gt;map.resources :foos&lt;/code&gt;.&lt;/p&gt;


	&lt;p&gt;If I make an integration test that does &lt;code&gt;get "/foos"&lt;/code&gt;, though, &lt;code&gt;assert_response :success&lt;/code&gt; fails due to a &lt;code&gt;0&lt;/code&gt; response code.&lt;/p&gt;


	&lt;p&gt;However, the &lt;code&gt;controller&lt;/code&gt; attribute of the test session is set correctly, and if I explictly trigger &lt;code&gt;controller.index&lt;/code&gt;, the response is successful.&lt;/p&gt;


	&lt;p&gt;Thankful for any help/hints.&lt;/p&gt;</description>
      <pubDate>Sat, 25 Aug 2007 19:21:18 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:7aee9fec-9979-4ad4-b717-593e65a61c60</guid>
      <link>http://www.mathewabonyi.com/articles/2006/08/09/plugin-test-kit-initial-release#comment-667</link>
    </item>
    <item>
      <title>"Plugin Test Kit: Initial Release" by Henrik N</title>
      <description>&lt;p&gt;Hum. Nevermind, I suppose. After installing/uninstalling Rails gems for a bit, it seems to work now.&lt;/p&gt;</description>
      <pubDate>Sat, 25 Aug 2007 18:16:36 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:ebc5462d-3783-4355-a1a4-ecea6b489a85</guid>
      <link>http://www.mathewabonyi.com/articles/2006/08/09/plugin-test-kit-initial-release#comment-665</link>
    </item>
    <item>
      <title>"Plugin Test Kit: Initial Release" by Henrik N</title>
      <description>&lt;p&gt;Seems this is exactly what I need, but I can&amp;#8217;t get it working.&lt;/p&gt;


	&lt;p&gt;I generated (using the edge Rails generator) a new app. I then installed PTK, copied over my own plugin and generated the PTK files into it.&lt;/p&gt;


In my plugin&amp;#8217;s test dir, I tried running a file (&amp;#8220;simple_test.rb&amp;#8221;) containing only
&lt;pre&gt;&lt;code&gt;
  require File.join(File.dirname(__FILE__), 'ptk_helper')
&lt;/code&gt;&lt;/pre&gt;

First, I got an error to the effect of &amp;#8220;ActiveResource missing&amp;#8221;. After installing that gem (does PTK only work with Gem Rails btw, not vendor/rails?), I now get
&lt;pre&gt;&lt;code&gt;
  Gem::Exception: can't activate activesupport (= 1.4.2), already activated activesupport-1.4.2.7357]

    method activate    in rubygems.rb at line 246
    &#8942;
    method initialize_frameworks    in ptk.rb at line 107
    method process    in ptk.rb at line 97
    method send    in ptk.rb at line 93
    method run    in ptk.rb at line 93
    at top level    in ptk_helper.rb at line 4
    method require    in simple_test.rb at line 5
    at top level    in simple_test.rb at line 5
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Any ideas?&lt;/p&gt;</description>
      <pubDate>Sat, 25 Aug 2007 16:19:04 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:df56e76f-3222-4f8e-bc2d-b7233537d16a</guid>
      <link>http://www.mathewabonyi.com/articles/2006/08/09/plugin-test-kit-initial-release#comment-660</link>
    </item>
  </channel>
</rss>
