Jay Whittaker

Greenhorn
+ Follow
since Jun 01, 2014
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jay Whittaker

Update:

I added this to the model worker.rb, now have only 3 tests left to solve:
9 years ago
So I have the following tests written in the below file. I need to edit 'worker.rb' in order to get it to pass all of the tests.

This is a brain teaser my friend gave me, but I cannot figure out much. Help is much appreciated ;) !!!

worker_spec.rb



worker.rb



Test Fails Log:

....FFFFFFF

Failures:

1) Worker merging two workers should delete the loser
Failure/Error: expect { Worker.find(@loser.id) }.to raise_error(ActiveRecord::RecordNotFound)
expected ActiveRecord::RecordNotFound but nothing was raised
# ./spec/models/worker_spec.rb:35:in `block (3 levels) in <top (required)>'

2) Worker merging two workers should merge the writings together
Failure/Error: @result.writings.length.should eq 2

expected: 2
got: 1

(compared using ==)
# ./spec/models/worker_spec.rb:39:in `block (3 levels) in <top (required)>'

3) Worker merging two workers when the winner has no email should merge in the loser's email
Failure/Error: @result.email.should eq @loser.email

expected: "loser@example.com"
got: ""

(compared using ==)
# ./spec/models/worker_spec.rb:51:in `block (3 levels) in <top (required)>'

4) Worker duplicate detection should return true if the first name, last name, and email are the same
Failure/Error: @joe.duplicates?(@dupe).should be_true
NoMethodError:
undefined method `duplicates?' for #<Worker:0x007f988a283ca8>
# ./spec/models/worker_spec.rb:63:in `block (3 levels) in <top (required)>'

5) Worker duplicate detection should return false if the first name, last name, or email are different
Failure/Error: @joe.duplicates?(@tim).should be_false
NoMethodError:
undefined method `duplicates?' for #<Worker:0x007f988a37c768>
# ./spec/models/worker_spec.rb:67:in `block (3 levels) in <top (required)>'

6) Worker duplicate detection should return false if the argument is nil
Failure/Error: @joe.duplicates?(nil).should be_false
NoMethodError:
undefined method `duplicates?' for #<Worker:0x007f9889f89cc8>
# ./spec/models/worker_spec.rb:71:in `block (3 levels) in <top (required)>'

7) Worker duplicate detection should return true if the argument is self
Failure/Error: @joe.duplicates?(@joe).should be_true
NoMethodError:
undefined method `duplicates?' for #<Worker:0x007f988c003aa8>
# ./spec/models/worker_spec.rb:75:in `block (3 levels) in <top (required)>'

Finished in 0.19964 seconds
11 examples, 7 failures



Thanks for any advice you can give!!!

9 years ago