<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Andy Waite - Home</title>
  <id>tag:andywaite.com,2010:mephisto/</id>
  <generator uri="http://mephistoblog.com" version="0.8.0">Mephisto Drax</generator>
  <link href="http://andywaite.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://andywaite.com/" rel="alternate" type="text/html"/>
  <updated>2010-04-19T21:08:12Z</updated>
  <entry xml:base="http://andywaite.com/">
    <author>
      <name>andy</name>
    </author>
    <id>tag:andywaite.com,2010-04-19:22</id>
    <published>2010-04-19T21:06:00Z</published>
    <updated>2010-04-19T21:08:12Z</updated>
    <link href="http://andywaite.com/2010/4/19/htframework" rel="alternate" type="text/html"/>
    <title>HTFramework</title>
<content type="html">
            &lt;p&gt;HTFramework is a framework of re-usable components for happier iPhone OS development: &lt;a href=&quot;http://github.com/huddletech/HTFramework/&quot;&gt;http://github.com/huddletech/HTFramework/&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://andywaite.com/">
    <author>
      <name>andy</name>
    </author>
    <id>tag:andywaite.com,2009-12-28:10</id>
    <published>2009-12-28T21:46:00Z</published>
    <updated>2009-12-28T22:10:03Z</updated>
    <category term="heroku"/>
    <category term="hobo"/>
    <link href="http://andywaite.com/2009/12/28/deploying-a-hobo-app-to-heroku" rel="alternate" type="text/html"/>
    <title>Deploying a Hobo app to Heroku</title>
<content type="html">
            &lt;p&gt;Hobo and Heroku make for a killer combination for getting your app built and deployed in record time.&lt;/p&gt;


	&lt;p&gt;These instructions are for Hobo 0.9.102. If you&#8217;re using an older version the steps may differ.&lt;/p&gt;


&lt;pre&gt;
$ hobo myapp
$ cd myapp
$ git init
$ heroku create yourappname
&lt;/pre&gt;

	&lt;p&gt;Create a &lt;code&gt;.gems&lt;/code&gt; file, since Hobo isn&#8217;t pre-installed on Heroku:&lt;/p&gt;


&lt;pre&gt;
hobo --version 0.9.102
&lt;/pre&gt;

	&lt;p&gt;It is recommend to specify a particular version of any gem you use, in case a future release isn&#8217;t fully backwards compatible. (There&#8217;s no longer any need to specify &lt;em&gt;will_paginate&lt;/em&gt; here.)&lt;/p&gt;


	&lt;p&gt;Next, create a &lt;code&gt;.gitignore&lt;/code&gt; file:&lt;/p&gt;


&lt;pre&gt;
log/*
db/*.sqlite3
&lt;/pre&gt;

	&lt;p&gt;Generate the database migrations:&lt;/p&gt;


&lt;pre&gt;
$ script/generate hobo_migration
&lt;/pre&gt;

	&lt;p&gt;Choose [m] to &lt;em&gt;migrate now&lt;/em&gt; and give it a name such as &lt;em&gt;create users&lt;/em&gt;.&lt;/p&gt;


	&lt;p&gt;To generate the auto dryml files in &lt;em&gt;app/views/taglibs/auto/&lt;/em&gt;, you&#8217;ll need to access the site once locally. Hobo cannot create these on Heroku because the filesystem is read-only. So run:&lt;/p&gt;


&lt;pre&gt;
$ script/server
&lt;/pre&gt;

	&lt;p&gt;And open &lt;a href=&quot;http://localhost:3000&quot;&gt;http://localhost:3000&lt;/a&gt; in your browser.&lt;/p&gt;


	&lt;p&gt;You can then add all your files into the git repository, and push them to Heroku:&lt;/p&gt;


&lt;pre&gt;
$ git add *
$ git add .gems
$ git add .gitignore
$ git commit -m &quot;initial import&quot; 
$ git push heroku master
&lt;/pre&gt;

	&lt;p&gt;It will take a couple of minutes to install the Hobo gem the first time you deploy, but subsequent deployments will be faster.&lt;/p&gt;


	&lt;p&gt;Next, run the database migration on Heroku:&lt;/p&gt;


&lt;pre&gt;
$ heroku rake db:migrate
&lt;/pre&gt;

	&lt;p&gt;If you don&#8217;t see any error message, then you should be good to go:&lt;/p&gt;


&lt;pre&gt;
$ heroku open
&lt;/pre&gt;

	&lt;p&gt;&lt;strong&gt;Common Problems&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;If you see the Rails &lt;em&gt;&#8220;something went wrong&#8221;&lt;/em&gt; error, use &lt;em&gt;heroku console&lt;/em&gt; to view the error log.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;em&gt;&#8220;relation &#8220;users&#8221; does not exist&#8221;&lt;/em&gt; &#8211; you probably forgot to run &lt;em&gt;heroku rake db:migrate&lt;/em&gt;&lt;/li&gt;
	&lt;/ul&gt;
          </content>  </entry>
  <entry xml:base="http://andywaite.com/">
    <author>
      <name>andy</name>
    </author>
    <id>tag:andywaite.com,2009-12-27:8</id>
    <published>2009-12-27T22:48:00Z</published>
    <updated>2009-12-27T23:05:04Z</updated>
    <category term="cucumber"/>
    <category term="rails"/>
    <link href="http://andywaite.com/2009/12/27/cucumber-scaffolding-for-rails" rel="alternate" type="text/html"/>
    <title>Cucumber Scaffolding for Rails</title>
<content type="html">
            &lt;p&gt;I recently discovered the rspec_scaffold generator, part of rspec_on_rails. It generates a resource just as the normal Rails one does, and rspec tests instead of normal tests, as the example below shows:&lt;/p&gt;


&lt;pre&gt;
$ script/generate rspec_scaffold person name:string admin:boolean birthday:date
      exists  app/models/
      exists  app/controllers/
      exists  app/helpers/
      create  app/views/people
      exists  app/views/layouts/
      exists  public/stylesheets/
      exists  spec/controllers/
      exists  spec/routing/
      exists  spec/models/
      exists  spec/helpers/
      exists  spec/fixtures/
      create  spec/views/people
      exists  spec/integration/
      create  app/views/layouts/people.html.erb
   identical  public/stylesheets/scaffold.css
      create  spec/routing/people_routing_spec.rb
      create  spec/controllers/people_controller_spec.rb
      create  app/controllers/people_controller.rb
      create  spec/helpers/people_helper_spec.rb
      create  app/helpers/people_helper.rb
      create  app/views/people/index.html.erb
      create  app/views/people/show.html.erb
      create  app/views/people/new.html.erb
      create  app/views/people/edit.html.erb
      create  app/models/person.rb
      create  spec/fixtures/people.yml
      create  spec/models/person_spec.rb
      create  spec/views/people/edit.html.erb_spec.rb
      create  spec/views/people/index.html.erb_spec.rb
      create  spec/views/people/new.html.erb_spec.rb
      create  spec/views/people/show.html.erb_spec.rb
      create  spec/integration/people_spec.rb
      exists  db/migrate
      create  db/migrate/20091227214143_create_people.rb
       route  map.resources :people
&lt;/pre&gt;

	&lt;p&gt;But unlike the normal tests, these aren&#8217;t just skeleton files. They include a wide range of tests for the model and it&#8217;s controller, views and routes.&lt;/p&gt;


The thing that&#8217;s missing is an integration test, such as the following Cucumber feature:
&lt;pre&gt;
Feature: Manage people

  Scenario: List people
    Given a person exists with name &quot;Homer Simpson&quot; 
      And a person exists with name &quot;Bart Simpson&quot; 
    When I go to the people page
    Then the title should be &quot;People: index&quot; 
      And the heading should be &quot;Listing people&quot; 
      And I should see &quot;Homer Simpson&quot; 
      And I should see &quot;Bart Simpson&quot; 

  Scenario: View person
    Given a person exists with name &quot;Homer Simpson&quot; 
    When I go to the people page
      And I follow &quot;Show&quot; 
    Then I should be on the page for that person
      And the title should be &quot;People: show&quot; 
      And I should see &quot;Homer Simpson&quot; against &quot;Name:&quot; 

  Scenario: New person
    Given I am on the people page
    When I follow &quot;New person&quot; 
    Then I should be on the new person page
      And the title should be &quot;People: new&quot; 
      And the heading should be &quot;New person&quot; 
      And the person's birthday should be today
      And the person's birthday year range should be from 5 years ago to 5 years from now

  Scenario: Create person
    Given I am on the new person page
    When I fill in &quot;Name&quot; with &quot;Homer Simpson&quot; 
      And I check &quot;admin&quot; 
      And I select &quot;December 31, 2007&quot; as the &quot;Birthday&quot; date
      And I press &quot;Create&quot; 
    Then I should be on the page for person &quot;Homer Simpson&quot; 
      And I should see &quot;Homer Simpson&quot; against &quot;Name:&quot; 
      And I should see &quot;true&quot; against &quot;Admin:&quot; 
      And I should see &quot;2007-12-31&quot; against &quot;Birthday:&quot; 
      And I should see &quot;Person was successfully created.&quot; 

  Scenario: Back from new person page
    Given I am on the new person page
    When I follow &quot;Back&quot; 
    Then I should be on the people page

  Scenario: Back from edit person page
    Given a person exists with name &quot;Homer Simpson&quot; 
    When I go to the edit page for that person
      And I follow &quot;Back&quot; 
    Then I should be on the people page

  Scenario: Show from edit person page
    Given a person exists with name &quot;Homer Simpson&quot; 
    When I go to the edit page for that person
      And I follow &quot;Show&quot; 
    Then I should be on the page for that person

  Scenario: Edit from show person page
    Given a person exists with name &quot;Homer Simpson&quot; 
    When I go to the page for that person
      And I follow &quot;Edit&quot; 
    Then I should be on the edit page for that person

  Scenario: Edit person
    Given a person exists with name &quot;Homer Simpson&quot; 
      And that person is admin
      And that person has &quot;birthday&quot; date &quot;February 14, 2010&quot; 
    When I go to the people page
      And I follow &quot;Edit&quot; 
    Then I should be on the edit page for that person
      And the title should be &quot;People: edit&quot; 
      And the heading should be &quot;Editing person&quot; 
      And the &quot;name&quot; field should contain &quot;Homer Simpson&quot; 
      And the &quot;admin&quot; checkbox should be checked
      And the person's birthday should be &quot;February 14, 2010&quot; 

  Scenario: Update person
    Given a person exists with name &quot;Homer Simpson&quot; 
      And that person is admin
    When I go to the edit page for that person
      And I fill in &quot;name&quot; with &quot;Homer J Simpson&quot; 
      And I uncheck &quot;admin&quot; 
      And I press &quot;Update&quot; 
    Then I should be on the page for person &quot;Homer J Simpson&quot; 
      And I should see &quot;Person was successfully updated.&quot; 
      And I should see &quot;Homer J Simpson&quot; against &quot;Name:&quot; 
      And I should see &quot;false&quot; against &quot;Admin:&quot; 
&lt;/pre&gt;

	&lt;p&gt;I wrote the above manually but I plan to automate this and turn it into a gem eventually, so that you&#8217;ll be able to do something like this:&lt;/p&gt;


&lt;pre&gt;
$ script/generate cucumber_scaffold person name:string admin:boolean birthday:date
&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://andywaite.com/">
    <author>
      <name>andy</name>
    </author>
    <id>tag:andywaite.com,2009-12-26:2</id>
    <published>2009-12-26T00:50:00Z</published>
    <updated>2009-12-26T15:40:37Z</updated>
    <category term="heroku"/>
    <category term="mephisto"/>
    <link href="http://andywaite.com/2009/12/26/installing-mephisto-on-heroku" rel="alternate" type="text/html"/>
    <title>Installing Mephisto on Heroku</title>
<content type="html">
            &lt;p&gt;Since &lt;a href=&quot;http://heroku.com&quot;&gt;Heroku&lt;/a&gt; apps run in a &lt;a href=&quot;http://docs.heroku.com/constraints#read-only-filesystem&quot;&gt;read-only filesystem&lt;/a&gt;, the normal &lt;a href=&quot;http://mephistoblog.com/&quot;&gt;Mephisto&lt;/a&gt; installation method won&#8217;t work. Here&#8217;s how to work around that.&lt;/p&gt;


	&lt;p&gt;Begin by cloning Mephisto in the usual way:&lt;/p&gt;


&lt;pre&gt;
$ git clone git://github.com/emk/mephisto.git
$ cd mephisto
&lt;/pre&gt;

	&lt;p&gt;And prepare the database configuration:&lt;/p&gt;


&lt;pre&gt;
$ cp config/database.example.yml config/database.yml
&lt;/pre&gt;

	&lt;p&gt;Normally the next step would be to run &lt;code&gt;rake db:bootstrap&lt;/code&gt; which modifies and creates a few files. Since we can&#8217;t do this on Heroku, we&#8217;ll create them locally and add them to the respository.&lt;/p&gt;


	&lt;p&gt;The behaviour in the development environment differs from production, so we need to run in production mode locally.&lt;/p&gt;


	&lt;p&gt;If you have mysql running setup, create a new database named &lt;em&gt;mephisto_production&lt;/em&gt;. Alternatively, just define a sqlite connection:&lt;/p&gt;


&lt;pre&gt;
production:
  adapter: sqlite3
  database: db/mephisto_production
&lt;/pre&gt;

	&lt;p&gt;You can now bootstrap the app:&lt;/p&gt;


&lt;pre&gt;
$ rake db:bootstrap RAILS_ENV=production
&lt;/pre&gt;

	&lt;p&gt;This will modify session_store.rb and create a few other files/folders, but &lt;code&gt;git status&lt;/code&gt; won&#8217;t show them since they are excluded by &lt;em&gt;.gitignore&lt;/em&gt;. Use the &lt;code&gt;-f&lt;/code&gt; flag to force add them:&lt;/p&gt;


&lt;pre&gt;
$ git add config/initializers/session_store.rb -f
$ git add themes/ -f
$ git add public/plugin_assets/ -f
$ git commit -m &quot;adding required files for Heroku&quot; 
&lt;/pre&gt;

	&lt;p&gt;You&#8217;re now ready to deploy onto Heroku:&lt;/p&gt;


&lt;pre&gt;
$ heroku create yourblogname
$ git push heroku master
$ heroku rake db:bootstrap
&lt;/pre&gt;

	&lt;p&gt;I&#8217;m not sure why, but at this point you need to restart your app or you&#8217;ll get an error message:&lt;/p&gt;


&lt;pre&gt;
$ heroku restart
&lt;/pre&gt;

	&lt;p&gt;You can then view the site in your browser and you should see Mephisto running.&lt;/p&gt;


&lt;pre&gt;
$ heroku open
&lt;/pre&gt;

	&lt;p&gt;&lt;strong&gt;Notes&lt;/strong&gt;&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;The above instructions will deploy the edge version of Mephisto rather than the v0.8-stable branch which the official site recommends, but I haven&#8217;t yet worked out how to deploy a particular branch to Heroku.&lt;/li&gt;
		&lt;li&gt;Some features will not work on Heroku, such as installing/editing themes or uploading assets. You will need to do this locally and then add the appropriate files to the git repository.&lt;/li&gt;
	&lt;/ol&gt;
          </content>  </entry>
</feed>
