1) Right now this is just testing a successful response. However, since
I've gone and created a Post via FactoryGirl... how can I test the
@post.id equals one of the id's being returned by the get: index json?


    describe Api::V1::PostsController do

  context 'Post' do
    before(:each) do
      @post = FactoryGirl.create(:post)
    end


    context '#index' do
      it "should have a successful response on get index" do
        get :index, format: :json
        response.should be_success
      end
    end

EDIT:

2) How can I use "post :create" when my route is nested.

For example... this works great as an rspec controller post :create with
a top level resource, such as post

      it "should get a success response on post create" do
        post :create, params
        response.should be_success
      end

however, for a nested resource like 'comment' which is nested under
post... the above would throw the following...

    Failure/Error: post :create, params
     ActionController::UrlGenerationError:
       No route matches

and if I tried

          it "should get a success response on post create" do
        post :create, post_id: @post.id, params #@post is defined and
created above
        response.should be_success
      end

I get this odd error...

    syntax error, unexpected '\n', expecting => (SyntaxError)

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/1362a2e750554081fd57048567852e68%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to