Created
November 30, 2009 10:03
-
-
Save evolve2k/245378 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Create a new rails app | |
Rails twatter | |
1b. Initialise git | |
git init | |
git add . | |
git commit -a -m 'Initial Comit, empty rails app' | |
2. generate cucumber files | |
script/generate cucumber | |
3. Generate RSpec files | |
script/generate rspec | |
4. Create your first cucumber feature | |
go to /features/ | |
In /features/, create a new file called 'create_message.feature' using your favorite text editor | |
Feature: Users can post messages to Twatter | |
In order communicate with other Twatter users | |
As a user | |
I want to be able to easily add new twat posts | |
Scenario: Create a message | |
Given Im on the twats page | |
When I fill in "Message" with "First Post LOL" | |
And I press "Post" | |
Then I see "First Post LOL" under messages | |
4b. Update git | |
git commit -a -m 'Added first feature' | |
5. Run Tests, watch them fail. | |
(The malteaser challeng! More you 'shoot and aim' the more chocolate you get) | |
Rake cucumber | |
You will get an error along these lines: | |
schema.rb doesn't exist yet. Run "rake db:migrate" to create it then try again. If you do not intend to use a database, you should instead alter /home/richie/projects/twatter/config/environment.rb to prevent active_record from loading: config.frameworks -= [ :active_record ] | |
Can you guess what to do next? | |
rake db:migrate | |
6. Now run cucumber again | |
Rake cucumber | |
You should get a bunch of coloured output to the command line. | |
Find the first error at the top of the output: | |
Scenario: Create a message # features/create_a_message.feature:7 | |
Given Im on the twats page # features/create_a_message.feature:8 | |
Undefined step: "Im on the twats page" (Cucumber::Undefined) | |
features/create_a_message.feature:8:in `Given Im on the twats page' | |
7. Now we need to do the minimum to get this to pass: | |
Basically, lets explain to cucumber what 'twats page' means. | |
goto /features/support open paths.rb | |
when /the home\s?page/ #existing | |
'/' #existing | |
when /the new twat page/ | |
new_twat_path | |
8. Run cucmber again | |
Rake cucumber | |
Scenario: Create a message # features/create_a_message.feature:7 | |
Given Im on the new twat page # features/create_a_message.feature:8 | |
Undefined step: "Im on the new twat page" (Cucumber::Undefined) | |
features/create_a_message.feature:8:in `Given Im on the new twat page' | |
Now we have defined 'new_twats_path' we need to setup the routes so that they go somewhere. | |
twatter/config open routes.rb | |
You can remove everything from the routes file we don't need any of it for now. | |
ActionController::Routing::Routes.draw do |map| | |
map.resources :twats | |
end | |
9. Rake cucumber | |
Create new twats controller | |
script/generate rspec_controller twats |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment