Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- how to use padrino helper methods in rspec
- describe "POST /sessions" do
- it "should populate current_user after posting correct user/pass" do
- u = User.create({:email=>"john@gmail.com", :password=>"helloworld", :password_confirmation=>"helloworld"})
- user = {
- email:"john@gmail.com",
- password:"hellowolrd"
- }
- post '/sessions/new', user
- current_user.should_not == "null"
- end
- end
- post "/new" do
- user = User.authenticate(params[:email], params[:password])
- if user
- session[:user_id] = user.id
- redirect '/'
- else
- render "sessions/new"
- end
- end
- Testing.helpers do
- def current_user
- @current_user ||= User.find(:id=>session[:user_id]) if session[:user_id]
- end
- end
- Failures:
- 1) SessionsController POST /users should populate current_user after posting correct user/pass
- Failure/Error: current_user.should_not == "null"
- NameError:
- undefined local variable or method `current_user' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_2:0x0000000313c0d8>
- # ./spec/app/controllers/sessions_controller_spec.rb:20:in `block (3 levels) in <top (required)>'
Add Comment
Please, Sign In to add comment