Fix offense constant definition in block in models/spree/preferences/configuration_spec.rb

This commit is contained in:
Ana Nunes da Silva
2024-03-26 10:59:35 +00:00
parent fc3d7f8496
commit b18fe8ce35
2 changed files with 9 additions and 11 deletions

View File

@@ -11,7 +11,6 @@
# AllowedMethods: enums
Lint/ConstantDefinitionInBlock:
Exclude:
- 'spec/models/spree/preferences/configuration_spec.rb'
- 'spec/models/spree/preferences/preferable_spec.rb'
- 'spec/validators/date_time_string_validator_spec.rb'
- 'spec/validators/integer_array_validator_spec.rb'

View File

@@ -3,25 +3,24 @@
require 'spec_helper'
describe Spree::Preferences::Configuration do
before :all do
class AppConfig < Spree::Preferences::Configuration
let(:config) do
Class.new(Spree::Preferences::Configuration) do
preference :color, :string, default: :blue
end
@config = AppConfig.new
end.new
end
it "has named methods to access preferences" do
@config.color = 'orange'
expect(@config.color).to eq 'orange'
config.color = 'orange'
expect(config.color).to eq 'orange'
end
it "uses [ ] to access preferences" do
@config[:color] = 'red'
expect(@config[:color]).to eq 'red'
config[:color] = 'red'
expect(config[:color]).to eq 'red'
end
it "uses set/get to access preferences" do
@config.set :color, 'green'
expect(@config.get(:color)).to eq 'green'
config.set :color, 'green'
expect(config.get(:color)).to eq 'green'
end
end