Commit 7ea39df9 authored by Rémy Coutable's avatar Rémy Coutable

Improve specs by defining anonymous instead of named classes

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 56a7cabe
...@@ -4,7 +4,8 @@ require 'spec_helper' ...@@ -4,7 +4,8 @@ require 'spec_helper'
describe SafeUrl do describe SafeUrl do
describe '#safe_url' do describe '#safe_url' do
class SafeUrlTestClass let(:safe_url_test_class) do
Class.new do
include SafeUrl include SafeUrl
attr_reader :url attr_reader :url
...@@ -13,8 +14,9 @@ describe SafeUrl do ...@@ -13,8 +14,9 @@ describe SafeUrl do
@url = url @url = url
end end
end end
end
let(:test_class) { SafeUrlTestClass.new(url) } let(:test_class) { safe_url_test_class.new(url) }
let(:url) { 'http://example.com' } let(:url) { 'http://example.com' }
subject { test_class.safe_url } subject { test_class.safe_url }
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
require 'spec_helper' require 'spec_helper'
describe QualifiedDomainArrayValidator do describe QualifiedDomainArrayValidator do
class QualifiedDomainArrayValidatorTestClass let(:qualified_domain_array_validator_test_class) do
Class.new do
include ActiveModel::Validations include ActiveModel::Validations
attr_accessor :domain_array attr_accessor :domain_array
...@@ -12,9 +13,9 @@ describe QualifiedDomainArrayValidator do ...@@ -12,9 +13,9 @@ describe QualifiedDomainArrayValidator do
self.domain_array = domain_array self.domain_array = domain_array
end end
end end
end
let!(:record) do let!(:record) do
QualifiedDomainArrayValidatorTestClass.new(['gitlab.com']) qualified_domain_array_validator_test_class.new(['gitlab.com'])
end end
subject { validator.validate(record) } subject { validator.validate(record) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment