Learning Rails part 3 - Using RSpec

So I've been going at this Rails things for a few days now and I learned a lot. One of the things I discovered is how you can make developing applications easier in Rails with the help of some test-driven development techniques.

There's a lot of stuff you can do to test your application. The lazy method would be to invest your time in manually testing your application. There are however plenty of other options that will save you large amounts of time. I've tried a few things myself and I learned that there's really no need to manually test your rails applications. 99% of all test work can be done fully automated.

Learning Rails part 2: Guard yourself

After working a few days on my project in Rails I learned something. Having to work with the terminal to execute commands against your Rails project is nice, since you can do some crazy stuff. It's also the most annoying thing ever.

I like to live preview my work on the UI. Which means that I have a terminal running the rails server. Because that terminal is running the rails server, I need another one to execute all the other stuff to get new controllers, views, specs, features, etc. I'm okay running two terminals, but there's a probably a better way.

Learning Rails part 1: Things to get you started

<p>After developing .NET for a long, long time I felt the need to try something completely different. </p><p>Googling around the internet I had seen Ruby on Rails quite a few times already in the past few years. But back when it started I didn't exactly feel the need to learn a new language. But after hearing more about it on BubbleConf and other places I decided, what the heck, why not give it a shot and see where this takes me.</p><p>In this blogpost and in the next few blogposts I'm going to show you what I'm doing to learn Rails and how you can start building rails apps too.</p><!--more--> <h2 id="how-this-series-work">How this series work</h2> <p>There's basically two approaches to learning a new language or thing. You can read a book about it and then start working with it. Or you dive in head-first and start building something and read books afterwards.</p><p>Depending on your personality, you may or may not like my style of learning. I am a hacker and I can only learn things inside-out when I get my fingers on them and break stuff ;-)</p><p>You have been warned! I will not explain theory in these blogposts, just some nice ways of doing things. I will point you to other blogs and manuals, but you will have to read them yourself if you are into such things.</p> <h2 id="getting-the-goods">Getting the goods</h2> <p>To start learning/building with Rails you need a few little things:</p> <ul> <li>An installation of Ruby on your machine </li><li>A text editor (there's quite a few good ones out there)</li><li>Git (because you are going to break stuff)</li><li>The Ruby on rails gem</li></ul> <p>You can download Ruby from the following locations:</p> <ul> <li><a href="http://rubyinstaller.org">http://rubyinstaller.org</a> (Windows)</li><li><a href="http://net.tutsplus.com/tutorials/ruby/how-to-install-ruby-on-a-mac/">http://net.tutsplus.com/tutorials/ruby/how-to-install-ruby-on-a-mac/</a> (Mac)</li></ul> <p><strong>Pro tip(tm):</strong> Install the devkit too if you're on Windows. You can find it here: <a href="http://rubyinstaller.org/add-ons/devkit/">http://rubyinstaller.org/add-ons/devkit/</a></p> <p>For mac users, make sure you install the Xcode command line tools. To do this you need to execute the following command in a terminal:</p>

1
xcode-select --install

<p>And the tools will install itself.</p><p>After you have installed Ruby on your system, you should be able to get the Rails gem installed. Start the terminal and execute the following command:</p>

1
gem install rails