I am writing some tests for a JSON API. Would using controller specs with render_views be an acceptable way of doing this? For example, something like:
describe 'task028: Adding an Item via MenuHeader', task028: true do
it 'should create a new menu item' do
m=FactoryGirl.create(:menu)
mh=FactoryGirl.create(:header, parent: nil, menu_id: m.id)
Item.count.should eq(0)
post :create, {item: { header: "my menu item header", detail: "my menu item detail", menu_header_id: mh.id, position: 1, is_enabled: true }}
MenuItem.count.should eq(1)
JSON.parse(response.body)['status'].should eq('success')
JSON.parse(response.body)['preceding_item_id'].should eq(nil)
response.code.should eq('200')
end
Is this style ok? Or are there other / better ways to test a JSON api? Should these be feature specs?