describe " create action" do
before(:each) do @user = mock_model(User,:user => “value”)
controller.stub!(:require_user).and_return(@user)
controller.stub!(:uses_mailer).and_return(@user)
User.stub!(:new).and_return(@user)
end
it “should create a new user object” do
User.should_receive(:new).with(:user=>“value”).and_return(@user)
post :create,:user => “value”
end
end
end
Error:
<User(id: integer, created_on: datetime, updated_on: datetime,
destroyed_on: dat
etime, accessed_on: datetime, email_address: string, name_first: string,
name_la
st: string, mailing_address_id: integer, billing_address_id: integer,
name_displ
ay: string, picture_id: integer, url: string, country: string,
freelance: boolea
n, statement: string, hostname_active: boolean, hostname: string,
promotional_ma
ilings: boolean, sales_commission_rate: float, referral_commission_rate:
float,
employee_lock: boolean) (class)> expected :new with ({:user=>“value”})
once, but
received it 0 times
describe :create do
before(:each) do
controller.stub!(:require_user).and_return(@user)
controller.stub!(:uses_mailer).and_return(@user)
User.stub!(:new).and_return(@user)
post :create,{:terms_and_conditions => “1”,:promotional_mailings =>
“0”,:email_address => “[email protected]”},:user => {}
end
it “should create a new user object” do
User.should_receive(:new).with({“terms_and_conditions” =>
“1”,“promotional_mailings” => “0”,“email_address” =>
“[email protected]”}).and_return(@user)
post :create,{:terms_and_conditions => “1”,:promotional_mailings
=> “0”,:email_address => “[email protected]”},:user => {}
end
end
end
Error
Spec::Mocks::MockExpectationError in ‘UsersController create should
create a new
user object’
<User(id: integer, created_on: datetime, updated_on: datetime,
destroyed_on: dat
etime, accessed_on: datetime, email_address: string, name_first: string,
name_la
st: string, mailing_address_id: integer, billing_address_id: integer,
name_displ
ay: string, picture_id: integer, url: string, country: string,
freelance: boolea
n, statement: string, hostname_active: boolean, hostname: string,
promotional_ma
ilings: boolean, sales_commission_rate: float, referral_commission_rate:
float,
employee_lock: boolean) (class)> expected :new with
({“terms_and_conditions”=>"1
", “promotional_mailings”=>“0”, “email_address”=>“[email protected]”}) once,
but rec
eived it 0 times