Commit a141d7d1

mo khan <mo@mokhan.ca>
2014-11-22 00:00:35
add specs for photos controller.
1 parent 1cd098e
Changed files (1)
spec
controllers
spec/controllers/api/v2/photos_controller_spec.rb
@@ -0,0 +1,26 @@
+require 'rails_helper'
+
+module Api
+  module V2
+    describe PhotosController do
+      describe "#index" do
+        let!(:photo) { create(:photo) }
+
+        it 'should load all the photos' do
+          xhr :get, :index
+          expect(assigns(:photos)).to match_array([photo])
+        end
+      end
+
+      describe "#show" do
+        let!(:other_photo) { create(:photo) }
+        let!(:photo) { create(:photo) }
+
+        it 'loads the specified photo' do
+          xhr :get, :show, id: photo.id
+          expect(assigns(:photo)).to eql(photo)
+        end
+      end
+    end
+  end
+end