l'essentiel est invisible pour les yeux

Monday, May 19, 2008

[rails] RSpec matchers for render(:nothing => true)

This is matchers for render(:nothing => true).

Add some code into spec/spec_helper.rb is as follows:


# Matchers for render(:nothing => true)
class RenderNothing
def initialize
end

def matches?(controller)
@actual = controller.rendered_file
@actual == nil
end

def failure_message
return "render_nothing expected (render :nothing => true), got #{@actual.inspect}"
end

def negative_failure_message
return "render_nothing expected (render :nothing => true) not to equal #{@actual.inspect}"
end
end

def render_nothing
RenderNothing.new
end


Use render_nothing.

it "should not render anything" do
post :destroy, :id => 1
response.should render_nothing
end

2 comments:

Eugene said...

Use rendered_template instead of rendered_file in Rails > 2.1.0

Anonymous said...

The natural scenery here is a reason in and EQ2 gold of itself to visit the state. Places such as the Prime EVE Online ISK Hook National Wildlife Refuge located in Milton which was established in 1963, the 15,978-acre Bombay Hook EVE ISK National Wildlife Refuge located in Smyrna, and the 143-acre Edward H. McCabe Nature Preserve also gaia gold located in Milton delight visitors year-round with their beautiful views and Maple Story mesos vibrant wildlife. For those to like to enjoy the great outdoors by sitting back and relaxing and soaking up the sun there is place such as Bethany Beach where visitors have a one mile stretch to vacation laid back style, or Bellevue State Park where curious vacationers can take in the fabulous scenery year round and at the same time tour the ground of William DuPont Jr. Whatever your style and however you like to spend SRO gold your time outdoors Delaware is the right place to visit.