Skip to content

Instantly share code, notes, and snippets.

View agungsetiawan's full-sized avatar

Agung Setiawan agungsetiawan

View GitHub Profile
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)
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)
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
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
require 'rails_helper'
RSpec.describe User, type: :model do
describe '#priority_user?' do
end
end
require 'rails_helper'
RSpec.describe User, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
class CreateUsers < ActiveRecord::Migration[6.0]
def change
create_table :users do |t|
t.string :name
t.string :email
t.timestamps
end
end
end
class User < ApplicationRecord
has_one :account
PRIORITY_USER_MINIMUM_BALANCE = 100_000
def priority_user?
account.balance > PRIORITY_USER_MINIMUM_BALANCE
end
end
RSpec.configure do |config|
#other configurations ommitted for brevity
config.include FactoryBot::Syntax::Methods
end
group :development, :test do
gem 'rspec-rails', '~> 3.9'
gem 'factory_bot_rails'
end