Testing Rails Metal/Rack with RSpec?

Posted by Matt Darby on Stack Overflow See other posts from Stack Overflow or by Matt Darby
Published on 2010-03-15T18:47:44Z Indexed on 2010/03/15 18:49 UTC
Read the original article Hit count: 435

Filed under:
|
|

Say I have a Metal class named Preview. How do I test it with RSpec?

When I try:

require 'spec_helper'

describe Preview do

  it "should return the posted content" do
    post "/preview", :content => "*title*"
    response.body.should == "*title*"
  end

end

I get:

undefined method `post' for #<ActiveSupport::TestCase::Subclass_1:0x1058b3098>

It seems that RSpec doesn't load up the :post method if the test isn't explicitly for a Controller. I've tried specifying :type => :controller to no avail.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about rspec