This file contains hidden or 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 User, type: :model do | |
describe '#priority_user?' do | |
let(:user) { create(:user) } | |
context 'balance more than User::PRIORITY_USER_MINIMUM_BALANCE' do | |
it 'return true' do | |
account = create(:account, balance: 200_000, user: user) |
This file contains hidden or 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 User, type: :model do | |
describe '#priority_user?' do | |
let(:user) { create(:user) } | |
it 'return true if balance more than User::PRIORITY_USER_MINIMUM_BALANCE' do | |
account = create(:account, balance: 200_000, user: user) | |
expect(user.priority_user?).to eq(true) |
This file contains hidden or 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 User, type: :model do | |
describe '#priority_user?' do | |
it 'return true if balance more than User::PRIORITY_USER_MINIMUM_BALANCE' do | |
user = create(:user) | |
account = create(:account, balance: 200_000, user: user) | |
expect(user.priority_user?).to eq(true) | |
end |
This file contains hidden or 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 User, type: :model do | |
describe '#priority_user?' do | |
it 'return true if balance more than User::PRIORITY_USER_MINIMUM_BALANCE' do | |
#test here | |
end | |
it 'return false if balance less than User::PRIORITY_USER_MINIMUM_BALANCE' do | |
#test here |
This file contains hidden or 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 User, type: :model do | |
describe '#priority_user?' do | |
end | |
end |
This file contains hidden or 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 User, type: :model do | |
pending "add some examples to (or delete) #{__FILE__}" | |
end |
This file contains hidden or 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
class CreateUsers < ActiveRecord::Migration[6.0] | |
def change | |
create_table :users do |t| | |
t.string :name | |
t.string :email | |
t.timestamps | |
end | |
end | |
end |
This file contains hidden or 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
class User < ApplicationRecord | |
has_one :account | |
PRIORITY_USER_MINIMUM_BALANCE = 100_000 | |
def priority_user? | |
account.balance > PRIORITY_USER_MINIMUM_BALANCE | |
end | |
end |
This file contains hidden or 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
RSpec.configure do |config| | |
#other configurations ommitted for brevity | |
config.include FactoryBot::Syntax::Methods | |
end |
This file contains hidden or 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
group :development, :test do | |
gem 'rspec-rails', '~> 3.9' | |
gem 'factory_bot_rails' | |
end |