<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[I'm Steve Hodgkiss]]></title>
  <link href="http://yoursite.com/atom.xml" rel="self"/>
  <link href="http://yoursite.com/"/>
  <updated>2015-01-11T14:59:20+01:00</updated>
  <id>http://yoursite.com/</id>
  <author>
    <name><![CDATA[Steve Hodgkiss]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Sharing a Screen Session With Other System Administrators]]></title>
    <link href="http://yoursite.com/blog/2015/01/11/sharing-a-screen-session-with-other-system-administrators/"/>
    <updated>2015-01-11T14:37:35+01:00</updated>
    <id>http://yoursite.com/blog/2015/01/11/sharing-a-screen-session-with-other-system-administrators</id>
    <content type="html"><![CDATA[<!--more-->


<p>Create a named screen session:</p>

<pre><code>steve@machine:~$ screen -S lhm
</code></pre>

<p>Or, name your existing session:</p>

<pre><code>Ctrl-a :sessionname lhm
</code></pre>

<p>Turn on screens multi user mode and give access to the root user:</p>

<pre><code>Ctrl-a :multiuser on
Ctrl-a :acladd root
</code></pre>

<p>Now any admin user can attach to this screen session with the following command:</p>

<pre><code>sudo screen -x steve/lhm
</code></pre>

<p>This is useful when you want to give other admin users the ability to view and control a long running task that you started.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Testing Rails 3 Generators With RSpec]]></title>
    <link href="http://yoursite.com/blog/2015/01/11/testing-rails-3-generators-with-rspec/"/>
    <updated>2015-01-11T14:12:09+01:00</updated>
    <id>http://yoursite.com/blog/2015/01/11/testing-rails-3-generators-with-rspec</id>
    <content type="html"><![CDATA[<p>Rails provides an easy way to test generators with test/unit, but what if you’re using RSpec?</p>

<!--more-->


<p>One approach is to <a href="http://blog.codegram.com/2011/2/cucumber-plus-ad-hoc-apps-to-test-rails-3-generators">use aruba</a> to generate a new Rails app, run bundle install, run your generator then verify it did the right thing. The problem with this approach is that it’s really, really slow. The approach <code>Rails::Generators::TestCase</code> takes is to run the generator in the current process against a temporary directory. This is much faster.</p>

<p>Today I released <a href="https://github.com/stevehodgkiss/generator_spec">generator_spec</a> for testing generators with RSpec. It’s  a thin wrapper around <code>Rails::Generators::TestCase</code>, with the same assertions and setup methods available. It also comes with a really nice file structure matcher.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>require "generator_spec/test_case"
</span><span class='line'>
</span><span class='line'>describe InstallGenerator do
</span><span class='line'>  include GeneratorSpec::TestCase
</span><span class='line'>  destination File.expand_path("../../tmp", __FILE__)
</span><span class='line'>  
</span><span class='line'>  before do
</span><span class='line'>    # Methods from Rails::Generators::TestCase are made available to the RSpec test
</span><span class='line'>    prepare_destination
</span><span class='line'>    run_generator
</span><span class='line'>  end
</span><span class='line'>
</span><span class='line'>  specify do
</span><span class='line'>    destination_root.should have_structure {
</span><span class='line'>      no_file "non_existant.rb"
</span><span class='line'>      directory "config" do
</span><span class='line'>        directory "initializers" do
</span><span class='line'>          file "mygem.rb" do
</span><span class='line'>            contains "# Change this"
</span><span class='line'>          end
</span><span class='line'>        end
</span><span class='line'>      end
</span><span class='line'>      directory "db" do
</span><span class='line'>        directory "migrate" do
</span><span class='line'>          migration "create_tests" do
</span><span class='line'>            contains "class TestMigration"
</span><span class='line'>          end
</span><span class='line'>        end
</span><span class='line'>      end
</span><span class='line'>    }
</span><span class='line'>  end
</span><span class='line'>end</span></code></pre></td></tr></table></div></figure>

]]></content>
  </entry>
  
</feed>
