Skip to content

Instantly share code, notes, and snippets.

describe PostsController do
it "should show the given post on GET show" do
post = stub('a post', :to_param => '1')
Post.expects(:find).with(post.to_param).returns(post)
get :show, :id => post.to_param
should render_template(:show)
should assign_to(:post).with(post)
end
describe PostsController, "on GET show" do
before(:each) do
@post = stub('a post', :to_param => '1')
Post.expects(:find).with(@post.to_param).returns(@post)
get :show, :id => @post.to_param
end
it { should render_template(:show) }
it { should assign_to(:post).with(@post) }
describe PostsController, "on GET show" do
before(:each) do
@post = stub('a post', :to_param => '1')
Post.stubs(:find => @post)
get :show, :id => @post.to_param
end
it { should render_template(:show) }
describe PostsController do
it "should show a published post on GET show" do
post = stub('a post', :to_param => '1')
post.expects(:published? => true)
Post.expects(:find).with(post.to_param).returns(post)
get :show, :id => post.to_param
should render_template(:show)
should assign_to(:post).with(post)
end
end
module PostHelpers
def stub_post(post_attrs = {})
post_attrs = {
:to_param => '1',
:published? => true,
:title => 'a title'
}.update(post_attrs)
stub('a post', post_attrs)
end
# post.class.should have_received(:find).with(post.to_param)
should find(post)
# Post.should have_received(:new).with(post_attrs)
should build(Post, post_attrs)
# Post.should have_received(:new).with(post_attrs)
# post.should have_received(:save)
should build_and_save(Post, post_attrs)
module GeoKit
module Geocoders
class FakeGeocoder < Geocoder
def self.locations
@locations ||= {}
end
def self.geocode(location)
loc = GeoLoc.new
if locations.key?(location)
#!/usr/bin/ruby
unless failing_feature = ARGV[0]
puts "Usage: find-interacting-feature <feature_file>"
exit
end
other_features = Dir["features/**/*.feature"] - [failing_feature]
interacting_feature = other_features.detect do |other_feature|
class Test::Unit::TestCase
def self.should_should_belong_to(association)
should "should belong to #{association}" do
assert instance_methods.include?("should belong to #{association}")
end
end
end
# autocompletion for cuc
_cucumber_features() {
compadd `ls features/**/*.feature | sed "s/features\/\(.*\).feature/\1/"`
}
compdef _cucumber_features cuc