Commit 864398f3 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch '119104-improve-specs' into 'master'

Improve specs by defining anonymous instead of named classes

Closes #119104

See merge request gitlab-org/gitlab!22094
parents 37ca9198 7ea39df9
...@@ -4,17 +4,19 @@ require 'spec_helper' ...@@ -4,17 +4,19 @@ 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
include SafeUrl Class.new do
include SafeUrl
attr_reader :url attr_reader :url
def initialize(url) def initialize(url)
@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,18 +3,19 @@ ...@@ -3,18 +3,19 @@
require 'spec_helper' require 'spec_helper'
describe QualifiedDomainArrayValidator do describe QualifiedDomainArrayValidator do
class QualifiedDomainArrayValidatorTestClass let(:qualified_domain_array_validator_test_class) do
include ActiveModel::Validations Class.new do
include ActiveModel::Validations
attr_accessor :domain_array attr_accessor :domain_array
def initialize(domain_array) def initialize(domain_array)
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