Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Scaffold app using different testing frameworks under Rails 3.1, MRI 1.9.2
Ruby CoffeeScript JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
app
config
db
doc
features
lib
log
public
script
spec
vendor
.gitignore
.rspec
.rvmrc
Gemfile
Gemfile.lock
README
Rakefile
config.ru

README

= Rails 3.1 sample application

Complete steps to set up a Rails 3.1 application with:
  - Ruby unit tests using RSpec 2
  - Acceptance tests using Capybara with:
    - RSpec 2
    - Cucumber
  - Acceptance tests running in RackTest
  - Acceptance test running javascript with Selenium
  - Javascript unit tests using Evergreen
  - No asset pipeline (Not supported by Evergreen yet)

== Rails 3.1 default generated files

  01. mkdir app
  02. cd app
  03. echo "rvm use 1.9.2-p180@app --create"
  04. cd ..
  05. cd app
  06. gem install rails -v="3.1"
  07. gem install bundler -v ="1.1.pre8"
  08. add "alias b='bundle exec'" to ~/.bash/aliases

== Installed cucumber-rails

  01. add cucumber-rails to the gemfile
  02. bundle install
  03. b gem update
  04. gem update --system
  05. rails generate cucumber:install

== Generated cucumber feature with rails scaffold

  01. rails generate cucumber:feature post title:string body:text published:boolean
  02. rails generate scaffold post title:string body:text published:boolean
  03. rake db:migrate
  04. rake db:test:prepare
  05. add gem 'database_cleaner' to gemfile
  06. rake cucumber

==  Added unit spec with RSpec

  01. add gem 'rspec-rails', '~> 2.6' to Gemfile
  02. add gem 'machinist' to Gemfile
  03. add gem 'faker' to Gemfile
  04. bundle install
  05. rails generate rspec:install
  06. write a unit test
  07. add blueprints
  08. b rspec spec/models/posts_spec.rb

== Added acceptance test using Capybara and RSpec

  01. add gem 'capybara' to Gemfile (not required if you still have cucumber as dependency)
  02. require 'capybara/rspec' in your test helper
  03. add a root route
  05. remove the static html index file
  06. write an capybara-rspec request spec
  07. b rspec spec/request/manage_posts_spec.rb

==  Added javascript unit tests using Evergreen

  01. brew install node
  02. npm install -g coffee-script
  03. Create a coffee script file in app/coffee
  04. mkdir public/javascripts
  05. coffee --compile --output public/javascripts/ --watch app/coffee/
  06. Write the coffescript file in app/coffee
  07. Write the javascript test in spec/javascripts
  08. Add the spec helper in in spec/javascripts/spec_helper.coffee
  09. Add gem 'evergreen', :require => 'evergreen/rails' to the Gemfile
  10. Remove the asset pipline gems
  11. bundle install
  12. Turn off the asset pipline in application.rb
  13. rails server
  14. Go to localhost:3000/evergreen
  15. Run b rake spec:javascripts

== Added request spec that uses selenium to execute Javascript

  01. write a request spec
  02. set :js => true

== Added a cucumber scenario that executes Javascript

  01. Add a feature
  02. Tag a scenario with @javascript

== License:

  (The MIT License)

  Copyright (c) 2011 Nicklas Ramhöj

  Permission is hereby granted, free of charge, to any person obtaining
  a copy of this software and associated documentation files (the
  'Software'), to deal in the Software without restriction, including
  without limitation the rights to use, copy, modify, merge, publish,
  distribute, sublicense, and/or sell copies of the Software, and to
  permit persons to whom the Software is furnished to do so, subject to
  the following conditions:

  The above copyright notice and this permission notice shall be
  included in all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Something went wrong with that request. Please try again.