-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
I'm writting an API for a pet project of mine and was running rails 3.2.9
I decided to update rails in order to avoid security problems but I suddenly ran into some problems.
I've been able to resolve most of them but I keep getting this and don't know what to do with it.
I am using RSPEC to test a json API and until this upgrade everything was going just fine and all routes were working perfectly.
I'm not sure wether it's a bug or a bad usage from me, so I'm sorry if it's the former.
Here is my code :
Routes :
Fake::Application.routes.draw do
namespace :api do
namespace :v1 do
scope '/user' do
match "signup" => "registrations#create", :via => :post
match "delete" => "registrations#destroy", :via => :delete
match "login" => "sessions#create", :via => :post
match "logout" => "sessions#destroy", :via => :delete
end
end
end
end
Spec :
require 'spec_helper'
describe Api::V1::SessionsController do
before do
@user = {
:email => Faker::Internet::email,
:pseudo => Faker::Internet::user_name,
:password => Faker::Lorem::words(2).join
}
user = User.create @user
end
context 'should login in' do
it 'should be ok ' do
post '/api/v1/user/login', :user => @user
JSON.parse(response.body)["success"].should == true
end
it 'should fail without credentials' do
post '/api/v1/user/login', {}
JSON.parse(response.body)["success"].should == false
end
end
end
And the result :
± rspec spec/controllers/sessions_controller_spec.rb 5:21:10 PM
Rack::File headers parameter replaces cache_control after Rack 1.5.
FF
Failures:
1) Api::V1::SessionsController should login in should be ok with auth_token
Failure/Error: post '/api/v1/user/login', :user => @user
ActionController::RoutingError:
No route matches {:user=>{:email=>"meghan.breitenberg@bodehansen.org", :pseudo=>"linwood_gislason", :password=>"repellendusaliquid"}, :controller=>"api/v1/sessions", :action=>"/api/v1/user/login"}
# ./spec/controllers/sessions_controller_spec.rb:17:in `block (3 levels) in <top (required)>'
2) Api::V1::SessionsController should login in should fail without credentials
Failure/Error: post '/api/v1/user/login', {}
ActionController::RoutingError:
No route matches {:controller=>"api/v1/sessions", :action=>"/api/v1/user/login"}
# ./spec/controllers/sessions_controller_spec.rb:22:in `block (3 levels) in <top (required)>'
Finished in 0.50905 seconds
2 examples, 2 failures
Failed examples:
rspec ./spec/controllers/sessions_controller_spec.rb:15 # Api::V1::SessionsController should login in should be ok with auth_token
rspec ./spec/controllers/sessions_controller_spec.rb:21 # Api::V1::SessionsController should login in should fail without credentials
Edit :
Rails version : 3.2.11
Rspec version : 2.12.2
Ruby version : ruby 1.9.3p0
Metadata
Metadata
Assignees
Labels
No labels