From e55c039d16acbdcd5a64642eb2abcf12229050e5 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Wed, 22 Apr 2015 01:15:27 -0700 Subject: [PATCH] consistency in code style..ish [ci skip] --- .../api/v1/users_controller_spec.rb | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/spec/controllers/api/v1/users_controller_spec.rb b/spec/controllers/api/v1/users_controller_spec.rb index 8c045e9..4524eb0 100644 --- a/spec/controllers/api/v1/users_controller_spec.rb +++ b/spec/controllers/api/v1/users_controller_spec.rb @@ -9,19 +9,16 @@ describe "GET #show" do before(:each) do - #Added by steve for alec fakeuser = double('user') allow(request.env['warden']).to receive(:authenticate!).and_return(fakeuser) allow(controller).to receive(:current_user).and_return(fakeuser) - - @user = FactoryGirl.create :user get :show, id: @user.id, format: :json end - it "returns the information about a reporter on a hash" do + it "renders json with the users info" do user_response = JSON.parse(response.body, symbolize_names: true) expect(user_response[:email]).to eql @user.email end @@ -30,12 +27,10 @@ end describe "POST #create" do - - context "when is successfully created" do + context "when a user is successfully created" do before(:each) do @user_attrs = FactoryGirl.attributes_for :user - # Added by steve for alec fakeuser = double('user') allow(request.env['warden']).to receive(:authenticate!).and_return(fakeuser) allow(controller).to receive(:current_user).and_return(fakeuser) @@ -51,13 +46,12 @@ it { should respond_with 201 } end - context "when is not created" do + context "when a user is not created" do before(:each) do - #notice I'm not including the email + # notice I'm not including the email @invalid_user_attributes = { password: "12345678", password_confirmation: "12345678" } - #Added by steve for alec fakeuser = double('user') allow(request.env['warden']).to receive(:authenticate!).and_return(fakeuser) allow(controller).to receive(:current_user).and_return(fakeuser) @@ -66,12 +60,12 @@ post :create, { user: @invalid_user_attributes }, format: :json end - it "renders an errors json" do + it "renders json with errors" do user_response = JSON.parse(response.body, symbolize_names: true) expect(user_response).to have_key(:errors) end - it "renders the json errors on why the user could not be created" do + it "renders json errors for why the user could not be created" do user_response = JSON.parse(response.body, symbolize_names: true) expect(user_response[:errors][:email]).to include "can't be blank" end @@ -84,14 +78,11 @@ before(:each) do @user = FactoryGirl.create :user - #Added by steve for alec fakeuser = double('user') allow(request.env['warden']).to receive(:authenticate!).and_return(fakeuser) allow(controller).to receive(:current_user).and_return(fakeuser) delete :destroy, { id: @user.id }, format: :json - - end it { should respond_with 204 } @@ -99,8 +90,7 @@ end describe "PUT/PATCH #update" do - - context "when is successfully updated" do + context "when a user successfully updated" do before(:each) do @user = FactoryGirl.create :user