spec/parser_spec.rb in rack-http-accept-language-0.1.0 vs spec/parser_spec.rb in rack-http-accept-language-0.1.1
- old
+ new
@@ -1,13 +1,14 @@
# frozen_string_literal: true
require 'spec_helper'
describe RackHttpAcceptLanguage::Parser do
context 'without wildcard' do
+ subject(:parser) { described_class.new(http_accept_language) }
+
context 'no upcase handling necessary' do
let(:http_accept_language) { 'en-US,en-GB;q=0.6,en;q=0.8' }
- subject(:parser) { described_class.new(http_accept_language) }
it 'preferred language' do
expected_array = 'en-US'
expect(parser.preferred_language).to eq expected_array
end
@@ -18,17 +19,25 @@
end
end
context 'upcase necessary' do
let(:http_accept_language) { 'en-us,en-GB;q=0.6,en;q=0.8' }
- subject(:parser) { described_class.new(http_accept_language) }
it 'preferred language' do
expected_array = 'en-US'
expect(parser.preferred_language).to eq expected_array
end
it 'preferred_languages' do
+ expected_array = ['en-US', 'en', 'en-GB']
+ expect(parser.preferred_languages).to eq expected_array
+ end
+ end
+
+ context 'with spaces' do
+ let(:http_accept_language) { 'en-US, en-GB;q=0.6, en;q=0.8' }
+
+ it 'strips unneccessary spaces' do
expected_array = ['en-US', 'en', 'en-GB']
expect(parser.preferred_languages).to eq expected_array
end
end
end