Skip to content

Instantly share code, notes, and snippets.

From ac79dd7c726dde04be6a1a1dfdd6c781276b31b4 Mon Sep 17 00:00:00 2001
From: Wincent Colaiuta <win@wincent.com>
Date: Tue, 6 Jul 2010 17:48:20 +0200
Subject: [PATCH] Make view helpers available in view specs
This maintains the behavior established in RSpec 1.
See:
http://github.com/rspec/rspec-rails/issues/issue/119
describe IssuesController do
describe 'routing' do
specify { get('/issues').should have_routing('issues#index') }
specify { get('/issues/new').should have_routing('issues#new') }
specify { get('/issues/123').should have_routing('issues#show', :id => '123') }
specify { get('/issues/123/edit').should have_routing('issues#edit', :id => '123') }
specify { put('/issues/123').should have_routing('issues#update', :id => '123') }
specify { delete('/issues/123').should have_routing('issues#destroy', :id => '123') }
specify { post('/issues').should have_routing('issues#create') }
diff --git a/features/view_specs/view_spec.feature b/features/view_specs/view_spec.feature
index e85c306..7cce24e 100644
--- a/features/view_specs/view_spec.feature
+++ b/features/view_specs/view_spec.feature
@@ -152,3 +152,34 @@ Feature: view spec
"""
When I run "rspec spec/views"
Then the output should contain "1 example, 0 failures"
+
+ Scenario: spec with view that accesses helper_method helpers
$ ls -laFSh vendor/cache
total 65768
-rw-r--r-- 1 wincent staff 14M 28 jun 18:47 webrat-0.7.1.gem
-rw-r--r-- 1 wincent staff 7,9M 14 jul 22:07 celerity-0.8.0.beta.1.gem
-rw-r--r-- 1 wincent staff 2,1M 14 jul 22:07 jruby-openssl-0.7.gem
-rw-r--r-- 1 wincent staff 1,4M 28 jun 18:47 railties-3.0.0.beta4.gem
-rw-r--r-- 1 wincent staff 1,3M 28 jun 18:47 selenium-webdriver-0.0.24.gem
-rw-r--r-- 1 wincent staff 791K 28 jun 18:47 ffi-0.6.3.gem
-rw-r--r-- 1 wincent staff 504K 28 jun 18:47 haml-3.0.12.gem
-rw-r--r-- 1 wincent staff 389K 28 jun 18:47 json_pure-1.4.3.gem
source 'http://rubygems.org'
platforms :ruby_18 do
gem 'haml', '3.0.12'
gem 'mysql', '2.8.1'
gem 'rails', '3.0.0.beta4'
gem 'wikitext', '2.0'
group :development, :test do
gem 'factory_girl_rails' # want factories in development console
#
#
# create a new Rails app
#
#
$ cd /tmp
$ rails --version
Rails 3.0.0.beta4
$ rails new demo
source 'http://rubygems.org'
platforms :ruby_18 do
gem 'haml', '>= 3.0.14'
gem 'mysql', '2.8.1'
gem 'rails', '3.0.0.rc'
gem 'wikitext', '2.0'
group :development, :test do
gem 'factory_girl_rails' # want factories in development console
// Copyright 2007-2010 Wincent Colaiuta. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
source 'http://rubygems.org'
platforms :ruby_18 do
gem 'haml', '>= 3.0.15'
gem 'mysql', '2.8.1'
gem 'rails', '3.0.0.rc'
gem 'wikitext', '2.0'
gem 'wopen3', '>= 0.3'
group :development, :test do
$ bundle update
Updating git://github.com/jnicklas/capybara.git
Updating git://github.com/btakita/rr.git
Updating git://github.com/cavalle/steak.git
Fetching source index for http://rubygems.org/
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.0.rc)
Using builder (2.1.2)
Using i18n (0.4.1)