Using Bundler To Create Gems With Rspec

Posted by mhagedorn on October 31st, 2011 filed in Uncategorized
Comment now »

Suppose you want to start gem development, and you want to use bundler to generate your skeleton gem.  Great!   Now what about the tests?  I wanted to know how to add Rspec to my basic gem and get going.

Here are the steps I used:

bundler gem fooster

Then edit the generated Gemfile (fooster/Gemfile) to add rspec as a dependency

s.adddevelopmentdependency "rspec"

Then create the spec directory to hold your specs

mkdir fooster/rspec

Then create the fooster/spec/spec_helper.rb file

require 'rubygems'

require 'bundler/setup'

require 'fooster' # and any other gems you need

RSpec.configure do |config|
  # some (optional) config here
end

I use guard to autorun my specs, so make sure that is installed (optional)

gem install guard

gem install rspec-guard

cd fooster

guard init rspec

Then create your first spec

#fooster/spec/fooster_spec.rb

require 'spec_helper'

describe Fooster do
  pending 'write it'
end

Then execute guard

guard


Using git-svn with remote branches

Posted by mhagedorn on April 20th, 2011 filed in git
Comment now »

I am writing this as a note to myself, because I always forget how to set this up.   I have found it surprisingly hard and tricky to get  local git branches to map to remote svn branches.   Not sure why this is really, but have put together these notes as to how to get it to work “normally” from the git side and magically map to the appropriate remote branch on the remote svn side.

Assume your upstream svn repo is stored at https://svn2.code.com/svn/myproject

First clone the repo: git svn clone https://svn2.code.com/svn/myproject –stdlayout

(stdlayout tells the git svn client to assume the existence of trunk, branches and tags in the upstream repo, most people do this)

after it finishes you will have a directory myproject with trunk checked out in it

git branch -r will show you the upstream (svn) branches

working on a remote branch is as easy as git checkout  -b newlocalbranch nameofremoteupstreambranch

you can see which upstream branch is connected to the local git branch by doing a git log


My Talk on Rails3 for Rails2 Programmers

Posted by mhagedorn on May 12th, 2010 filed in Uncategorized
1 Comment »

Last nite I gave a presentation at houston.rb about Rails3 for the person doing Rails2 currently.   Lots of folks showed up and the good folks from Squegee bought pizza.   A good time was had by all.  Lots of people wanted a link to the slides so I have included them here


Running HTTPS in your Rails Development Environment

Posted by mhagedorn on September 29th, 2009 filed in Rails
3 Comments »

If you are building a rails application that requires SSL for parts of your site, you are probably going to use the SSL requirement plugin. But that alone isn’t going to allow you to run your code in development. You can easily see this after you enable the SSL Requirement plugin (suddenly nothing will work). Your single mongrel instance is going to need some help in order to be able process https requests! I wanted a simple way to allow my rails development process to continue normally and still have https protected code.

Read the rest of this entry »


Announcing the migrate_war Rails plugin

Posted by mhagedorn on April 17th, 2008 filed in Rails
1 Comment »

The MigrateWar Rails plugin makes it easy to create database schema on deployment machines when you deploy via JRuby/War Files. This is especially helpful on Windows machines, where you cannot use Capistrano easily.

Capistrano is a powerful deployment tool that is considered ‘state of the practice’ by anyone deploying Rails applications to Unixy type systems. But what about if you need some of that same Capistrano fu on a windows server. Can it be done? In my case I really needed a way to build my database schema on the deployment target as soon as the application was deployed (cap deploy with migrations basically). This isnt such an easy thing to do as I found. I was going to deploy via JRuby/Goldspike in a War file format (the standard java deployment package), so I dusted off my arcane Java knowledge and came up with a solution to load the schema.rb file as soon as the war file loads. Read on for details.

Read the rest of this entry »


Ruby on Rails Contractor: I am Available! (One of the Advanced Rails Recipes Book contributors )

Posted by mhagedorn on April 12th, 2008 filed in Uncategorized
2 Comments »

I just posted this to craigslist:

I am web developer who specializes in Ruby on Rails contracts and works remotely from my home office. Currently looking for new projects, I’m open to conversations about new contract possibilities. My company is Silverchair Solutions, an agile web development consultancy. I have over 13 years of web development experience and two and a half years of Rails experience. Recently some of my work was published in the Advanced Rails Recipes book (Pragmatic Programmers – see the wizard chapter!). I am a former Oracle DBA and am very comfortable designing databases as well as configuring linux/mac os servers in support of my web applications.

To learn more about me, view my Linkedin profile here:

Working with Rails Profile

If you have a project that you think I may be able to help you with, please send me an email with a short description of what it is you need done and we will chat!

Thanks, Mike


I’m an Author!

Posted by mhagedorn on April 12th, 2008 filed in Rails
Comment now »

Ok its been awhile since this occurred, but I would be remiss if I didn’t mention that I have been included as one of the authors of the Pragmatic Studio’s Advanced Rails Recipes Book. I contributed a chapter on creating Wizards. You can check it out here. Basically I leveraged actsasstate_machine to pull this off. Check it out!


Using your website url as your OpenID

Posted by mhagedorn on March 12th, 2008 filed in OpenId
Comment now »

I have an OpenId, I have found it useful. But frankly its just another thing that I have to remember. Somthing that I can’t forget is my website url. What if you could set up some kind of cool forwarding that allows me to use my website url as my OpenID? Well… you can. Actually if you just have a blog and not a full blown website, this will work too.

Add some entries to the head section of the index page of your website


`<link rel="openid.server" href="http://www.myopenid.com/server" />
<link rel="openid.delegate" href="http://your.real.openid.com/" />'

Where, the openid.server is the url of your provider, and the openid.delegate is your real openid identity.

This trick will work with any resource you have access to on the internet, i.e. anything where you could add information to the head portion of your index page. Many thanks to Duncan Davidson for this tip


Automating Cocoa Deployments with Sparkle and Xcode

Posted by mhagedorn on March 7th, 2008 filed in Cocoa
Comment now »

For those of us who live in the rails world, fantastic tools like Capistrano have made deployment drop-dead simple. And since I do some Cocoa work I found myself wanting some of that same capistrano-esqe love in my Cocoa deployments. The Sparkle framework handles most of this for you, but in its vanilla implementation requires you to hand code some descriptor files and this seemed problematic to me. So I have cooked up an Xcode based recipe which allows me to do push button deploys and let Sparkle handle the updating part.

Read the rest of this entry »


State Transition Diagrams for acts_as_state_machine

Posted by mhagedorn on March 5th, 2008 filed in Rails
1 Comment »

Lately I have been using the wonderful acts_as_state_machine plugin for lots of cool stuff in my rails applications. The problem that I have run into though, is visualizing the state transitions that I have created. Typically, when I first learned about state machines back in Electrical Engineering days, we drew cool diagrams with bubbles to represent the states and arrows to show the state transitions (a.k.a state transition diagrams). I have found these to be very helpful. But I wanted to a way to automatically create these.

Read the rest of this entry »