Apply single quote convention in Ruby code

This commit is contained in:
riggraz
2019-08-24 20:04:53 +02:00
parent 0f74fc2b88
commit 87c205ca60
17 changed files with 60 additions and 56 deletions

View File

@@ -1,6 +1,6 @@
FactoryBot.define do
factory :board do
sequence(:name) { |n| "Board#{n}" }
description { "My fantastic board" }
description { 'My fantastic board' }
end
end

View File

@@ -1,6 +1,6 @@
FactoryBot.define do
factory :post_status do
sequence(:name) { |n| "Post Status #{n}" }
color { "#ffffff" }
color { '#ffffff' }
end
end

View File

@@ -1,7 +1,7 @@
FactoryBot.define do
factory :post do
title { "Post Title" }
description { "Post Description" }
title { 'Post Title' }
description { 'Post Description' }
board
user
post_status

View File

@@ -2,23 +2,23 @@ FactoryBot.define do
factory :user do
sequence(:email) { |n| "user#{n}@example.com" }
full_name { "First Last" }
password { "password" }
full_name { 'First Last' }
password { 'password' }
end
factory :moderator, class: User do
sequence(:email) { |n| "mod#{n}@example.com" }
full_name { "First Last" }
password { "password" }
role { "moderator" }
full_name { 'First Last' }
password { 'password' }
role { 'moderator' }
end
factory :admin, class: User do
sequence(:email) { |n| "admin#{n}@example.com" }
full_name { "First Last" }
password { "password" }
role { "admin" }
full_name { 'First Last' }
password { 'password' }
role { 'admin' }
end
end

View File

@@ -9,7 +9,7 @@ RSpec.describe Board, type: :model do
it 'has a non-nil and non-empty name' do
nil_name_board = FactoryBot.build(:board, name: nil)
empty_name_board = FactoryBot.build(:board, name: "")
empty_name_board = FactoryBot.build(:board, name: '')
expect(nil_name_board).to be_invalid
expect(empty_name_board).to be_invalid
@@ -24,7 +24,7 @@ RSpec.describe Board, type: :model do
it 'has a description that can be nil or empty' do
nil_description_board = FactoryBot.build(:board, description: nil)
empty_description_board = FactoryBot.build(:board, description: "")
empty_description_board = FactoryBot.build(:board, description: '')
expect(nil_description_board).to be_valid
expect(empty_description_board).to be_valid

View File

@@ -9,17 +9,17 @@ RSpec.describe Post, type: :model do
it 'has a non-nil and non-empty title' do
nil_post = FactoryBot.build(:post, title: nil)
empty_post = FactoryBot.build(:post, title: "")
empty_post = FactoryBot.build(:post, title: '')
expect(nil_post).to be_invalid
expect(empty_post).to be_invalid
end
it 'has a title between 4 and 64 characters' do
too_short_post = FactoryBot.build(:post, title: "a" * 3)
short_post = FactoryBot.build(:post, title: "a" * 4)
long_post = FactoryBot.build(:post, title: "a" * 64)
too_long_post = FactoryBot.build(:post, title: "a" * 65)
too_short_post = FactoryBot.build(:post, title: 'a' * 3)
short_post = FactoryBot.build(:post, title: 'a' * 4)
long_post = FactoryBot.build(:post, title: 'a' * 64)
too_long_post = FactoryBot.build(:post, title: 'a' * 65)
expect(too_short_post).to be_invalid
expect(short_post).to be_valid
@@ -29,7 +29,7 @@ RSpec.describe Post, type: :model do
it 'has a description that can be nil or empty' do
nil_description_post = FactoryBot.build(:post, description: nil)
empty_description_post = FactoryBot.build(:post, description: "")
empty_description_post = FactoryBot.build(:post, description: '')
expect(nil_description_post).to be_valid
expect(empty_description_post).to be_valid

View File

@@ -8,7 +8,7 @@ RSpec.describe PostStatus, type: :model do
end
it 'must have a name' do
empty_name = FactoryBot.build(:post_status, name: "")
empty_name = FactoryBot.build(:post_status, name: '')
nil_name = FactoryBot.build(:post_status, name: nil)
expect(empty_name).to be_invalid
@@ -23,11 +23,11 @@ RSpec.describe PostStatus, type: :model do
it 'has a valid hex color' do
nil_color = FactoryBot.build(:post_status, color: nil)
empty_color = FactoryBot.build(:post_status, color: "")
invalid_color = FactoryBot.build(:post_status, color: "ffffff")
invalid_color2 = FactoryBot.build(:post_status, color: "#ffff")
valid_color = FactoryBot.build(:post_status, color: "#fff")
valid_color2 = FactoryBot.build(:post_status, color: "#ffffff")
empty_color = FactoryBot.build(:post_status, color: '')
invalid_color = FactoryBot.build(:post_status, color: 'ffffff')
invalid_color2 = FactoryBot.build(:post_status, color: '#ffff')
valid_color = FactoryBot.build(:post_status, color: '#fff')
valid_color2 = FactoryBot.build(:post_status, color: '#ffffff')
expect(nil_color).to be_invalid
expect(empty_color).to be_invalid

View File

@@ -8,7 +8,7 @@ RSpec.describe User, type: :model do
end
it 'creates a user with role "user" by default' do
expect(User.new.role).to eq("user")
expect(User.new.role).to eq('user')
end
it 'can have the following roles: "user", "moderator" and "admin"' do
@@ -16,9 +16,9 @@ RSpec.describe User, type: :model do
moderator = FactoryBot.build(:moderator)
admin = FactoryBot.build(:admin)
expect(user.role).to eq("user")
expect(moderator.role).to eq("moderator")
expect(admin.role).to eq("admin")
expect(user.role).to eq('user')
expect(moderator.role).to eq('moderator')
expect(admin.role).to eq('admin')
expect(user).to be_valid
expect(moderator).to be_valid
@@ -27,17 +27,17 @@ RSpec.describe User, type: :model do
it 'has a non-nil and non-empty full name' do
nil_name_user = FactoryBot.build(:user, full_name: nil)
empty_name_user = FactoryBot.build(:user, full_name: "")
empty_name_user = FactoryBot.build(:user, full_name: '')
expect(nil_name_user).to be_invalid
expect(empty_name_user).to be_invalid
end
it 'has a full name between 2 and 32 characters' do
too_short_user = FactoryBot.build(:user, full_name: "a" * 1)
short_user = FactoryBot.build(:user, full_name: "a" * 2)
long_user = FactoryBot.build(:user, full_name: "a" * 32)
too_long_user = FactoryBot.build(:user, full_name: "a" * 33)
too_short_user = FactoryBot.build(:user, full_name: 'a' * 1)
short_user = FactoryBot.build(:user, full_name: 'a' * 2)
long_user = FactoryBot.build(:user, full_name: 'a' * 32)
too_long_user = FactoryBot.build(:user, full_name: 'a' * 33)
expect(too_short_user).to be_invalid
expect(short_user).to be_valid
@@ -46,7 +46,7 @@ RSpec.describe User, type: :model do
end
it 'has an email that must contain a @' do
invalid_email_user = FactoryBot.build(:user, email: "invalid.email")
invalid_email_user = FactoryBot.build(:user, email: 'invalid.email')
expect(invalid_email_user).to be_invalid
end