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,17 +4,19 @@ require 'spec_helper'
describe SafeUrl do
describe '#safe_url' do
class SafeUrlTestClass
include SafeUrl
let(:safe_url_test_class) do
Class.new do
include SafeUrl
attr_reader :url
attr_reader :url
def initialize(url)
@url = url
def initialize(url)
@url = url
end
end
end
let(:test_class) { SafeUrlTestClass.new(url) }
let(:test_class) { safe_url_test_class.new(url) }
let(:url) { 'http://example.com' }
subject { test_class.safe_url }
......
......@@ -3,18 +3,19 @@
require 'spec_helper'
describe QualifiedDomainArrayValidator do
class QualifiedDomainArrayValidatorTestClass
include ActiveModel::Validations
let(:qualified_domain_array_validator_test_class) do
Class.new do
include ActiveModel::Validations
attr_accessor :domain_array
attr_accessor :domain_array
def initialize(domain_array)
self.domain_array = domain_array
def initialize(domain_array)
self.domain_array = domain_array
end
end
end
let!(:record) do
QualifiedDomainArrayValidatorTestClass.new(['gitlab.com'])
qualified_domain_array_validator_test_class.new(['gitlab.com'])
end
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