Skip to content

Commit

Permalink
Add webmock and shoulda
Browse files Browse the repository at this point in the history
  • Loading branch information
MaicolBen committed Feb 23, 2017
1 parent 758876f commit f5363cf
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ GEM
adamantium (~> 0.2.0)
equalizer (~> 0.0.9)
concurrent-ruby (1.0.2)
crack (0.4.3)
safe_yaml (~> 1.0.0)
database_cleaner (1.4.1)
debug_inspector (0.0.2)
delayed_job (4.1.2)
Expand Down Expand Up @@ -177,6 +179,7 @@ GEM
has_scope (0.7.0)
actionpack (>= 4.1, < 5.1)
activesupport (>= 4.1, < 5.1)
hashdiff (0.3.2)
i18n (0.7.0)
ice_nine (0.11.2)
ipaddress (0.8.3)
Expand Down Expand Up @@ -325,6 +328,7 @@ GEM
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4)
ruby-progressbar (1.7.1)
safe_yaml (1.0.4)
sass (3.4.22)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
Expand All @@ -335,6 +339,8 @@ GEM
sendgrid (1.2.4)
json
sexp_processor (4.4.5)
shoulda-matchers (3.1.1)
activesupport (>= 4.0.0)
slop (3.6.0)
spring (2.0.0)
activesupport (>= 4.2)
Expand Down Expand Up @@ -366,6 +372,10 @@ GEM
procto (~> 0.0.2)
warden (1.2.6)
rack (>= 1.0)
webmock (2.3.2)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
websocket-driver (0.6.4)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
Expand Down Expand Up @@ -408,10 +418,12 @@ DEPENDENCIES
rspec-rails (~> 3.5.2)
rubocop (~> 0.32.1)
sendgrid (~> 1.2.4)
shoulda-matchers (~> 3.1.1)
spring
spring-watcher-listen (~> 2.0.0)
tzinfo-data
uglifier (~> 2.7.2)
webmock (~> 2.3.2)

RUBY VERSION
ruby 2.3.1p112
Expand Down
2 changes: 2 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class User < ApplicationRecord
:recoverable, :rememberable, :trackable, :validatable
include DeviseTokenAuth::Concerns::User

validates :email, uniqueness: true

def full_name
return username unless first_name.present?
"#{first_name} #{last_name}"
Expand Down
5 changes: 5 additions & 0 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
require 'rails_helper'

describe User do
describe 'validations' do
it { should validate_presence_of(:email) }
it { should validate_uniqueness_of(:email).case_insensitive }
end

context 'when was created with regular login' do
let!(:user) { create(:user) }
let(:full_name) { user.full_name }
Expand Down
7 changes: 7 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@
config.use_transactional_fixtures = true
config.infer_spec_type_from_file_location!
end

Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
with.library :rails
end
end
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

require 'factory_girl_rails'
require 'helpers'
require 'webmock/rspec'
require 'shoulda/matchers'

FactoryGirl.factories.clear
FactoryGirl.reload
Expand Down

0 comments on commit f5363cf

Please sign in to comment.