CoolJorcz/karmaville — pull request #2 by CoolJorcz (2013-09-03 00:52:10+00:00)
Title: WIP integration and model testing

We're having problems with user model testing, it keeps giving us a nil class error for most of them.

We're also having problems with the integration test, it has the same error.

Here are the errors:

UsersController
.page
should return the correct page number

User
should have many karma_points
#total_karma
returns the total karma for the user (FAILED - 1)
#full_name
returns both the first and last names in a single string
#valid?
should require username to be set
should ensure username has a length between 2 and 32
should require first_name to be set
should require last_name to be set
should require email to be set
when a user already exists
example at ./spec/models/user_spec.rb:19 (FAILED - 2)
example at ./spec/models/user_spec.rb:18 (FAILED - 3)
.by_karma
returns users in order of highest-to-lowest karma (FAILED - 4)
.page
should return the correct page number

pagination
clicking page 1 (FAILED - 5)

KarmaPoint
should belong to user
#save
increments the user's total_karma by the value of the karma point (FAILED - 6)
#valid?
should allow value to be set to 1
should require label to be set
should only allow numeric, integer values for value
should allow value to be set to 0
should require user to be set
should not allow value to be set to -1

Failures:

1) User#total_karma returns the total karma for the user
Failure/Error: let(:user) { create(:user_with_karma, :total => 500, :points => 2) }
NoMethodError:
undefined method `+' for nil:NilClass
# ./app/models/user.rb:31:in `update_karma'
# ./spec/models/user_spec.rb:34:in `block (3 levels) in '
# ./spec/models/user_spec.rb:37:in `block (3 levels) in '

2) User#valid? when a user already exists
Failure/Error: before { create(:user) }
NoMethodError:
undefined method `+' for nil:NilClass
# ./app/models/user.rb:31:in `update_karma'
# ./spec/models/user_spec.rb:16:in `block (4 levels) in '

3) User#valid? when a user already exists
Failure/Error: before { create(:user) }
NoMethodError:
undefined method `+' for nil:NilClass
# ./app/models/user.rb:31:in `update_karma'
# ./spec/models/user_spec.rb:16:in `block (4 levels) in '

4) User.by_karma returns users in order of highest-to-lowest karma
Failure/Error: user_med = create(:user_with_karma, :total => 500, :points => 2)
NoMethodError:
undefined method `+' for nil:NilClass
# ./app/models/user.rb:31:in `update_karma'
# ./spec/models/user_spec.rb:25:in `block (3 levels) in '

5) pagination clicking page 1
Failure/Error: generate_users
NoMethodError:
undefined method `+' for nil:NilClass
# ./app/models/user.rb:31:in `update_karma'
# ./spec/support/generate_users.rb:4:in `block in generate_users'
# ./spec/support/generate_users.rb:3:in `times'
# ./spec/support/generate_users.rb:3:in `generate_users'
# ./spec/features/users_spec.rb:8:in `block (2 levels) in '

6) KarmaPoint#save increments the user's total_karma by the value of the karma point
Failure/Error: let(:user) { create(:user) }
NoMethodError:
undefined method `+' for nil:NilClass
# ./app/models/user.rb:31:in `update_karma'
# ./spec/models/karma_point_spec.rb:18:in `block (3 levels) in '
# ./spec/models/karma_point_spec.rb:23:in `block (3 levels) in '

Finished in 0.59472 seconds
22 examples, 6 failures

Failed examples:

rspec ./spec/models/user_spec.rb:36 # User#total_karma returns the total karma for the user
rspec ./spec/models/user_spec.rb:19 # User#valid? when a user already exists
rspec ./spec/models/user_spec.rb:18 # User#valid? when a user already exists
rspec ./spec/models/user_spec.rb:24 # User.by_karma returns users in order of highest-to-lowest karma
rspec ./spec/features/users_spec.rb:11 # pagination clicking page 1
rspec ./spec/models/karma_point_spec.rb:20 # KarmaPoint#save increments the user's total_karma by the value of the karma point