New bie question: Why use assert_equal when there are comparison operators in Rspec?

hi guys,
I’m reading up on Rspec, Mocha and some related material to put BDD
in my new rails app.

I have also checked out Ryan B.’ railscasts on rspec (that’s how I
got to know about Mocha).

Reading up on the Rspec’s main site, the main example in
http://rspec.rubyforge.org/rspec/1.3.0/ does not show any use of
assert_equals. Rather it just uses the “==” comparison operators.
Here’s an extract:

============ Extract begin ===========================

it "reduces its balance by the transfer amount" do
  source = Account.new(50, :USD)
  target = stub('target account')
  source.transfer(5, :USD).to(target)
  source.balance.should == Money.new(45, :USD) <----- here
end

end
end
============ Extract end ===========================

Newbie question (don’t shoot me cause I tried reading up and can’t
find out why): Why do folks still use assert_equal if the comparison
operators (apart from that there’s a Test::Unit::Assertions module
(http://ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit/
Assertions.html) written for it)?

On Aug 06, 2010, at 3:52 am, ct9a wrote:

Reading up on the Rspec’s main site, the main example in
http://rspec.rubyforge.org/rspec/1.3.0/ does not show any use of
assert_equals. Rather it just uses the “==” comparison operators.
Here’s an extract:

assert_equals is part of Test::Unit, not RSpec. You can’t use
assert_equals in RSpec unless you also have Test::Unit loaded. The
default Rails test suite setup is based on Test::Unit, so you have
access to both. (RSpec it designed to integrate with it.) There’s no
reason to use assert_equals unless you want to, and personally I’d avoid
miking the two styles.

HTH

Ash


http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs