I'm writing an rspec scenario thats failing with:
(#<User:0x1056904f0>).update_attributes(#<RSpec::Mocks::ArgumentMatchers::AnyArgMatcher:0x105623648>)
expected: 1 time
received: 0 times
users_controller_spec.rb:
describe "Authenticated examples" do
before(:each) do
activate_authlogic
@user = Factory.create(:valid_user)
UserSession.create(@user)
end
describe "PUT update" do
it "updates the requested user" do
User.stub!(:current_user).and_return(@user)
@user.should_receive(:update_attributes).with(anything()).and_return(true)
put :update, :id => @user , :current_user => {'email' => 'Trippy'}
puts "Spec Object Id : " + "#{@user.object_id}"
end
users_controller.rb:
def update
@user = current_user
puts "Controller Object ID is : " + "#{@user.object_id}"
respond_to do |format|
if @user.update_attributes(params[:user])
format.html { redirect_to(root_url, :notice => 'Successfully updated profile.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
end
end
end
user.rb - factories
Factory.define :valid_user, :class => User do |u|
u.username "Trippy"
u.password "password"
u.password_confirmation "password"
u.email "[email protected]"
u.single_access_token "k3cFzLIQnZ4MHRmJvJzg"
u.id "37"
end