spec/clavem/authorizer_spec.rb in clavem-1.0.3 vs spec/clavem/authorizer_spec.rb in clavem-1.1.0
- old
+ new
@@ -172,10 +172,29 @@
instance = ::Clavem::Authorizer.new
expect(instance.default_response_handler(instance, ::ClavemDummyRequest.new(nil), nil)).to eq("")
end
end
+ describe ".localize" do
+ it "should set the right locale path" do
+ expect(instance.instance_variable_get(:@i18n_locales_path)).to eq(File.absolute_path(::Pathname.new(File.dirname(__FILE__)).to_s + "/../../locales/"))
+ instance.localize
+ end
+
+ it "should set using English if called without arguments" do
+ authorizer = ::Clavem::Authorizer.new
+ R18n::I18n.should_receive(:new).with([:en, ENV["LANG"], R18n::I18n.system_locale].compact, File.absolute_path(::Pathname.new(File.dirname(__FILE__)).to_s + "/../../locales/")).and_call_original
+ authorizer.localize
+ end
+
+ it "should set the requested locale" do
+ authorizer = ::Clavem::Authorizer.new
+ R18n::I18n.should_receive(:new).with([:it, ENV["LANG"], R18n::I18n.system_locale].compact, File.absolute_path(::Pathname.new(File.dirname(__FILE__)).to_s + "/../../locales/")).and_call_original
+ authorizer.localize(:it)
+ end
+ end
+
# PRIVATE
describe "#open_endpoint" do
it("should call system with the right command") do
Kernel.should_receive(:system).with("open \"URL\"")
instance.instance_variable_set(:@url, "URL")
@@ -222,10 +241,9 @@
authorizer.stub(:setup_webserver) do authorizer.instance_variable_set(:@server, server) end
expect { authorizer.authorize("URL") }.to raise_error(::Clavem::Exceptions::Timeout)
thread = authorizer.instance_variable_get(:@timeout_thread)
expect(thread).to be_a(Thread)
- expect(thread.stop?).to be_true
expect(authorizer.instance_variable_get(:@timeout_expired)).to be_true
end
end
describe "#setup_webserver" do
\ No newline at end of file