Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
pacso committed May 10, 2024
1 parent cb8832c commit 80f77fe
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 44 deletions.
8 changes: 4 additions & 4 deletions lib/ice_cube/i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ module IceCube
module I18n
LOCALES_PATH = File.expand_path(File.join("..", "..", "..", "config", "locales"), __FILE__)

def self.t(*args, **kwargs)
backend.t(*args, **kwargs)
def self.t(*, **)
backend.t(*, **)
end

def self.l(*args, **kwargs)
backend.l(*args, **kwargs)
def self.l(*, **)
backend.l(*, **)
end

def self.backend
Expand Down
4 changes: 2 additions & 2 deletions lib/ice_cube/rule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def self.from_ical(ical)
end

# Yaml implementation
def to_yaml(*args)
YAML.dump(to_hash, *args)
def to_yaml(*)
YAML.dump(to_hash, *)
end

# From yaml
Expand Down
76 changes: 38 additions & 38 deletions spec/examples/from_hash_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,57 +9,57 @@ module IceCube
end

it "should raise an ArgumentError when the hash[:rule_type] is invalid" do
expect { Rule.from_hash({ rule_type: "IceCube::MadeUpIntervalRule" }) }
expect { Rule.from_hash({rule_type: "IceCube::MadeUpIntervalRule"}) }
.to raise_error ArgumentError, "Invalid rule frequency type: MadeUpInterval"
end

it "returns a SecondlyRule when the hash[:rule_type] is secondly" do
expect(Rule.from_hash({ rule_type: "IceCube::SecondlyRule" })).to be_a SecondlyRule
expect(Rule.from_hash({rule_type: "IceCube::SecondlyRule"})).to be_a SecondlyRule
end

it "returns a MinutelyRule when the hash[:rule_type] is minutely" do
expect(Rule.from_hash({ rule_type: "IceCube::MinutelyRule" })).to be_a MinutelyRule
expect(Rule.from_hash({rule_type: "IceCube::MinutelyRule"})).to be_a MinutelyRule
end

it "returns a HourlyRule when the hash[:rule_type] is hourly" do
expect(Rule.from_hash({ rule_type: "IceCube::HourlyRule" })).to be_a HourlyRule
expect(Rule.from_hash({rule_type: "IceCube::HourlyRule"})).to be_a HourlyRule
end

it "returns a DailyRule when the hash[:rule_type] is daily" do
expect(Rule.from_hash({ rule_type: "IceCube::DailyRule" })).to be_a DailyRule
expect(Rule.from_hash({rule_type: "IceCube::DailyRule"})).to be_a DailyRule
end

it "returns a WeeklyRule when the hash[:rule_type] is weekly" do
expect(Rule.from_hash({ rule_type: "IceCube::WeeklyRule" })).to be_a WeeklyRule
expect(Rule.from_hash({rule_type: "IceCube::WeeklyRule"})).to be_a WeeklyRule
end

it "returns a MonthlyRule when the hash[:rule_type] is monthly" do
expect(Rule.from_hash({ rule_type: "IceCube::MonthlyRule" })).to be_a MonthlyRule
expect(Rule.from_hash({rule_type: "IceCube::MonthlyRule"})).to be_a MonthlyRule
end

it "returns a YearlyRule when the hash[:rule_type] is yearly" do
expect(Rule.from_hash({ rule_type: "IceCube::YearlyRule" })).to be_a YearlyRule
expect(Rule.from_hash({rule_type: "IceCube::YearlyRule"})).to be_a YearlyRule
end
end

describe "creating monthly rule" do
context "with valid day_of_week validations" do
let(:input_hash) {
{
"rule_type": "IceCube::MonthlyRule",
"interval": 1,
"validations": {
"day_of_week": {
rule_type: "IceCube::MonthlyRule",
interval: 1,
validations: {
day_of_week: {
"0": [2],
"1": [2],
"2": [2],
"3": [2],
"4": [2],
"5": [2],
"6": [1,2]
"6": [1, 2]
},
"hour_of_day": 7,
"minute_of_hour": 19
hour_of_day: 7,
minute_of_hour: 19
}
}
}
Expand All @@ -69,50 +69,50 @@ module IceCube
schedule = Schedule.new(Time.utc(2010, 1, 1, 0, 0, 0))
schedule.add_recurrence_rule rule
expect(schedule.first(10).map(&:to_time)).to eq([
Time.utc(2010, 1, 2, 7, 19, 0),
Time.utc(2010, 1, 8, 7, 19, 0),
Time.utc(2010, 1, 9, 7, 19, 0),
Time.utc(2010, 1, 10, 7, 19, 0),
Time.utc(2010, 1, 11, 7, 19, 0),
Time.utc(2010, 1, 12, 7, 19, 0),
Time.utc(2010, 1, 13, 7, 19, 0),
Time.utc(2010, 1, 14, 7, 19, 0),
Time.utc(2010, 2, 6, 7, 19, 0),
Time.utc(2010, 2, 8, 7, 19, 0)
])
Time.utc(2010, 1, 2, 7, 19, 0),
Time.utc(2010, 1, 8, 7, 19, 0),
Time.utc(2010, 1, 9, 7, 19, 0),
Time.utc(2010, 1, 10, 7, 19, 0),
Time.utc(2010, 1, 11, 7, 19, 0),
Time.utc(2010, 1, 12, 7, 19, 0),
Time.utc(2010, 1, 13, 7, 19, 0),
Time.utc(2010, 1, 14, 7, 19, 0),
Time.utc(2010, 2, 6, 7, 19, 0),
Time.utc(2010, 2, 8, 7, 19, 0)
])
end
end

context "with invalid day_of_week validations" do
let(:input_hash_with_zeroeth_occurrence) {
{
"rule_type": "IceCube::MonthlyRule",
"interval": 1,
"validations": {
"day_of_week": {
rule_type: "IceCube::MonthlyRule",
interval: 1,
validations: {
day_of_week: {
"1": [],
"2": [0],
"3": [],
"4": []
},
"hour_of_day": 7,
"minute_of_hour": 19
hour_of_day: 7,
minute_of_hour: 19
}
}
}
let(:input_hash_with_sixth_occurrence) {
{
"rule_type": "IceCube::MonthlyRule",
"interval": 1,
"validations": {
"day_of_week": {
rule_type: "IceCube::MonthlyRule",
interval: 1,
validations: {
day_of_week: {
"1": [],
"2": [6],
"3": [],
"4": []
},
"hour_of_day": 7,
"minute_of_hour": 19
hour_of_day: 7,
minute_of_hour: 19
}
}
}
Expand Down

0 comments on commit 80f77fe

Please sign in to comment.