Skip to content

Commit

Permalink
Merge pull request #536 from rootstrap/feature/capybara
Browse files Browse the repository at this point in the history
Add capybara
  • Loading branch information
sebastiancaraballo authored Dec 7, 2023
2 parents b02435f + d651aca commit 3cc011c
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ jobs:
./cc-test-reporter before-build
- name: Setup Database
run: bundle exec rake parallel:load_schema
- name: Run yarn commands
run: |
yarn install
- name: Check for untracked changes in schema.rb
uses: rootstrap/check_untracked_changes@v1
with:
Expand Down
6 changes: 6 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ inherit_mode:
- Exclude

require:
- rubocop-capybara
- rubocop-factory_bot
- rubocop-performance
- rubocop-rails
Expand Down Expand Up @@ -139,3 +140,8 @@ Style/SlicingWithRange:

Style/StringConcatenation:
Enabled: false

RSpec/Capybara/FeatureMethods:
EnabledMethods:
- feature
- scenario
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ group :development do
gem 'rails_best_practices', '~> 1.20'
gem 'reek', '~> 6.1', '>= 6.1.1'
gem 'rubocop', '~> 1.58', require: false
gem 'rubocop-capybara', '~> 2.19'
gem 'rubocop-factory_bot', '~> 2.24', require: false
gem 'rubocop-performance', '~> 1.19', require: false
gem 'rubocop-rails', '~> 2.22', require: false
Expand All @@ -67,6 +68,7 @@ group :development do
end

group :test do
gem 'capybara', '~> 3.39', '>= 3.39.2'
gem 'faker', '~> 3.2'
gem 'faraday-retry', '~> 2.2'
gem 'knapsack', '~> 4.0'
Expand Down
14 changes: 14 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ GEM
brow (0.4.1)
builder (3.2.4)
byebug (11.1.3)
capybara (3.39.2)
addressable
matrix
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
code_analyzer (0.5.5)
sexp_processor
coderay (1.1.3)
Expand Down Expand Up @@ -279,6 +288,7 @@ GEM
net-pop
net-smtp
marcel (1.0.2)
matrix (0.4.2)
method_source (1.0.0)
mini_mime (1.1.5)
mini_portile2 (2.8.5)
Expand Down Expand Up @@ -513,6 +523,8 @@ GEM
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
yaaf (2.2.0)
activemodel (>= 5.2)
activerecord (>= 5.2)
Expand All @@ -530,6 +542,7 @@ DEPENDENCIES
binding_of_caller (~> 1.0)
bootsnap (~> 1.17)
brakeman (~> 6.0)
capybara (~> 3.39, >= 3.39.2)
delayed_job_active_record (~> 4.1)
devise (~> 4.9)
devise_token_auth (~> 1.2.2)
Expand Down Expand Up @@ -570,6 +583,7 @@ DEPENDENCIES
rswag-api (~> 2.13.0)
rswag-ui (~> 2.13.0)
rubocop (~> 1.58)
rubocop-capybara (~> 2.19)
rubocop-factory_bot (~> 2.24)
rubocop-performance (~> 1.19)
rubocop-rails (~> 2.22)
Expand Down
25 changes: 25 additions & 0 deletions spec/features/admin/sign_in_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

RSpec.describe 'Admin SignIn' do
feature 'Signing in' do
let(:admin_user) { create(:admin_user) }

scenario 'Admin signs in successfully' do
visit admin_root_path
fill_in 'Email', with: admin_user.email
fill_in 'Password', with: admin_user.password
click_button 'Login'

expect(page).to have_content 'Signed in successfully.'
end

scenario 'Admin fails to sign in with invalid credentials' do
visit admin_root_path
fill_in 'Email', with: '[email protected]'
fill_in 'Password', with: 'wrongpassword'
click_button 'Login'

expect(page).to have_content 'Invalid Email or password.'
end
end
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
require 'webmock/rspec'
require 'shoulda/matchers'
require 'pundit/rspec'
require 'capybara/rspec'

Knapsack.tracker.config(enable_time_offset_warning: false)
Knapsack::Adapters::RSpecAdapter.bind
Expand Down

0 comments on commit 3cc011c

Please sign in to comment.