Last active
August 29, 2015 14:17
-
-
Save maxmanders/40c2000bb45b66349887 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
RSpec.describe DashboardController, type: :controller do | |
describe "Dashboard" do | |
before do | |
sign_in_as_a_valid_user | |
end | |
describe "GET /dashboard/index" do | |
it "Gives the expected status code." do | |
get dashboard_index_path | |
response.status.should be(200) | |
end | |
#it "Should contain Cirrus 2.0 in the masthead." do | |
#get dashboard_index_path | |
#response.body.should have_xpath('//*[@id="wrapper"]/nav/div[1]/a[contains(., "Cirrus 2.0")]') | |
#end | |
#it "Should should have the user's email address in a drop-down link." do | |
#get dashboard_index_path | |
#response.body.should have_xpath("//*[@id='wrapper']/nav/ul/li/a[contains(., '#{user.email}')]") | |
#end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ValidUserHelper | |
def signed_in_as_a_valid_user | |
@user ||= FactoryGirl.create :user | |
sign_in @user | |
end | |
end | |
module ValidUserRequestHelper | |
def sign_in_as_a_valid_user | |
@user ||= FactoryGirl.create :user | |
post user_session_path, 'user[email]' => @user.email, 'user[password]' => @user.password | |
end | |
end | |
RSpec.configure do |config| | |
config.include ValidUserHelper | |
config.include ValidUserRequestHelper | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.routes.draw do | |
get 'dashboard/index' | |
devise_for :users, skip: :registrations | |
devise_scope :user do | |
resource :registration, | |
only: [:new, :create, :edit, :update], | |
path: 'users', | |
path_names: { new: 'sign_up' }, | |
controller: 'devise/registrations', | |
as: :user_registration do | |
get :cancel | |
end | |
end | |
namespace :api, :path => "", :constraints => { :subdomain => "api" }, :defaults => { :format => :json } do | |
namespace :v1 do | |
get '/echo/:message', to: 'status#echo' | |
end | |
end | |
root "dashboard#index" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
╭─max@hedgehog ~/dev/cirrus-v2-api ‹ruby-2.1.5› ‹feature/user-model*› | |
╰─$ rspec | |
Run options: include {:focus=>true} | |
All examples were filtered out; ignoring {:focus=>true} | |
Randomized with seed 35411 | |
F | |
Failures: | |
1) DashboardController Dashboard GET /dashboard/index Gives the expected status code. | |
Failure/Error: sign_in_as_a_valid_user | |
ActionController::UrlGenerationError: | |
No route matches {:action=>"/users/sign_in", :controller=>"dashboard", :"user[email]"=>"[email protected]", :"user[password]"=>"P@ssw0rd1!"} | |
# /Users/max/.rvm/gems/ruby-2.1.5/gems/actionpack-4.1.8/lib/action_dispatch/journey/formatter.rb:39:in `generate' | |
# /Users/max/.rvm/gems/ruby-2.1.5/gems/actionpack-4.1.8/lib/action_dispatch/routing/route_set.rb:599:in `generate' | |
# /Users/max/.rvm/gems/ruby-2.1.5/gems/actionpack-4.1.8/lib/action_dispatch/routing/route_set.rb:629:in `generate' | |
# /Users/max/.rvm/gems/ruby-2.1.5/gems/actionpack-4.1.8/lib/action_dispatch/routing/route_set.rb:624:in `generate_extras' | |
# /Users/max/.rvm/gems/ruby-2.1.5/gems/actionpack-4.1.8/lib/action_dispatch/routing/route_set.rb:620:in `extra_keys' | |
# /Users/max/.rvm/gems/ruby-2.1.5/gems/actionpack-4.1.8/lib/action_controller/test_case.rb:189:in `assign_parameters' | |
# /Users/max/.rvm/gems/ruby-2.1.5/gems/actionpack-4.1.8/lib/action_controller/test_case.rb:582:in `process' | |
# /Users/max/.rvm/gems/ruby-2.1.5/gems/actionpack-4.1.8/lib/action_controller/test_case.rb:64:in `process' | |
# /Users/max/.rvm/gems/ruby-2.1.5/gems/actionpack-4.1.8/lib/action_controller/test_case.rb:501:in `post' | |
# ./spec/support/devise_support.rb:11:in `sign_in_as_a_valid_user' | |
# ./spec/controllers/dashboard_controller_spec.rb:8:in `block (3 levels) in <top (required)>' | |
Top 1 slowest examples (0.03485 seconds, 53.0% of total time): | |
DashboardController Dashboard GET /dashboard/index Gives the expected status code. | |
0.03485 seconds ./spec/controllers/dashboard_controller_spec.rb:13 | |
Finished in 0.06579 seconds (files took 1.42 seconds to load) | |
1 example, 1 failure | |
Failed examples: | |
rspec ./spec/controllers/dashboard_controller_spec.rb:13 # DashboardController Dashboard GET /dashboard/index Gives the expected status code. | |
Randomized with seed 35411 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[7] pry(main)> show-routes | |
Prefix Verb URI Pattern Controller#Action | |
dashboard_index GET /dashboard/index(.:format) dashboard#index | |
new_user_session GET /users/sign_in(.:format) devise/sessions#new | |
user_session POST /users/sign_in(.:format) devise/sessions#create | |
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy | |
user_password POST /users/password(.:format) devise/passwords#create | |
new_user_password GET /users/password/new(.:format) devise/passwords#new | |
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit | |
PATCH /users/password(.:format) devise/passwords#update | |
PUT /users/password(.:format) devise/passwords#update | |
cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel | |
user_registration POST /users(.:format) devise/registrations#create | |
new_user_registration GET /users/sign_up(.:format) devise/registrations#new | |
edit_user_registration GET /users/edit(.:format) devise/registrations#edit | |
PATCH /users(.:format) devise/registrations#update | |
PUT /users(.:format) devise/registrations#update | |
api_v1 GET /v1/echo/:message(.:format) api/v1/status#echo {:format=>:json, :subdomain=>"api"} | |
root GET / |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment