/
channels_controller_spec.rb
69 lines (55 loc) · 1.5 KB
/
channels_controller_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
require "spec_helper"
describe ChannelsController do
include Devise::TestHelpers
before(:all) do
@channel = FactoryGirl.create(:channel)
@user = FactoryGirl.create(:user)
end
before(:each) do
sign_in @user
end
describe "GET index" do
before do
get :index, :format => :json
end
it "should return list of channels in JSON" do
expect(JSON(response.body)).to be_kind_of(Array)
end
it "should have an array for activities in the JSON response" do
expect(JSON(response.body).first["activities"]).to be_kind_of(Array)
end
end
describe "GET show" do
before do
get :show, :id => @channel.id, :format => :json
end
it "should return the channel data in json" do
expect(response).to be_ok
end
end
describe "POST create" do
before do
channel = { :name => Faker::Internet.domain_word }
post :create, :channel => channel, :format => :json
end
it "should create a channel" do
expect(response.status).to eq(201)
end
end
describe "PUT update" do
before do
put :update, :id => @channel.id, :channel => {:name => "SuperTest"}, :format => :json
end
it "should update the channel" do
expect(response.status).to eq(200)
end
end
describe "DELETE destroy" do
before do
delete :destroy, :id => @channel.id, :format => :json
end
it "should destroy the channel" do
expect(response.status).to eq(200)
end
end
end