[rspec-users] Possible Problem with RSpec and

Luis Lavena luislavena at gmail.com
Sat Nov 24 20:25:49 EST 2007


On Nov 24, 2007 9:48 PM, James B. Byrne <byrnejb at harte-lyne.ca> wrote:
> Sorry to be such a pest but I am trying to learn Ruby, Rails and RSpec all
> at one go and it is a bit overwhelming.  I have previously completed the
> depot tutorial in the Agile Web Dev with rails book and now I am trying do
> do it again using RSpec.
>
> What I would like to know now is why I am getting a rake failure error at
> the end of every spec:models run.  Is this the expected behaviour when a
> test / expectation fails?
>

You didn't pasted the code of your specs... only the backtrace...

Please include the spec/models/product_spec.rb code here so we can see
your problem.

Also, it seems your validations aren't right, since you're evaluating
"be_valid" for product after title being set, but #valid? is returning
false.

Maybe you're "asking" the wrong question to your model?
(not tested code)

it "should have a title" do
  @product = Product.new(:title => nil)
  @product.should_not be_valid
  @product.should have_at_least(1).errors_on(:title)
end

also, versions of ruby, rails, rspec and database engine are helpful too ;-)

-- 
Luis Lavena
Multimedia systems
-
Leaders are made, they are not born. They are made by hard effort,
which is the price which all of us must pay to achieve any goal that
is worthwhile.
Vince Lombardi


More information about the rspec-users mailing list