background preloader

Rails Tutorial for Devise with RSpec and Cucumber

Rails Tutorial for Devise with RSpec and Cucumber
Devise with RSpec and Cucumber Introduction Ruby on Rails tutorial showing how to create a Rails 3.2 application using Devise with RSpec and Cucumber. Devise provides ready-made authentication and user management. The combination of Devise, RSpec, and Cucumber is the foundation for many real-world Rails applications. Is It for You? This tutorial is for experienced Rails developers as well as startup founders or hobbyist coders who are new to Rails. Experienced developers will find the complete application on GitHub; this tutorial provides the detail and background to understand the implementation in depth. For Rails beginners, this tutorial describes each step that you must follow to create the application. This is one in a series of Rails example apps and tutorials from the RailsApps Project. This example application uses ActiveRecord and a SQLite database. For more complex applications that use Devise, CanCan, and Twitter Bootstrap, see: How to Support the Project Before You Start Assumptions

Rails Tutorial for Devise with CanCan and Twitter Bootstrap Basic Tutorials Devise, RSpec, Cucumber Devise, Mongoid OmniAuth, Mongoid Subdomains Premium Tutorials Twitter Bootstrap, Devise, CanCan Startup Prelaunch Signup App Close Click a link to any tutorial for instant access. The tutorials. One of the best resources for Rails developers, tons of useful tutorials, advice, best practices... @rails_apps Awesome tutorials covering #rails, #mongoid, #devise. Big thanks to @rails_apps for providing some great RoR starter apps and tutorials. Devise with CanCan and Twitter Bootstrap Authentication with Authorization plus Twitter Bootstrap for Rails. Devise gives you ready-made authentication and user management. CanCan provides authorization for administrator access. Twitter Bootstrap is a popular front-end framework for CSS styling. RSpec and Cucumber for testing and behavior-driven development. Hobo Basic Tutorials Online Single User No Membership Student "Devise with CanCan and Twitter Bootstrap" Ebook Ebook only One-time Purchase $5 one-time Pro $19/month Team $349/year

RailsApps/rails3-devise-rspec-cucumber Better Specs Rails Tutorial for a Startup Prelaunch Signup Site by Daniel Kehoe Last updated 8 September 2012 Note: This tutorial is overdue for a round of revisions since it no longer matches the current rails-prelaunch-signup example application. Ruby on Rails tutorial showing how to create a “beta launching soon” application for a startup prelaunch site with a signup page. Screenshot: Read an interview with Michael Gajda of XPlaygrounds.com about how he used the rails-prelaunch-signup example to launch his startup site. Follow on Twitter Follow the project on Twitter: @rails_apps . Introduction The initial app for a typical web startup announces the founders’ plans and encourages visitors to enter an email address for future notification of the site’s launch. But why build it yourself if others have already done so? eliminate effort spent building an application that meets a common need; offer code that is already implemented and tested by a large community; provide a well-thought-out app containing most of the features you’ll need. Tutorial Hosting

RSpec Best Practices Click here to view the complete list of tools reviews This article was originally published in the Spring 2011 issue of Methods & Tools RSpec Best Practices Jared Carroll, Carbon Five, RSpec is a Behavior-Driven Development tool for Ruby programmers. Web Site: tested: 2.5License & Pricing: MIT License, open source / freeSupport: Community RSpec is a great tool in the behavior driven design process of writing human readable specifictions that direct and validate the development of your application. First #describe What You Are Doing Begin by using #describe for each of the methods you plan on defining, passing the method’s name as the argument. describe User do describe '.authenticate' do end describe '.admins' do end describe '#admin?' Then Establish The #context Next use #context to explain the different scenarios in which the method could be executed. For example, the following method has two execution paths: Lose The Should Before:

#275 How I Test Here I show how I would add tests to the password reset feature created in the previous episode. I use RSpec, Capybara, Factory Girl, and Guard to make request, model, and mailer specs. Download: source codeProject Files in Zip (92.2 KB)mp4Full Size H.264 Video (26.4 MB)m4vSmaller H.264 Video (16.1 MB)webmFull Size VP8 Video (18.1 MB)ogvFull Size Theora Video (37.8 MB) Rails Tutorial for Devise with Mongoid by Daniel Kehoe Last updated 19 August 2012 Ruby on Rails tutorial showing how to create a Rails 3.2 application using Devise with Mongoid. Devise gives you ready-made authentication and user management. Similar Examples and Tutorials See a list of additional Rails examples, tutorials, and starter apps. Follow on Twitter Follow the project on Twitter: rails_apps. Tutorial This tutorial documents each step that you must follow to create this application. Before You Start If you follow this tutorial closely, you’ll have a working application that closely matches the example app in this GitHub repository. If you clone and install the example app and find problems or wish to suggest improvements, please create a GitHub issue. To improve this tutorial, please leave comments below. Installing MongoDB If you don’t have MongoDB installed on your computer, you’ll need to install it and set it up to be always running on your computer (run at launch). brew install mongodb gem 'mongoid', '~> 3.0.1' Fork Clone

How I Test In a recent discussion on Google+, a friend of mine commented, "Test-Driven Development (TDD) and Behavior-Driven Development (BDD) is Ivory Tower BS." This prompted me to think about my first project, how I felt the same way then, and how I feel about it now. Since that first project, I've developed a rhythm of TDD/BDD that not only works for me, but for the client as well. Ruby on Rails ships with a test suite, called Test Unit, but many developers prefer to use RSpec, Cucumber, or some combination of the two. Personally, I prefer the latter, using a combination of both. RSpec From the RSpec site: RSpec is a testing tool for the Ruby programming language. RSpec provides a powerful DSL that is useful for both unit and integration testing. Cucumber I've found the benefits of TDD/BDD far outweigh the cons. Cucumber is an integration and acceptance testing framework that supports Ruby, Java, .NET, Flex, and a host of other web languages and frameworks. The Setup Within the Gemfile, add:

RSpec | PeepCode Screencasts ▶ We’ve been acquired by Pluralsight! ▶ Upgrade your account to Pluralsight ▶ More details… Filter by tag: Ruby on Rails · Ruby · Javascript · Play by Play · Unix · RSpec · Deployment · Pdf · Design · Cocoa · iPhone · Node · Databases · Productivity · Git RSpec 2: with Rails 4 and Ruby 2 (Part 3 of 3) RSpec 2: Tools (Part 2 of 3) RSpec 2: The Basics (Part 1 of 3) Use the Cucumber RSpec Controllers and Tools RSpec Mocks and Models RSpec Basics Rails Tutorial for OmniAuth with Mongoid by Daniel Kehoe Last updated 23 November 2012 Ruby on Rails tutorial showing how to create a Rails 3.2 application using OmniAuth with Mongoid. OmniAuth gives you ready-made authentication using a service provider such as Twitter or Facebook. Mongoid gives access to a MongoDB datastore for quick development without schemas or migrations. This tutorial also gives you the option of using Haml, RSpec and Cucumber, showing how to integrate each option. Service Providers: Facebook, Twitter, GitHub, LinkedIn, and many more. This tutorial shows how to set up an application for sign-in with a single provider. Any issues? When to use Devise? Devise provides authentication using username (or email address) and password. The Email Problem You don’t need to ask a visitor for an email address when you build an application that allows a user to log in using a service provider such as Twitter or Facebook. Similar Examples and Tutorials See a list of additional Rails examples, tutorials, and starter apps.

Digesting Rails: BDD with RSpec | Robert Lysik I’ve now progressed through the first six chapters of the Ruby on Rails Tutorial and my head is spinning. I feel like Keanu Reeve’s character from the 90′s b-movie Johnny Mnemonic. Before I proceed, I thought I’d take some time to digest what I’ve learned and do a little research into aspects that I’ve found somewhat inscrutable, which are legion. Where to start? Behavior Driven Development Behavior Driven Development or BDD is a framework for unit testing of software that seeks to rephrase test cases using more natural language. RSpec RSpec is a Behavior Driven Development tool for Ruby inspired by the work of Dan North and JBehave. A Simple Example The Ruby on Rails Tutorial contains an excellent overview of BDD and RSpec and interweaves testing using RSpec throughout each chapter. It is possible to use RSpec without the Rails framework, however. Please note that the examples that follow are geared for the Mac OS X environment. You should get a response like the following: Voila! Hurray!

Documentation for rspec-rails (2.12.2) rspec-rails is a testing framework for Rails 3.x and 4.x. Use rspec-rails 1.x for Rails 2.x. Installation Add rspec-rails to both the :development and :test groups in the Gemfile: group :development, :test do gem 'rspec-rails', '~> 2.0'end Download and install by running: bundle install Initialize the spec/ directory (where specs will reside) with: rails generate rspec:install To run your specs, use the rspec command: bundle exec rspec bundle exec rspec spec/models bundle exec rspec spec/controllers/accounts_controller_spec.rb Specs can also be run via rake spec, though this command may be slower to start than the rspec command. In Rails 4, you may want to create a binstub for the rspec command so it can be run via bin/rspec: bundle binstubs rspec-core Generators Once installed, RSpec will generate spec files instead of Test::Unit test files when commands like rails generate model and rails generate controller are used. You may also invoke invoke RSpec generators independently. Model Specs Upgrade note

Rails Tutorial for Subdomains with Devise by Daniel Kehoe Last updated 20 August 2012 Ruby on Rails tutorial showing how to create a Rails 3.2 application with subdomains and authentication using Devise. What Is Implemented The example app implements a common use of subdomains, often called “Basecamp-style subdomains in Rails.” What Is Not Implemented Another common use of subdomains can be called “blog-style subdomains.” Based on the Rails3-Mongoid-Devise Example App This app extends the Rails 3 + Mongoid + Devise example app. Similar Examples and Tutorials See a list of additional Rails examples, tutorials, and starter apps. Follow on Twitter Follow the project on Twitter: @rails_apps. Tutorial This tutorial documents each step that you must follow to create this application. Before You Start If you follow this tutorial closely, you’ll have a working application that closely matches the example app in this GitHub repository. To improve this tutorial, please leave comments below. Installing MongoDB brew install mongodb Fork Clone Generate

Ruby for Newbies: Testing with Rspec Ruby is a one of the most popular languages used on the web. We're running a Session here on Nettuts+ that will introduce you to Ruby, as well as the great frameworks and tools that go along with Ruby development. In this episode, you’ll learn about testing your Ruby code with Rspec, one of the best testing libraries in the business. If you’ve read my recent tutorial on JasmineJS, you’ll probably notice several similarities in Rspec. Actually, the similarities are in Jasmine: Jasmine was created with Rspec in mind. We’re going to look at how to can use Rspec to do TDD in Ruby. It’s pretty easy to install Rspec. That easy. Now, let’s set up a small project. Here’s what your project directory should look like: We put the specifications (or specs) in a spec folder; we have one spec file for each class. (Have you met require_relative yet? You may not be familiar with the YAML module; YAML is a simple text database that we’ll use to store data. Let’s start with the tests for the Book class.

Related: