Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 51 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
_site
.sass-cache
# Ruby specific
*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/spec/examples.txt
/test/tmp/
/test/version_tmp/
/tmp/

# Bundler specific
Gemfile.lock
.bundle/
vendor/bundle

# Jekyll specific
_site/
.sass-cache/
.jekyll-metadata
.jekyll-cache/

# Dependency directories
node_modules/
jspm_packages/

# Environment variables
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor/IDE files
.idea/
.vscode/
*.swp
*.swo
*~

# System files
.DS_Store
Thumbs.db
3 changes: 3 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--color
--format documentation
--require spec_helper
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source "https://rubygems.org"
source 'https://rubygems.org'

gem "github-pages", ">= 25"
gem 'webrick'
gem 'csv'
group :development, :test do
gem 'rspec', '~> 3.12'
end
11 changes: 11 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end

config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end

config.shared_context_metadata_behavior = :apply_to_host_groups
end
12 changes: 12 additions & 0 deletions src/author_validator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class AuthorValidator
MAX_NAME_LENGTH = 100

def self.validate(author)
return false if author.nil? || author.strip.empty?
return false if author.length > MAX_NAME_LENGTH

# Optional: Additional validation rules can be added here
# For example, validate allowed characters, no special rules for now
true
end
end
35 changes: 35 additions & 0 deletions test/author_validator_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require_relative '../src/author_validator'

RSpec.describe AuthorValidator do
describe '.validate' do
context 'when author is valid' do
it 'returns true for a standard name' do
expect(AuthorValidator.validate('John Doe')).to be true
end

it 'returns true for a name at max length' do
long_name = 'a' * 100
expect(AuthorValidator.validate(long_name)).to be true
end
end

context 'when author is invalid' do
it 'returns false for nil author' do
expect(AuthorValidator.validate(nil)).to be false
end

it 'returns false for empty string' do
expect(AuthorValidator.validate(''))).to be false
end

it 'returns false for whitespace-only string' do
expect(AuthorValidator.validate(' ')).to be false
end

it 'returns false for name exceeding max length' do
long_name = 'a' * 101
expect(AuthorValidator.validate(long_name)).to be false
end
end
end
end