diff --git a/lib/detectify/query_builder/base.rb b/lib/detectify/query_builder/base.rb index 466042f..6563ff4 100644 --- a/lib/detectify/query_builder/base.rb +++ b/lib/detectify/query_builder/base.rb @@ -4,8 +4,8 @@ class Base attr_reader :domain, :subdomain def initialize(domain, subdomain) - @domain = domain - @subdomain = subdomain + @domain = domain.downcase if domain.is_a?(String) + @subdomain = subdomain.downcase if subdomain.is_a?(String) end def build diff --git a/spec/detectify/query_builder/base_spec.rb b/spec/detectify/query_builder/base_spec.rb new file mode 100644 index 0000000..de2755f --- /dev/null +++ b/spec/detectify/query_builder/base_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +RSpec.describe Detectify::QueryBuilder::Base do + let(:domain) { 'DOMAIN' } + let(:subdomain) { 'SUBDOMAIN' } + subject { Detectify::QueryBuilder::Base.new(domain, subdomain) } + + describe '#initialize' do + it 'sets domain in downcase' do + expect(subject.domain).to eq(domain.downcase) + end + + it 'sets subdomain in downcase' do + expect(subject.subdomain).to eq(subdomain.downcase) + end + end +end