diff --git a/spec/controller/bets_controller_spec.rb b/spec/controllers/bets_controller_spec.rb similarity index 100% rename from spec/controller/bets_controller_spec.rb rename to spec/controllers/bets_controller_spec.rb diff --git a/spec/controller/static_pages_controller_spec.rb b/spec/controllers/static_pages_controller_spec.rb similarity index 100% rename from spec/controller/static_pages_controller_spec.rb rename to spec/controllers/static_pages_controller_spec.rb diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb new file mode 100644 index 0000000..a79e9bf --- /dev/null +++ b/spec/controllers/users_controller_spec.rb @@ -0,0 +1,25 @@ +require "rails_helper" +include SessionsHelper + +RSpec.describe UsersController, type: :controller do + describe "GET #show" do + let!(:user) { create(:user)} + + context "when user logged in" do + before do + log_in user + get :show, params: { id: user.id } + end + it "render show template" do + expect(response).to render_template(:show) + end + end + + context "when user not logged in" do + it "redirect to login template" do + get :show, params: { id: user.id } + expect(response).to redirect_to login_path + end + end + end +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index f50c86e..9925b30 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -4,7 +4,8 @@ abort("The Rails environment is running in production mode!") if Rails.env.production? require "rspec/rails" -require "support/factory_bot" + +Dir[Rails.root.join("spec", "support", "**", "*.rb")].each { |f| require f } begin ActiveRecord::Migration.maintain_test_schema!