The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
TIL: RSpec Request Specs

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Vincent Woo

Posts: 30
Nickname: vwoo
Registered: Sep, 2008

Vincent Woo is a Ruby on Rails enthusiast.
TIL: RSpec Request Specs Posted: Dec 5, 2010 10:18 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Vincent Woo.
Original Post: TIL: RSpec Request Specs
Feed Title: Undefined Range
Feed URL: http://www.undefinedrange.com/categories/ruby-on-rails.rss
Feed Description: Interesting things I experience with Ruby on Rails.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Vincent Woo
Latest Posts From Undefined Range

Advertisement

The rspec-rails gem gives us Request Specs, the ability to create default Test::Unit Rails integration style tests. Just add files into #{Rails.root}/spec/requests.

require 'spec_helper' describe "Redirect Middleware" do it "should redirect based on certain conditions" get '/x' get '/y' follow_redirect! end end

Rails Guide has more information on what you can do with request specs like follow_redirect! or host!

Request specs was perfect for testing a simple middleware I wrote. It was high level specs that require multiple page requests to trigger and applicable to many different controllers. Plus, it didn't need the browser compatibility testing of the popular Cucumber + Webrat + Selenium type combos. Really happy with less dependencies = smaller API and complexity = less setup, faster test runs, reduced brittleness.

I'm probably in the minority in that thinking though. For instance, the recently minted RSpec book has a large section dedicated to Cucumber but AFAIK doesn't reference request specs at all (other than mentioning the "rake spec:requests" task in passing). But request specs are a part of the RSpec gems and I hope it is here to stay.

Read: TIL: RSpec Request Specs

Topic: My stock clean task Previous Topic   Next Topic Topic: HuntFunc Meeting: December 7

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use