aspose file tools*
The moose likes Ruby and the fly likes Ruby on Rails tests - how to make them pass?  (Rspec, TDD) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Ruby
Bookmark "Ruby on Rails tests - how to make them pass?  (Rspec, TDD)" Watch "Ruby on Rails tests - how to make them pass?  (Rspec, TDD)" New topic
Author

Ruby on Rails tests - how to make them pass? (Rspec, TDD)

Jay Whittaker
Greenhorn

Joined: Jun 01, 2014
Posts: 2
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!!!

Jay Whittaker
Greenhorn

Joined: Jun 01, 2014
Posts: 2
Update:

I added this to the model worker.rb, now have only 3 tests left to solve:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ruby on Rails tests - how to make them pass? (Rspec, TDD)