From 6f1d6a62a907473abdcf52ee373ecb82cc031909 Mon Sep 17 00:00:00 2001 From: Joshua Young Date: Thu, 24 Oct 2024 18:31:08 +1000 Subject: [PATCH] Make raise and rb_raise messages consistent --- .ruby-version | 1 + ext/vernier/vernier.cc | 2 +- lib/vernier.rb | 4 ++-- lib/vernier/collector.rb | 2 +- test/test_time_collector.rb | 4 ++-- 5 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 .ruby-version diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..c0f8b3e --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.4.0-preview2 diff --git a/ext/vernier/vernier.cc b/ext/vernier/vernier.cc index ba4e880..7618016 100644 --- a/ext/vernier/vernier.cc +++ b/ext/vernier/vernier.cc @@ -1989,7 +1989,7 @@ collector_start(VALUE self) { auto *collector = get_collector(self); if (!collector->start()) { - rb_raise(rb_eRuntimeError, "already running"); + rb_raise(rb_eRuntimeError, "collector already running"); } return Qtrue; diff --git a/lib/vernier.rb b/lib/vernier.rb index 27aae7b..cb08572 100644 --- a/lib/vernier.rb +++ b/lib/vernier.rb @@ -40,7 +40,7 @@ def self.start_profile(mode: :wall, **collector_options) @collector.stop @collector = nil - raise "Profile already started, stopping..." + raise "profile already started, stopping..." end @collector = Vernier::Collector.new(mode, collector_options) @@ -48,7 +48,7 @@ def self.start_profile(mode: :wall, **collector_options) end def self.stop_profile - raise "No profile started" unless @collector + raise "profile not started" unless @collector result = @collector.stop @collector = nil diff --git a/lib/vernier/collector.rb b/lib/vernier/collector.rb index 59aa21c..d9e695b 100644 --- a/lib/vernier/collector.rb +++ b/lib/vernier/collector.rb @@ -32,7 +32,7 @@ def initialize(mode, options = {}) when :rails, :activesupport @hooks << Vernier::Hooks::ActiveSupport.new(self) else - warn "Unknown hook: #{hook.inspect}" + warn "unknown hook: #{hook.inspect}" end end diff --git a/test/test_time_collector.rb b/test/test_time_collector.rb index 4058121..27f14c0 100644 --- a/test/test_time_collector.rb +++ b/test/test_time_collector.rb @@ -247,14 +247,14 @@ def test_multiple_starts Vernier.start_profile(interval: SAMPLE_SCALE_INTERVAL) Vernier.start_profile(interval: SAMPLE_SCALE_INTERVAL) end - assert_equal "Profile already started, stopping...", error.message + assert_equal "profile already started, stopping...", error.message end def test_stop_without_start error = assert_raises("No trace started") do Vernier.stop_profile end - assert_equal "No profile started", error.message + assert_equal "profile not started", error.message end def test_includes_options_in_result_meta