Skip to content

Commit

Permalink
feat(result): add default
Browse files Browse the repository at this point in the history
  • Loading branch information
benzend committed Nov 19, 2024
1 parent 09c3353 commit 513becd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/glare/ux_metrics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,10 @@ def initialize(result:, threshold:, label:)
@label = label
end

def self.default
Result.new(result: 0.0, threshold: "", label: "")
end

attr_reader :result, :threshold, :label
end

Expand Down
2 changes: 1 addition & 1 deletion lib/glare/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Glare
module UxMetrics
VERSION = "0.2.5"
VERSION = "0.2.6"
end
end
2 changes: 2 additions & 0 deletions sig/glare/ux_metrics.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ module Glare
attr_reader threshold: String

def initialize: (result: Float, label: String, threshold: String) -> void

def self.default: () -> Result
end

class ClickData
Expand Down
10 changes: 10 additions & 0 deletions spec/glare/ux_metrics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,14 @@
expect(parser.result.is_a?(Float) && parser.label.is_a?(String) && parser.threshold.is_a?(String)).to eq(true)
end
end

describe Glare::UxMetrics::Result do
it "returns a valid default" do
result = Glare::UxMetrics::Result.default
expect(result).to be_a(Glare::UxMetrics::Result)
expect(result.result).to eq(0.0)
expect(result.threshold.empty?).to eq(true)
expect(result.label.empty?).to eq(true)
end
end
end

0 comments on commit 513becd

Please sign in to comment.