On Thu, Mar 20, 2008 at 6:03 PM, Pietro Mascagni <[EMAIL PROTECTED]> wrote:
> Is there anyway to achieve inheritance of specifications?
>
>  Suppose I had an action like
>
>  def index
>   filter = params[:filter] ? params[:filter] : '%'
>   order = params[:order] ? params[:order] : 'created_at DESC'
>   @posts = Post.find(:conditions => "title LIKE #{filter}", :order => order)
>   ...
>  end

If you use shared example groups, you can do stuff like

describe FooController do
  it_should_behave_like "super filtered out thing"
end

The docs at rspec.info have examples.

As a side note, you can shorten that action (and get rid of the
ternary operators) by doing:
filter = params[:filter] || '%'
order = params[:order] || 'created_at DESC'

Pat
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to