Files
nairobi/spec/helpers/settings_helper_spec.rb
Javi Martín db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00

37 lines
1.1 KiB
Ruby

require "rails_helper"
RSpec.describe SettingsHelper, type: :helper do
describe "#setting" do
it "returns a hash with all settings values" do
Setting["key1"] = "value1"
Setting["key2"] = "value2"
expect(setting["key1"]).to eq("value1")
expect(setting["key2"]).to eq("value2")
expect(setting["key3"]).to eq(nil)
end
end
describe "#feature?" do
it "returns presence of feature flag setting value" do
Setting["feature.f1"] = "active"
Setting["feature.f2"] = ""
Setting["feature.f3"] = nil
expect(feature?("f1")).to eq("active")
expect(feature?("f2")).to eq(nil)
expect(feature?("f3")).to eq(nil)
expect(feature?("f4")).to eq(nil)
end
end
describe "#display_setting_name" do
it "returns correct setting_name" do
expect(display_setting_name("setting")).to eq("Setting")
expect(display_setting_name("remote_census_general_name")).to eq("General Information")
expect(display_setting_name("remote_census_request_name")).to eq("Request Data")
expect(display_setting_name("remote_census_response_name")).to eq("Response Data")
end
end
end