Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from amanelis/spec-updates
Spec updates, gem updates, lots more.
- Loading branch information
Showing
14 changed files
with
156 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
/app/assets/stylesheets/.sass-cache | ||
|
||
.bushido | ||
.rvmrc | ||
|
||
/public/assets | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,33 @@ | ||
require "spec_helper" | ||
|
||
describe ApisController do | ||
include Devise::TestHelpers | ||
|
||
before :each do | ||
@user = Factory :user | ||
request.env['warden'].stub :authenticate! => @user | ||
controller.stub :current_user => @user | ||
end | ||
|
||
|
||
describe "active_users" do | ||
it "should return json" do | ||
get :active_users, :format => :json | ||
ActiveUsers.stub!(:all).and_return([]) | ||
JSON(response.body).should be_kind_of(Array) | ||
describe "#active_users" do | ||
before do | ||
@user = FactoryGirl.create(:user) | ||
end | ||
|
||
context "when a user is authenticated" do | ||
before do | ||
sign_in @user | ||
get :active_users, :format => :json | ||
end | ||
|
||
it "should return json" do | ||
ActiveUsers.stub!(:all).and_return([]) | ||
expect(JSON(response.body)).to be_kind_of(Array) | ||
end | ||
end | ||
|
||
context "when a user is NOT authenticated" do | ||
before do | ||
get :active_users, :format => :json | ||
end | ||
|
||
it "should not render any data or anything other than a 401" do | ||
expect(response.status).to eq(401) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,69 @@ | ||
require "spec_helper" | ||
|
||
describe ChannelsController do | ||
|
||
before :all do | ||
@channel = Factory :channel | ||
include Devise::TestHelpers | ||
|
||
before(:all) do | ||
@channel = FactoryGirl.create(:channel) | ||
@user = FactoryGirl.create(:user) | ||
end | ||
|
||
before :each do | ||
@user = Factory :user | ||
request.env['warden'].stub :authenticate! => @user | ||
controller.stub :current_user => @user | ||
before(:each) do | ||
sign_in @user | ||
end | ||
|
||
describe "GET index" do | ||
it "should return list of channels in JSON" do | ||
before do | ||
get :index, :format => :json | ||
JSON(response.body) # parse to validate 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 | ||
get :index, :format => :json | ||
puts JSON(response.body).first["activities"].should be_kind_of(Array) | ||
expect(JSON(response.body).first["activities"]).to be_kind_of(Array) | ||
end | ||
end | ||
|
||
describe "GET show" do | ||
it "should return the channel data in json" do | ||
before do | ||
get :show, :id => @channel.id, :format => :json | ||
response.should be_ok | ||
end | ||
|
||
it "should return the channel data in json" do | ||
expect(response).to be_ok | ||
end | ||
end | ||
|
||
describe "POST create" do | ||
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 | ||
channel_attributes = Factory.build :channel | ||
Channel.any_instance.should_receive(:save) | ||
post :create, :format => :json | ||
expect(response.status).to eq(201) | ||
end | ||
end | ||
|
||
describe "PUT update" do | ||
it "should update the channel" do | ||
# Channel.any_instance.should_receive(:update_attributes) | ||
before do | ||
put :update, :id => @channel.id, :channel => {:name => "SuperTest"}, :format => :json | ||
response.should be_ok | ||
end | ||
|
||
it "should update the channel" do | ||
expect(response.status).to eq(200) | ||
end | ||
end | ||
|
||
describe "DELETE destroy" do | ||
it "should destroy the channel" do | ||
# Channel.any_instance.should_receive(:destroy) | ||
before do | ||
delete :destroy, :id => @channel.id, :format => :json | ||
response.should be_ok | ||
end | ||
|
||
it "should destroy the channel" do | ||
expect(response.status).to eq(200) | ||
end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.