Skip to content

Commit

Permalink
Updating Tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
rposborne committed Feb 1, 2015
1 parent 28c6f98 commit 878aab5
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion spec/controllers/essays/a_controller_spec.rb
@@ -1,5 +1,5 @@
require 'spec_helper'

describe Essays::AController do
describe AController do

end
2 changes: 1 addition & 1 deletion spec/controllers/essays/b_controller_spec.rb
@@ -1,5 +1,5 @@
require 'spec_helper'

describe Essays::BController do
describe BController do

end
2 changes: 1 addition & 1 deletion spec/controllers/essays/c_controller_spec.rb
@@ -1,5 +1,5 @@
require 'spec_helper'

describe Essays::CController do
describe CController do

end
2 changes: 1 addition & 1 deletion spec/controllers/essays/d_controller_spec.rb
@@ -1,5 +1,5 @@
require 'spec_helper'

describe Essays::DController do
describe DController do

end
2 changes: 1 addition & 1 deletion spec/controllers/essays/e_controller_spec.rb
@@ -1,5 +1,5 @@
require 'spec_helper'

describe Essays::EController do
describe EController do

end
2 changes: 1 addition & 1 deletion spec/controllers/essays/f_controller_spec.rb
@@ -1,5 +1,5 @@
require 'spec_helper'

describe Essays::FController do
describe FController do

end
4 changes: 2 additions & 2 deletions spec/controllers/responses_controller_spec.rb
Expand Up @@ -45,7 +45,7 @@ def mock_response(stubs = {})
describe 'POST create' do
describe 'with valid params' do
it 'assigns a newly created response as @response' do
Response.stub(:new).with('these' => 'params') { mock_response(save: true) }
Response.stub(:new).with({"these"=>"params"}, {}) { mock_response(save: true) }
post :create, response: { 'these' => 'params' }
assigns(:response).should be(mock_response)
end
Expand All @@ -59,7 +59,7 @@ def mock_response(stubs = {})

describe 'with invalid params' do
it 'assigns a newly created but unsaved response as @response' do
Response.stub(:new).with('these' => 'params') { mock_response(save: false) }
Response.stub(:new).with({"these"=>"params"}, {}) { mock_response(save: false) }
post :create, response: { 'these' => 'params' }
assigns(:response).should be(mock_response)
end
Expand Down
17 changes: 8 additions & 9 deletions spec/controllers/users_controller_spec.rb
Expand Up @@ -9,13 +9,12 @@
def mock_user(stubs = {})
@mock_user ||= mock_model(User, stubs).as_null_object
end
desribe 'mark completed' do
describe 'mark completed' do
params = {participant_id: 5, group: 3}
u = User.find_or_create_by_id(params[:participant_id], group: params[:group])
it 'sets participant_id' do
puts u
u.id.should eq 5
u.group.should eq 3
u.group.should eq '3'
end
end
describe 'GET index' do
Expand Down Expand Up @@ -53,8 +52,8 @@ def mock_user(stubs = {})
describe 'POST create' do
describe 'with valid params' do
it 'assigns a newly created user as @user' do
User.stub(:new).with('these' => 'params') { mock_user(save: true) }
post :create, user: { 'these' => 'params' }
User.stub(:new).with({"group"=>nil}, {}) { mock_user(save: true) }
post :create, user: { "group"=>nil }
assigns(:user).should be(mock_user)
end

Expand All @@ -67,8 +66,8 @@ def mock_user(stubs = {})

describe 'with invalid params' do
it 'assigns a newly created but unsaved user as @user' do
User.stub(:new).with('these' => 'params') { mock_user(save: false) }
post :create, user: { 'these' => 'params' }
User.stub(:new).with({"group"=>nil}, {}) { mock_user(save: false) }
post :create, user: { "group"=>nil }
assigns(:user).should be(mock_user)
end

Expand All @@ -84,8 +83,8 @@ def mock_user(stubs = {})
describe 'with valid params' do
it 'updates the requested user' do
User.stub(:find).with('37') { mock_user }
mock_user.should_receive(:update_attributes).with('these' => 'params')
put :update, id: '37', user: { 'these' => 'params' }
mock_user.should_receive(:update_attributes).with({"group"=>nil})
put :update, id: '37', user: { "group"=>nil }
end

it 'assigns the requested user as @user' do
Expand Down
2 changes: 1 addition & 1 deletion spec/views/responses/index.html.erb_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'

describe 'responses/index.html.erb' do
describe 'responses/index.html.haml' do
before(:each) do
assign(:responses, [
stub_model(Response,
Expand Down
2 changes: 1 addition & 1 deletion spec/views/users/edit.html.erb_spec.rb
Expand Up @@ -13,7 +13,7 @@

# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select 'form', action: users_path(@user), method: 'post' do
assert_select 'input#user_id', name: 'user[id]'

assert_select 'input#user_name', name: 'user[name]'
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/views/users/index.html.erb_spec.rb
@@ -1,24 +1,24 @@
require 'spec_helper'

describe 'users/index.html.erb' do
describe 'users/index.html.haml' do
before(:each) do
assign(:users, [
stub_model(User,
id: 1,
name: 'Name'
name: 'Name',
group: '4'
),
stub_model(User,
id: 1,
name: 'Name'
name: 'Name',
group: '4'
)
])
end

it 'renders a list of users' do
render
render template: 'users/index.html.haml', layout: 'layouts/application'
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select 'tr>td', text: 1.to_s, count: 2
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select 'tr>td', text: 'Name'.to_s, count: 2
end
end
2 changes: 1 addition & 1 deletion spec/views/users/new.html.erb_spec.rb
Expand Up @@ -13,7 +13,7 @@

# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select 'form', action: users_path, method: 'post' do
assert_select 'input#user_id', name: 'user[id]'

assert_select 'input#user_name', name: 'user[name]'
end
end
Expand Down
@@ -1,6 +1,6 @@
require 'spec_helper'

describe 'users/show.html.erb' do
describe 'users/show.html.haml' do
before(:each) do
@user = assign(:user, stub_model(User,
id: 1,
Expand All @@ -9,7 +9,7 @@
end

it 'renders attributes in <p>' do
render
render template: 'users/show.html.haml', layout: 'layouts/application'
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/1/)
# Run the generator again with the --webrat flag if you want to use webrat matchers
Expand Down

0 comments on commit 878aab5

Please sign in to comment.