My users_controller.rb
def edit
@user = current_user
end
my sweet looking users_controller_spec.rb (note all my attempts to comment)
describe "Authenticated examples" do
before(:each) do
activate_authlogic
UserSession.create Factory.build(:valid_user)
end
describe "GET edit" do
it "assigns the requested user as @user" do
@user = Factory.create(:valid_user)
assigns(:user).should be(Factory.build(:valid_user))
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 "elephant@gmail.com"
u.single_access_token "k3cFzLIQnZ4MHRmJvJzg"
end
Basically, I'm just trying to pass this RSpec test in the most appropriate way.
I need to say very simply what mock_userit is current_user.
This test passes if I use in my users_controller.rb @user = User.find(params[:id])
Thank!!
source
share