diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..4e49b6c --- /dev/null +++ b/.rspec @@ -0,0 +1,12 @@ +<<<<<<< HEAD +--format documentation +--require spec_helper +======= +--require spec_helper + +--format documentation +--color + +--color +--format documentation +>>>>>>> 9fb149fe2ba069d7a44a08f92a3869118afb44ad diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 35cee72..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.4.3 diff --git a/Gemfile b/Gemfile index 9846c41..1ab8e38 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,5 @@ source 'https://rubygems.org' -ruby '2.6.3' - -gem 'rails', '5.1.5' +ruby '2.5.1' gem 'bootstrap-sass' gem 'chosen-rails' @@ -16,10 +14,26 @@ gem 'sass-rails', '~> 5.0' gem 'turbolinks' gem 'uglifier', '>= 1.3.0' -group :development do +group :development, :test do + gem 'rspec-rails' + gem 'shoulda-matchers' + gem 'factory_bot_rails' + gem 'capybara' gem 'pry-byebug' + gem 'coveralls', require: false +end + +group :development do gem 'spring' gem 'web-console', '~> 2.0' + gem 'capybara' +end + +group :development, :test do + gem 'rspec-rails' + gem 'shoulda-matchers' + gem 'capybara' + gem 'factory_bot_rails' end group :production do diff --git a/Gemfile.lock b/Gemfile.lock index d728002..24d124e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,46 +1,50 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.1.5) - actionpack (= 5.1.5) + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) nio4r (~> 2.0) - websocket-driver (~> 0.6.1) - actionmailer (5.1.5) - actionpack (= 5.1.5) - actionview (= 5.1.5) - activejob (= 5.1.5) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.1.5) - actionview (= 5.1.5) - activesupport (= 5.1.5) - rack (~> 2.0) + actionpack (5.2.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.1.5) - activesupport (= 5.1.5) + actionview (5.2.4.3) + activesupport (= 5.2.4.3) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.1.5) - activesupport (= 5.1.5) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) globalid (>= 0.3.6) - activemodel (5.1.5) - activesupport (= 5.1.5) - activerecord (5.1.5) - activemodel (= 5.1.5) - activesupport (= 5.1.5) - arel (~> 8.0) - activesupport (5.1.5) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.3) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (~> 0.7) + i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) - arel (8.0.0) + arel (9.0.0) autoprefixer-rails (9.8.4) execjs bcrypt (3.1.13) @@ -51,6 +55,14 @@ GEM sassc (>= 2.0.0) builder (3.2.4) byebug (11.1.3) + capybara (3.33.0) + addressable + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.5) + xpath (~> 3.2) carrierwave (2.1.0) activemodel (>= 5.0.0) activesupport (>= 5.0.0) @@ -63,14 +75,20 @@ GEM railties (>= 3.0) sassc-rails (>= 2.1.2) coderay (1.1.3) - coffee-rails (4.2.2) + coffee-rails (5.0.0) coffee-script (>= 2.2.0) - railties (>= 4.0.0) + railties (>= 5.2.0) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.12.2) concurrent-ruby (1.1.6) + coveralls (0.8.23) + json (>= 1.8, < 3) + simplecov (~> 0.16.1) + term-ansicolor (~> 1.3) + thor (>= 0.19.4, < 2.0) + tins (~> 1.6) crass (1.0.6) debug_inspector (0.0.3) devise (4.7.2) @@ -79,12 +97,19 @@ GEM railties (>= 4.1.0) responders warden (~> 1.2.3) + diff-lcs (1.4.2) + docile (1.3.2) erubi (1.9.0) execjs (2.7.0) + factory_bot (6.0.2) + activesupport (>= 5.0.0) + factory_bot_rails (6.0.0) + factory_bot (~> 6.0.0) + railties (>= 5.0.0) ffi (1.13.1) globalid (0.4.2) activesupport (>= 4.2.0) - i18n (0.9.5) + i18n (1.8.3) concurrent-ruby (~> 1.0) image_processing (1.11.0) mini_magick (>= 4.9.5, < 5) @@ -95,6 +120,7 @@ GEM rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) + json (2.3.0) loofah (2.2.3) crass (~> 1.0.2) nokogiri (>= 1.5.9) @@ -103,6 +129,8 @@ GEM mailboxer (0.15.1) carrierwave (>= 0.5.8) rails (>= 5.0.0) + marcel (0.3.3) + mimemagic (~> 0.3.2) method_source (1.0.0) mimemagic (0.3.5) mini_magick (4.10.1) @@ -125,17 +153,18 @@ GEM rack (2.2.3) rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.1.5) - actioncable (= 5.1.5) - actionmailer (= 5.1.5) - actionpack (= 5.1.5) - actionview (= 5.1.5) - activejob (= 5.1.5) - activemodel (= 5.1.5) - activerecord (= 5.1.5) - activesupport (= 5.1.5) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) bundler (>= 1.3.0) - railties (= 5.1.5) + railties (= 5.2.4.3) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) @@ -147,19 +176,37 @@ GEM rails_stdout_logging rails_serve_static_assets (0.0.5) rails_stdout_logging (0.0.5) - railties (5.1.5) - actionpack (= 5.1.5) - activesupport (= 5.1.5) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) method_source rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) + thor (>= 0.19.0, < 2.0) rake (11.3.0) rb-fsevent (0.10.4) rb-inotify (0.10.1) ffi (~> 1.0) + regexp_parser (1.7.1) responders (3.0.1) actionpack (>= 5.0) railties (>= 5.0) + rspec-core (3.9.2) + rspec-support (~> 3.9.3) + rspec-expectations (3.9.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-mocks (3.9.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-rails (4.0.1) + actionpack (>= 4.2) + activesupport (>= 4.2) + railties (>= 4.2) + rspec-core (~> 3.9) + rspec-expectations (~> 3.9) + rspec-mocks (~> 3.9) + rspec-support (~> 3.9) + rspec-support (3.9.3) ruby-vips (2.0.17) ffi (~> 1.9) sass (3.7.4) @@ -167,8 +214,8 @@ GEM sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (5.0.7) - railties (>= 4.0.0, < 6) + sass-rails (5.1.0) + railties (>= 5.2.0) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) @@ -181,6 +228,13 @@ GEM sprockets (> 3.0) sprockets-rails tilt + shoulda-matchers (4.3.0) + activesupport (>= 4.2.0) + simplecov (0.16.1) + docile (~> 1.1) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.2) spring (2.1.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) @@ -189,9 +243,14 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) + sync (0.5.0) + term-ansicolor (1.7.1) + tins (~> 1.0) thor (1.0.1) thread_safe (0.3.6) tilt (2.0.10) + tins (1.25.0) + sync turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) @@ -206,17 +265,22 @@ GEM binding_of_caller (>= 0.7.2) railties (>= 4.0) sprockets-rails (>= 2.0, < 4.0) - websocket-driver (0.6.5) + websocket-driver (0.7.2) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) PLATFORMS ruby DEPENDENCIES bootstrap-sass + capybara chosen-rails + coveralls devise + factory_bot_rails jbuilder (~> 2.0) jquery-rails loofah (~> 2.2.1) @@ -224,11 +288,12 @@ DEPENDENCIES pg (~> 0.15) pry-byebug puma (~> 3.7) - rails (= 5.1.5) rails-html-sanitizer (~> 1.0.4) rails_12factor rake (~> 11.1, >= 11.1.2) + rspec-rails sass-rails (~> 5.0) + shoulda-matchers spring sprockets (~> 3.7.2) turbolinks @@ -236,7 +301,7 @@ DEPENDENCIES web-console (~> 2.0) RUBY VERSION - ruby 2.6.3p62 + ruby 2.5.1p57 BUNDLED WITH - 1.17.3 + 2.1.4 diff --git a/README.md b/README.md index 3837735..355e8f5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ ## CA Mailboxer 2018 -Code base for week 5 challenge - Working with legacy code +Code base for week 5 challenge - Working with legacy code... +... \ No newline at end of file diff --git a/admin@admin.com b/admin@admin.com new file mode 100644 index 0000000..e69de29 diff --git a/app/controllers/recipients_controller.rb b/app/controllers/recipients_controller.rb new file mode 100644 index 0000000..a516921 --- /dev/null +++ b/app/controllers/recipients_controller.rb @@ -0,0 +1,5 @@ +class RecipientsController < ApplicationController + def index + @recipient = Recipient.all + end +end diff --git a/app/helpers/mailbox_helper.rb b/app/helpers/mailbox_helper.rb index 6dedc7e..8a402ca 100644 --- a/app/helpers/mailbox_helper.rb +++ b/app/helpers/mailbox_helper.rb @@ -1,6 +1,6 @@ module MailboxHelper - def unread_messages_count - # how to get the number of unread messages for the current user + def unread_s_count + # how to get the number of unread s for the current user # using mailboxer mailbox.inbox(unread: true).count end diff --git a/app/models/recipient.rb b/app/models/recipient.rb new file mode 100644 index 0000000..cf2634e --- /dev/null +++ b/app/models/recipient.rb @@ -0,0 +1,3 @@ +class Recipient < ApplicationRecord + validates_presence_of :name +end diff --git a/app/views/recipients/index.html.erb b/app/views/recipients/index.html.erb new file mode 100644 index 0000000..73c2093 --- /dev/null +++ b/app/views/recipients/index.html.erb @@ -0,0 +1,2 @@ +
Find me in app/views/recipients/index.html.erb
diff --git a/config/application.rb b/config/application.rb index 66d7296..674fb06 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,7 +1,6 @@ require File.expand_path('../boot', __FILE__) require "rails" -# Pick the frameworks you want: require "active_model/railtie" require "active_job/railtie" require "active_record/railtie" @@ -9,25 +8,12 @@ require "action_mailer/railtie" require "action_view/railtie" require "sprockets/railtie" -# require "rails/test_unit/railtie" -# Require the gems listed in Gemfile, including any gems -# you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module Mailboxer class Application < Rails::Application - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. - # config.time_zone = 'Central Time (US & Canada)' - - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - # config.i18n.default_locale = :de config.action_mailer.default_url_options = { host: 'ca-mailboxer.herokuapp.com' } @@ -36,6 +22,9 @@ class Application < Rails::Application generate.assets false generate.view_specs false generate.test_framework :rspec + generate.helper_specs false + generate.routing_specs false + generate.controller_specs false end end end diff --git a/config/routes.rb b/config/routes.rb index 1abf899..939541b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,6 @@ Rails.application.routes.draw do + get 'recipients/index' devise_for :users get 'welcome/index' diff --git a/coverage/.last_run.json b/coverage/.last_run.json new file mode 100644 index 0000000..6589a0e --- /dev/null +++ b/coverage/.last_run.json @@ -0,0 +1,5 @@ +{ + "result": { + "covered_percent": 33.71 + } +} diff --git a/coverage/.resultset.json b/coverage/.resultset.json new file mode 100644 index 0000000..4ec2c6f --- /dev/null +++ b/coverage/.resultset.json @@ -0,0 +1,179 @@ +{ + "RSpec": { + "coverage": { + "/Users/Viktor/CraftAcademy/legacy_code_june_2020/app/models/user.rb": [ + 1, + null, + null, + 1, + null, + null, + 1, + 1, + 1, + null, + 1, + null, + 1, + 0, + null, + null, + 1, + 0, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ], + "/Users/Viktor/CraftAcademy/legacy_code_june_2020/app/models/application_record.rb": [ + 1, + 1, + null + ], + "/Users/Viktor/CraftAcademy/legacy_code_june_2020/app/helpers/application_helper.rb": [ + 1, + 1, + 1, + 1, + 0, + 0, + 0, + null, + null, + 1, + 0, + null, + null + ], + "/Users/Viktor/CraftAcademy/legacy_code_june_2020/app/helpers/mailbox_helper.rb": [ + 1, + 1, + null, + null, + 0, + null, + null + ], + "/Users/Viktor/CraftAcademy/legacy_code_june_2020/app/controllers/welcome_controller.rb": [ + 1, + 1, + null, + null + ], + "/Users/Viktor/CraftAcademy/legacy_code_june_2020/app/controllers/application_controller.rb": [ + 1, + 1, + null, + 1, + null, + 1, + null, + 1, + null, + 1, + 0, + null, + null, + 1, + 0, + null, + null, + 1, + null, + 1, + 4, + 4, + null, + null + ], + "/Users/Viktor/CraftAcademy/legacy_code_june_2020/app/controllers/mailbox_controller.rb": [ + 0, + 0, + null, + 0, + 0, + 0, + 0, + null, + 0, + 0, + 0, + 0, + null, + 0, + 0, + 0, + 0, + 0 + ], +<<<<<<< HEAD + "/Users/simaboreiri/boot_camp/legacy_code_june_2020/app/controllers/conversations_controller.rb": [ +======= + "/Users/Viktor/CraftAcademy/legacy_code_june_2020/app/controllers/conversations_controller.rb": [ +>>>>>>> 55c2f82e8aa26a4e525d709eaa792f81a930a5fc + 0, + 0, + null, + 0, + 0, + null, + 0, + 0, + 0, + 0, + 0, + 0, + null, + 0, + 0, +<<<<<<< HEAD +======= + null, +>>>>>>> 55c2f82e8aa26a4e525d709eaa792f81a930a5fc + 0, + 0, + null, + 0, + 0, + 0, + 0, + 0, + null, + 0, + 0, + 0, + 0, + null, + 0, + 0, + 0, + 0, + null, + 0, + null, + 0, + 0, + 0, + null, + 0, + 0, + 0, + null, + 0 + ] + }, +<<<<<<< HEAD + "timestamp": 1593090312 +======= + "timestamp": 1593086556 +>>>>>>> 55c2f82e8aa26a4e525d709eaa792f81a930a5fc + } +} diff --git a/coverage/.resultset.json.lock b/coverage/.resultset.json.lock new file mode 100644 index 0000000..e69de29 diff --git a/db/migrate/20200625153035_create_recipients.rb b/db/migrate/20200625153035_create_recipients.rb new file mode 100644 index 0000000..a7a3116 --- /dev/null +++ b/db/migrate/20200625153035_create_recipients.rb @@ -0,0 +1,9 @@ +class CreateRecipients < ActiveRecord::Migration[5.2] + def change + create_table :recipients do |t| + t.string :name + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 22fce58..4195b59 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160322134147) do +ActiveRecord::Schema.define(version: 2020_06_25_153035) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -65,6 +65,12 @@ t.index ["receiver_id", "receiver_type"], name: "index_mailboxer_receipts_on_receiver_id_and_receiver_type" end + create_table "recipients", force: :cascade do |t| + t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "users", id: :serial, force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false diff --git a/lib/tasks/ci.rake b/lib/tasks/ci.rake new file mode 100644 index 0000000..4e716d6 --- /dev/null +++ b/lib/tasks/ci.rake @@ -0,0 +1,9 @@ +unless Rails.env.production? + require 'rspec/core/rake_task' + require 'coveralls/rake/task' + Coveralls::RakeTask.new + namespace :ci do + desc 'Run all tests and generate a merged coverage report' + task tests: [:spec, 'coveralls:push'] + end +end \ No newline at end of file diff --git a/password b/password new file mode 100644 index 0000000..e69de29 diff --git a/spec/factories/recipients.rb b/spec/factories/recipients.rb new file mode 100644 index 0000000..8608a7f --- /dev/null +++ b/spec/factories/recipients.rb @@ -0,0 +1,5 @@ +FactoryBot.define do + factory :recipient do + name { 'Name'} + end +end \ No newline at end of file diff --git a/spec/factories/user.rb b/spec/factories/user.rb new file mode 100644 index 0000000..7592e7e --- /dev/null +++ b/spec/factories/user.rb @@ -0,0 +1,7 @@ +FactoryBot.define do + factory :user do + email {'user@mail.com'} + password { 'password'} + name { 'Name'} + end +end \ No newline at end of file diff --git a/spec/feature/sending_message_spec.rb b/spec/feature/sending_message_spec.rb new file mode 100644 index 0000000..da10d25 --- /dev/null +++ b/spec/feature/sending_message_spec.rb @@ -0,0 +1,24 @@ +require "rails_helper" + +feature 'User can send a message' do + context 'Compose a message' + before do + create(:user, email: 'user@mail.com', password: '12345678', name: "Simon") + visit root_path + click_on 'Login' + fill_in "Email", :with => "user@mail.com" + fill_in "Password", :with => "12345678" + click_on "Log in" + click_on "Inbox" + click_on "Compose" + #create(:user, name: 'Simon') + select "Simon", :from => "Recipients" + fill_in "Subject", :with => "Test" + fill_in "Message", :with => "This is a test message." + click_on "Send Message" + end + + it 'user can send a message' do + expect(page).to have_content 'Your message was successfully sent!' + end +end \ No newline at end of file diff --git a/spec/feature/user_can_log_in_feature_spec.rb b/spec/feature/user_can_log_in_feature_spec.rb new file mode 100644 index 0000000..d424f76 --- /dev/null +++ b/spec/feature/user_can_log_in_feature_spec.rb @@ -0,0 +1,28 @@ +require "rails_helper" + +feature 'User can log in' do + context 'Sign in to account' + before do + create(:user, email: 'user@mail.com', password: '1234') + visit user_session_path +end + +it 'displays a log in button' do + expect(page).to have_content 'Login' + click_on 'Login' +end + +it 'displays a email form' do + expect(page).to have_content 'Email' +end + +it 'fills in email and password' do + fill_in "Email", :with => "admin@admin.com" + fill_in "Password", :with => "password" + click_on "Log in" +end + + +end + + diff --git a/spec/feature/user_can_log_out_spec.rb b/spec/feature/user_can_log_out_spec.rb new file mode 100644 index 0000000..e7d4fc0 --- /dev/null +++ b/spec/feature/user_can_log_out_spec.rb @@ -0,0 +1,16 @@ +require "rails_helper" + +feature 'User can log out' do + context 'Sign out of account' do + let(:user) { create(:user, name: 'Peter', password: '23456789', email: 'abc@mail.com') } + before do + login_as(user, scope: :user) + visit root_path + click_on 'Logout' + end + + it 'Displays a successful signout message' do + expect(page).to have_content 'Signed out successfully.' + end +end +end \ No newline at end of file diff --git a/spec/models/recipient_spec.rb b/spec/models/recipient_spec.rb new file mode 100644 index 0000000..3fc1d1a --- /dev/null +++ b/spec/models/recipient_spec.rb @@ -0,0 +1,16 @@ + +RSpec.describe Recipient, type: :model do + describe 'db table' do + it {is_expected.to have_db_column :name} + end + + describe 'validations' do + it {is_expected.to validate_presence_of :name} + end + + describe 'Factory' do + it 'should have valid factory' do + expect(FactoryBot.create(:recipient)).to be_valid + end + end +end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb new file mode 100644 index 0000000..7468523 --- /dev/null +++ b/spec/models/user_spec.rb @@ -0,0 +1,20 @@ +require 'rails_helper' + +RSpec.describe User, type: :model do + describe 'db table' do + it {is_expected.to have_db_column :email} + it {is_expected.to have_db_column :encrypted_password} + it {is_expected.to have_db_column :name} + end + + describe 'validations' do + it {is_expected.to validate_presence_of :email} + it {is_expected.to validate_presence_of :password} + end + + describe 'Factory' do + it 'should have valid factory' do + expect(FactoryBot.create(:user)).to be_valid + end + end +end \ No newline at end of file diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 0000000..a3980bf --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,27 @@ +require 'spec_helper' +ENV['RAILS_ENV'] ||= 'test' +require File.expand_path('../config/environment', __dir__) + +abort("The Rails environment is running in production mode!") if Rails.env.production? +require 'rspec/rails' +begin + ActiveRecord::Migration.maintain_test_schema! +rescue ActiveRecord::PendingMigrationError => e + puts e.to_s.strip + exit 1 +end +RSpec.configure do |config| + config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.use_transactional_fixtures = true + config.infer_spec_type_from_file_location! + config.filter_rails_from_backtrace! + config.include FactoryBot::Syntax::Methods + config.include Warden::Test::Helpers + + Shoulda::Matchers.configure do |config| + config.integrate do |with| + with.test_framework :rspec + with.library :rails + end +end +end diff --git a/spec/requests/recipients_request_spec.rb b/spec/requests/recipients_request_spec.rb new file mode 100644 index 0000000..4d3f27b --- /dev/null +++ b/spec/requests/recipients_request_spec.rb @@ -0,0 +1,12 @@ +require 'rails_helper' + +RSpec.describe "Recipients", type: :request do + + describe "GET /index" do + it "returns http success" do + get "/recipients/index" + expect(response).to have_http_status(:success) + end + end + +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..3cd93ed --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,16 @@ + +RSpec.configure do |config| + + config.expect_with :rspec do |expectations| + + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + config.mock_with :rspec do |mocks| + + mocks.verify_partial_doubles = true + end + + config.shared_context_metadata_behavior = :apply_to_host_groups + +end diff --git a/spec/user_can_log_in_spec.rb b/spec/user_can_log_in_spec.rb new file mode 100644 index 0000000..649fb62 --- /dev/null +++ b/spec/user_can_log_in_spec.rb @@ -0,0 +1,15 @@ +require "rails_helper" + +feature 'User can log in' do + context 'Sign in to account' + before do + visit root_path +end + +it 'displays a log in button' do + expect(page).to have_content 'Login' + click_on 'Login' +end +end + +