Open Source Rails RailsApps/rails3-devise-rspec-cucumber Better Specs arantius/resurrect-pages 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) Offres d’hébergement Ruby on Rails Ruby on Rails est un Framework basé sur le langage de programmation Ruby. Il est spécialement conçu pour des développements rapides et articulés sur la méthodologie Agile. Le principe de Ruby est de privilégier les conventions plutôt que les configurations. De plus en plus utilisé dans la création de sites internet et d’applications web, l’utilisation de Ruby on Rails implique un hébergement plus spécifiques et disposant entre autres des librairies Ruby. Pour votre Hébergement Ruby on Rails et la production de vos applications Rails, Railsprod vous propose trois offres mutualisées disposant de Ruby on Rails. Votre hébergement Ruby on Rails à la carte… Espace Disque : 500 MoBase de données : 100 MoEnvironnement : ProductionBackup quotidien : non inclusTrafic : illimitéAccès shell : inclusGems : incluses *Frais d’installation : inclusSouscrire * Sous réserve d’approbation du support technique. Besoin d’une solution de gestion de projets ?
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. 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 Let's first begin a new project, instructing Rails to skip Test Unit. Our First Feature
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? I’m somewhat intrigued by the idea of Test Driven Development, or in the case of the Ruby on Rails tutorial its variant which is described as Behavior Driven Development. 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. So, what’s up with “it?” Voila!
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
Data Scraping and More With Ruby, Nokogiri, Sinatra and Heroku | Hunter Powers In this article, you will learn the basics of scraping and parsing data from websites with Ruby and Nokogiri. You will then take this information and build a sample application, first as a command line tool and then as a full Sinatra web app. Finally, you will deploy your new application on the heroku hosting platform. There is a screencast that accompanies this article. Data scraping is the process of extracting data from output that was originally intended for humans. Nokogiri is a Ruby Gem that extracts data from web pages using CSS selectors. Let’s look at an example: In this page, there are three bits of interesting information: price, time, and inventory status. The above example is very simple, but hopefully gets the point across about how you can target content for extraction using CSS selectors. The 9:30 club is a music venue in DC. What we need is a way to target all concerts. Let’s take it a step farther and turn our app into a full Sinatra application.
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. 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. So, now that we’re all set up, let’s get cracking on some specs! Let’s start with the tests for the Book class. This is how we start: with a describe block. Moving on, Here’s our first test.