This repository has been archived by the owner on Mar 14, 2023. It is now read-only.
forked from zeroc0d3/ruby-deploy-gcc
-
Notifications
You must be signed in to change notification settings - Fork 0
Test Unit
ZeroC0D3 Team edited this page Jan 9, 2018
·
1 revision
- Initialize
rspec
rspec --init
-
Define rspec helper in
spec/spec_helper.rb
folder -
Create test unit for models
RSpec.describe [ClassModel], :type => :model do
context "associations" do
it { should belong_to(:field) }
it { should have_many(:fields) }
end
context "validations" do
should validate_presence_of(:field_name)
end
context "#field_name" do
should "Consist of field_name" do
class_model = ClassModel.new([field]: [value])
assert_equal [value], class_model.[field]
end
end
end
Example:
RSpec.describe Device, :type => :model do
context "associations" do
it { should belong_to(:device_profile) }
it { should have_many(:group_members) }
it { should have_many(:device_groups) }
end
context "validations" do
should validate_presence_of(:name)
should validate_presence_of(:serial)
should validate_presence_of(:resolution)
should validate_presence_of(:device_profile_id)
end
context "#name" do
should "Consist of name device" do
device = Device.new(name: "Pilot 00001")
assert_equal "Pilot 00001", device.name
end
end
context "#serial" do
should "Consist of serial device" do
device = Device.new(serial: "353110080105281")
assert_equal "353110080105281", device.serial
end
end
context "#resolution" do
should "Consist of resolution device" do
device = Device.new(resolution: "1900x1200")
assert_equal "1900x1200", device.resolution
end
end
context "#device_profile_id" do
should "Consist of profile_id device" do
device = Device.new(device_profile_id: 1)
assert_equal 1, device.device_profile_id
end
end
end
Research & Development (RnD) - ZeroC0D3 Team
- Email: [email protected]
- Repository: https://github.com/zeroc0d3lab
- Install-Packages
- Setup-Server
- Setup-Account
- Configuration-Bash
- Configuration-Zsh
- Install-Bash-Theme
- Install-Zsh-Theme
- Install-Docker
- Install-Memcached
- Install-MongoDB
- Install-MySQL
- Install-NodeJS
- Install-PostgreSQL
- Install-Redis
- Install-Ruby
- Install-SQLite3
- Configuration-App
- Configuration-GCM
- Configuration-Hosts
- Configuration-Memcached
- Configuration-MongoDB
- Configuration-PostgreSQL
- Configuration-Puma
- Configuration-Swap
- Configuration-Unicorn
- Nginx-Puma
- Nginx-Unicorn
- Logrotate
- Deployment-Dashboard
- Deployment-Configuration
- Deployment-Process
- Deployment-Folder-Structure
- Deploy-Preinstall