mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
b3d769ff4f
update rspec syntax to v3 change syntax to rspec v3 oops. fix typo mailers classes with rspec3 syntax helpers with rspec3 syntax jobs with rspec3 syntax serializers with rspec3 syntax views with rspec3 syntax support to rspec3 syntax category spec with rspec3 syntax
46 lines
1.2 KiB
Ruby
46 lines
1.2 KiB
Ruby
require 'spec_helper'
|
|
require 'tempfile'
|
|
|
|
describe GlobalSetting::EnvProvider do
|
|
it "can detect keys from env" do
|
|
ENV['DISCOURSE_BLA'] = '1'
|
|
expect(GlobalSetting::EnvProvider.new.keys).to include(:bla)
|
|
end
|
|
end
|
|
describe GlobalSetting::FileProvider do
|
|
it "can parse a simple file" do
|
|
f = Tempfile.new('foo')
|
|
f.write(" # this is a comment\n")
|
|
f.write("\n")
|
|
f.write("a = 1000 # this is a comment\n")
|
|
f.write("b = \"10 # = 00\" # this is a # comment\n")
|
|
f.write("c = \'10 # = 00\' # this is a # comment\n")
|
|
f.write("d =\n")
|
|
f.close
|
|
|
|
provider = GlobalSetting::FileProvider.from(f.path)
|
|
|
|
expect(provider.lookup(:a,"")).to eq 1000
|
|
expect(provider.lookup(:b,"")).to eq "10 # = 00"
|
|
expect(provider.lookup(:c,"")).to eq "10 # = 00"
|
|
expect(provider.lookup(:d,"bob")).to eq nil
|
|
expect(provider.lookup(:e,"bob")).to eq "bob"
|
|
|
|
expect(provider.keys.sort).to eq [:a, :b, :c, :d]
|
|
|
|
f.unlink
|
|
end
|
|
|
|
it "uses ERB" do
|
|
f = Tempfile.new('foo')
|
|
f.write("a = <%= 500 %> # this is a comment\n")
|
|
f.close
|
|
|
|
provider = GlobalSetting::FileProvider.from(f.path)
|
|
|
|
expect(provider.lookup(:a,"")).to eq 500
|
|
|
|
f.unlink
|
|
end
|
|
|
|
end
|