Skip to content

Instantly share code, notes, and snippets.

View dchelimsky's full-sized avatar

David Chelimsky dchelimsky

  • Retired
  • Chicago, IL, USA
View GitHub Profile
# Gemfile
source 'http://rubygems.org'
gem 'acts_as_list', '0.1.2'
gem 'acts_as_singleton', :git => 'git://github.com/stephencelis/acts_as_singleton.git'
gem 'authlogic', :git => 'git://github.com/odorcicd/authlogic.git', :branch => 'rails3'
gem 'aws-s3', '0.6.2'
gem 'cancan', '1.1.1'
gem 'delayed_job', '2.0.3'
diff --git a/features/view_specs/view_spec.feature b/features/view_specs/view_spec.feature
index e85c306..6534c30 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
shared_examples_for "a measurable object" do |measurement_method, measurement|
it "should return #{measurement} from ##{measurement_method}" do
subject.send(measurement_method).should == measurement
end
end
describe Array do
it_should_behave_like "a measurable object", :size, 2 do
subject { [2, 13] }
end
class ClassProjectsController < ApplicationController
def new
end
end
@dchelimsky
dchelimsky / gist:590557
Created September 21, 2010 21:10 — forked from qrush/gist:590466
describe SomeClass do
freeze { 1.day.from_now }
it "does some stuff with time" do
end
end
# this actually does...
describe SomeClass do
around { |example| Timecop.freeze(1.day.from_now, &example) }
#RSpec Mocks...
it "does something with a collaborator" do
#Given
collab = mock(:collab)
it.collaborator = collab
#Then
collab.should_receive(:call).with(3)
#When
#RSpec Mocks...
it "does something with a collaborator" do
#Given
collab = mock(:collab)
it.collaborator = collab
#Then
collab.should_receive(:call).with(3)
#When
describe Controller do
context "create" do
it "saves the model" do
model = Model.new
Model.stub(:new).and_return(model)
model.should_receive(:save)
post :create
end
end
end
module MyModule
def some_method
super
rescue SystemStackError => e
puts "you're including MyModule more than once"
end
end
class MyBaseClass; end
require 'spec_helper'
describe ArticlesController, :type => :controller do
# ^^ :type => :controller is not necessary if the file is in spec/controllers
describe "GET index" do
# ^^ The describe method creates an example group. ^^
get :index
# ^^ The get method is exposed to an example.
response.should be_successful
end