Skip to content

Commit 8963462

Browse files
committed
rewrite readme
1 parent 8650393 commit 8963462

File tree

1 file changed

+106
-50
lines changed

1 file changed

+106
-50
lines changed

README.textile

Lines changed: 106 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
h1. Rails Application with Devise and RSpec and Cucumber
1+
h1. Rails Application for Devise with RSpec and Cucumber
22

33
Rails 3.2 example application shows how to use "Devise":http://github.com/plataformatec/devise with "RSpec":http://rspec.info/ and "Cucumber":http://cukes.info/.
44

5-
Devise gives you ready-made authentication and user management. RSpec is a popular alternative to the Test::Unit testing framework. Cucumber is often used with RSpec for Behaviour Driven Development.
5+
* "Devise":http://github.com/plataformatec/devise gives you ready-made authentication and user management.
6+
* "RSpec":http://rspec.info/ is a popular alternative to the Test::Unit testing framework.
7+
* "Cucumber":http://cukes.info/ is used for Behaviour Driven Development.
68

79
Best of all, there's a "detailed tutorial":http://railsapps.github.com/tutorial-rails-devise-rspec-cucumber.html to show how it's built.
810

@@ -26,13 +28,13 @@ If you simply wish to modify the application for your own project, you can downl
2628

2729
h2. What Is Implemented -- and What Is Not
2830

29-
This is a demonstration application that allows you to visit a home page and see a list of users. With the default user's email and password (supplied below), you can log in and view details for each user. You can customize this app as you need.
31+
This is a demonstration application that allows you to visit a home page and see a list of users. With the default user's email and password (supplied below), you can log in and view details for each user. Devise provides user management so a visitor can register with an email address and password and create an account. Devise provides authentication so access to the site can be limited to users who are registered and logged in.
3032

3133
h4. Similar Examples and Tutorials
3234

33-
If you'd like to use the Mongoid ORM with the MongoDB datastore instead of ActiveRecord and a SQLite database, see the "rails3-mongoid-devise":https://github.com/RailsApps/rails3-mongoid-devise example app and tutorial. Mongoid makes development quicker without schemas or migrations. The "rails3-mongoid-devise":https://github.com/RailsApps/rails3-mongoid-devise example app and tutorial shows how to set up Devise and Mongoid with RSpec and Cucumber.
35+
This example application uses ActiveRecord and a SQLite database. You can use the Mongoid ORM with the MongoDB datastore instead, for faster development without schemas or migrations. The "rails3-mongoid-devise":https://github.com/RailsApps/rails3-mongoid-devise example app and tutorial shows how to set up Devise and Mongoid with RSpec and Cucumber.
3436

35-
See an expanded list of more "Rails examples, tutorials, and starter apps":http://railsapps.github.com/rails-examples-tutorials.html.
37+
See an expanded list of similar "Rails examples, tutorials, and starter apps":http://railsapps.github.com/rails-examples-tutorials.html.
3638

3739
h2. Dependencies
3840

@@ -47,7 +49,15 @@ h2. Getting the Application
4749

4850
You have several options for getting the code.
4951

50-
h4. Downloading the Code
52+
h4. Fork, Clone, or Generate?
53+
54+
_Fork:_ If you'd like to add features (or bug fixes) to improve the example application, you can fork the GitHub repo and "make pull requests":http://help.github.com/send-pull-requests/. Your code contributions are welcome!
55+
56+
_Clone:_ If you want to copy and customize the app with changes that are only useful for your own project, you can clone the GitHub repo. You'll need to search-and-replace the project name throughout the application. You probably should generate the app instead (see below).
57+
58+
_Generate:_ If you want to use the project as a starter app for your customized application, use the application template to generate a new version of the example app. You'll be able to give it your project name when you generate the app.
59+
60+
h4. Clone the Repository
5161

5262
If you simply wish to examine the example code, you can download the code ("clone the repository") with the command
5363

@@ -64,39 +74,43 @@ You can use an application template to generate a new version of the example app
6474
To build the "rails3-devise-rspec-cucumber" example application, run the command:
6575

6676
<pre>
67-
rails new myapp -m https://github.com/RailsApps/rails3-application-templates/raw/master/rails3-devise-rspec-cucumber-template.rb -T
77+
$ rails new myapp -m https://github.com/RailsApps/rails3-application-templates/raw/master/rails3-devise-rspec-cucumber-template.rb -T
6878
</pre>
6979

7080
Use the @-T@ flag to skip Test::Unit files.
7181

82+
The @$@ character indicates a shell prompt; don't include it when you run the command.
83+
7284
This creates a new Rails app (with the name @myapp@) on your computer.
7385

74-
The application generator template will ask you for your preferences:
75-
76-
* Would you like to use Haml instead of ERB?
77-
* Would you like to use RSpec instead of TestUnit?
78-
* Would you like to use factory_girl for test fixtures with RSpec?
79-
* Would you like to use Cucumber for your BDD?
80-
* Would you like to use Guard to automate your workflow?
81-
* Would you like to use Devise for authentication?
82-
* Would you like to install HTML5 Boilerplate?
83-
* Normalize CSS and use Skeleton boilerplate?
84-
* Normalize CSS for consistent styling across browsers?
85-
* Completely reset all CSS to eliminate styling?
86-
* Would you like to set a robots.txt file to ban spiders?
87-
* Would you like to use ‘rails-footnotes’ during development?
86+
The application generator templates will ask you for various preferences:
87+
88+
* Would you like to use "Haml":http://en.wikipedia.org/wiki/Haml instead of ERB?
89+
* Would you like to use "RSpec":http://rspec.info/ instead of TestUnit?
90+
* Would you like to use "factory_girl":https://github.com/thoughtbot/factory_girl for test fixtures with RSpec?
91+
* Would you like to use "machinist":https://github.com/notahat/machinist for test fixtures with RSpec?
92+
* Would you like to use "Cucumber":http://cukes.info/ for your BDD?
93+
* Would you like to use "Guard":http://intridea.com/posts/hire-a-guard-for-your-project to automate your workflow?
94+
* Would you like the app to use a Gmail account to send email?
95+
* Would you like to use "Devise":http://github.com/plataformatec/devise for authentication?
96+
## No
97+
## Devise with default modules
98+
## Devise with Confirmable module
99+
## Devise with Confirmable and Invitable modules
88100
* Which front-end framework would you like for HTML5 and CSS3?
89101
## None
90-
## Zurb Foundation
91-
## Twitter Bootstrap
92-
## Skeleton
102+
## "Zurb Foundation":http://foundation.zurb.com/
103+
## "Twitter Bootstrap":http://twitter.github.com/bootstrap/
104+
## "Skeleton":http://www.getskeleton.com/
93105
## Normalize CSS for consistent styling
106+
* Would you like to use "rails-footnotes":https://github.com/josevalim/rails-footnotes during development?
107+
* Would you like to set a robots.txt file to ban spiders?
94108

95109
h4. Use "Recipes" to Customize an Application Template
96110

97-
The "tutorial":http://railsapps.github.com/tutorial-rails-devise-rspec-cucumber.html shows how a customized application template can be assembled from "recipes." The application template was created using the "Rails Apps Composer":https://github.com/RailsApps/rails_apps_composer gem which provides a convenient way to assemble a reusable application template by selecting various "recipes" for popular Rails development packages.
111+
The application template was created using the "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer gem which provides a convenient way to assemble a reusable application template by selecting various "recipes" for popular Rails development packages. Use "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer if you want to customize the application template for your own starter apps.
98112

99-
h4. Please Remember: Edit the README
113+
h4. Edit the README
100114

101115
If you're open sourcing the app on GitHub, please edit the README file to add a description of the app and your contact info. Changing the README is important if you're using a clone of the example app. I've been mistaken (and contacted) as the author of apps that are copied from my example.
102116

@@ -114,6 +128,8 @@ The application uses the following gems:
114128
* "capybara":http://rubygems.org/gems/capybara
115129
* "devise":http://rubygems.org/gems/devise
116130

131+
See "Example Gemfiles for Rails 3.2":http://railsapps.github.com/rails-3-2-example-gemfile.html.
132+
117133
h4. Install the Required Gems
118134

119135
Install the required gems on your computer:
@@ -126,26 +142,60 @@ You can check which gems are installed on your computer with:
126142

127143
Keep in mind that you have installed these gems locally. When you deploy the app to another server, the same gems (and versions) must be available.
128144

129-
h4. Set Up Configuration for Devise
145+
h2. Configure Email
130146

131-
This app uses "Devise":http://github.com/plataformatec/devise for user management and authentication.
147+
You must configure the app for your email account if you want your application to send email messages, for example, if you've generated the application with the option to install the Devise @:confirmable@ module.
132148

133-
You can modify the configuration file for Devise if you want to use something other than the defaults:
149+
h4. Use a Gmail account
134150

135-
*config/initializers/devise.rb*
151+
If you've generated the application with the option to use a Gmail account to send email, you'll need to modify the files *config/environments/development.rb* and *config/environments/production.rb* to include your Gmail username and password.
152+
153+
<pre>
154+
config.action_mailer.smtp_settings = {
155+
address: "smtp.gmail.com",
156+
port: 587,
157+
domain: "example.com",
158+
authentication: "plain",
159+
enable_starttls_auto: true,
160+
user_name: ENV["GMAIL_USERNAME"],
161+
password: ENV["GMAIL_PASSWORD"]
162+
}
163+
</pre>
164+
165+
You can replace @ENV["GMAIL_USERNAME"]@ and @ENV["GMAIL_PASSWORD"]@ with your Gmail username and password. However, committing the file to a public GitHub repository will expose your secret password.
166+
167+
If you're familiar with setting "Unix environment variables":http://en.wikipedia.org/wiki/Environment_variable, it's advisable to leave @config.action_mailer.smtp_settings@ unchanged and set your environment variables in the file that is read when starting an interactive shell (the *~/.bashrc* file for the bash shell). This will keep the password out of your repository.
168+
169+
Are you using a bash shell? Use @echo $SHELL@ to find out. For a bash shell, edit the *~/.bashrc* file and add:
170+
171+
<pre>
172+
export GMAIL_USERNAME="myname@gmail.com"
173+
export GMAIL_PASSWORD="secret*"
174+
</pre>
175+
176+
Open a new shell or restart your terminal application to continue.
136177

137-
h4. Configure Email for Devise
178+
h4. Configure ActionMailer
138179

139-
Configure email by modifying
180+
The example application is set to deliver email in both development and production. It will raise deliervy errors in development but not production.
181+
182+
In development, @config.action_mailer.default_url_options@ is set for a host at @localhost:3000@ which will enable links in Devise confirmation email messages to work properly. You'll need to change the @config.action_mailer.default_url_options@ host option from @example.com@ to your own domain for the production environment.
183+
184+
You can change these values as needed in the *config/environments/development.rb* and *config/environments/production.rb* files.
185+
186+
h4. Configure Devise for Email
187+
188+
Complete your email configuration by modifying
140189

141190
*config/initializers/devise.rb*
142191

143-
and setting the return email address for emails sent from the application.
192+
and setting the @config.mailer_sender@ option for the return email address for messages that Devise sends from the application.
193+
194+
h2. Configure Devise
144195

145-
You may need to set values for your mailhost in
196+
You can modify the configuration file for Devise if you want to use something other than the defaults:
146197

147-
*config/environments/development.rb*
148-
*config/environments/production.rb*
198+
*config/initializers/devise.rb*
149199

150200
h2. Create a Default User
151201

@@ -161,14 +211,24 @@ puts 'New user created: ' << user.name
161211

162212
Use the defaults or change the values for name, email, and password as you wish.
163213

164-
h4. Seed the Database
214+
If you've generated the application with the option to install the Devise @:confirmable@ module, there will be an extra attribute @confirmed_at => Time.now@ for creation of a user.
215+
216+
h4. Set the Database
217+
218+
Prepare the database and add the default user to the database by running the commands:
219+
220+
<pre>
221+
$ bundle exec rake db:migrate
222+
$ bundle exec rake db:seed
223+
</pre>
165224

166-
Add the default user to the database by running the command:
225+
Set the database for running tests:
167226

168-
@$ rake db:migrate@
169-
@$ rake db:seed@
227+
<pre>
228+
$ bundle exec rake db:test:prepare
229+
</pre>
170230

171-
h4. Test the App
231+
h2. Test the App
172232

173233
You can check that your app runs properly by entering the command
174234

@@ -185,7 +245,7 @@ You should delete or change the pre-configured logins before you deploy your app
185245

186246
h2. Deploy to Heroku
187247

188-
For your convenience, here are instructions for "deploying your app to Heroku":http://railsapps.github.com/rails-heroku-tutorial.html. Heroku provides low cost, easily configured Rails application hosting.
248+
For your convenience, here is a "Tutorial for Rails on Heroku":http://railsapps.github.com/rails-heroku-tutorial.html. Heroku provides low cost, easily configured Rails application hosting.
189249

190250
h2. Customizing
191251

@@ -195,15 +255,15 @@ This application provides no useful functionality apart from demonstrating Devis
195255

196256
h2. Testing
197257

198-
The application contains RSpec unit tests and Cucumber scenarios and steps. The tests are minimal and can be improved.
199-
200-
Please send the author a message, create an issue, or submit a pull request if you can contribute improved RSpec or Cucumber files.
258+
The example application contains a suite of RSpec unit tests and Cucumber scenarios and step definitions.
201259

202260
After installing the application, run @rake -T@ to check that rake tasks for RSpec and Cucumber are available.
203261

204262
Run @rake spec@ to run all RSpec tests.
205263

206-
Run @rake cucumber@ (or more simply, @cucumber@) to run all Cucumber scenarios and steps.
264+
Run @rake cucumber@ (or more simply, @cucumber@) to run all Cucumber scenarios.
265+
266+
Please send the author a message, create an issue, or submit a pull request if you can contribute improved RSpec or Cucumber files.
207267

208268
h2. Documentation and Support
209269

@@ -236,10 +296,6 @@ Daniel Kehoe ("http://danielkehoe.com/":http://danielkehoe.com/) implemented the
236296
Is the app useful to you? Follow the project on Twitter: "@rails_apps":http://twitter.com/rails_apps
237297
and tweet some praise. I'd love to know you were helped out by what I've put together.
238298

239-
h4. Contributors
240-
241-
"Rowan":https://github.com/rowanu implemented Cucumber steps.
242-
243299
h2. License
244300

245301
h4. Public Domain Dedication

0 commit comments

Comments
 (0)