[rspec-users] My first tests, backwards. Please help

Jesse Crockett lists at ruby-forum.com
Tue Dec 30 17:17:58 EST 2008


Hello,

I'm trying to get a positive attitude towards testing.  I wrote a
controller that seems to work, and I want to make some tests.  I
populated the test db with an auction, some users, an item, and some
charities.  But, here is my first test, can't get it to pass.  If you
please, can you just help me get this test to pass, and not dwell on how
wrong my approach is?  I'll appreciate it, thanks.

require File.dirname(__FILE__) + '/../spec_helper'

describe "bidding on an item" do
  controller_name :items
  integrate_views

  before :each do
    @user = User.first
    User.stub!(:current_user).with(@user)
  end

  it "should require a credit" do
    @user.credits = 0
    @user.save
    post 'bid', :bid => {:auction_id => 1, :user_id => @user, :point =>
1}
    Bid.count.should == 0
  end

end
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list