Skip to content

Instantly share code, notes, and snippets.

@ghsyeung
Created March 21, 2012 03:13
Show Gist options
  • Save ghsyeung/2143985 to your computer and use it in GitHub Desktop.
Save ghsyeung/2143985 to your computer and use it in GitHub Desktop.
Starting a RoR project
require 'spec-helper'
describe UserController do
describe "Search user with name" do
it "should respond to search user route"
it "should call User model method to search user with same name"
it "should show view with the list of matching users" do
response.should render_template("matching_users")
it "should redirect to index page if not found" do
response.should redirect_to(:action => )
end
end
end
# Cucumber
# step to load table
Given /the following movies exist/ do |movies_table|
movies_table.hashes.each do |movie|
Movie.create(:title => movie[:title].strip, :rating => movie[:rating].strip, :release_date => movie[:release_date].strip)
end
end
# adding path patterns
when /^the edit page for "(.*)"$/
edit_movie_path(Movie.find_by_title($1))
# Generating the cucumber and rspec files
rails g cucumber:install capybara
rails g cucumber_rails_training_wheels:install
rails g rspec:install
# make necessary db changes
rails g migration Add[Column]To[Table] [column]:[type]
# prepare database
rake db:migrate
rake db:test:prepare
# check if done properly
rake spec
rake cucumber
BlogApp::Application.routes.draw do
# now can use call_user_path and call_user_url
match 'users/:id/call' => 'users#call', :as => 'call_user'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment