From 22ce2cb9eb93e1df575442818a0b8ec99a8d1828 Mon Sep 17 00:00:00 2001 From: Herwin Date: Wed, 25 Sep 2024 10:55:52 +0200 Subject: [PATCH 1/2] Convert Date#month to a shared spec --- library/date/month_spec.rb | 6 ++---- library/date/shared/month.rb | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 library/date/shared/month.rb diff --git a/library/date/month_spec.rb b/library/date/month_spec.rb index e040f9a94c..f493ec8119 100644 --- a/library/date/month_spec.rb +++ b/library/date/month_spec.rb @@ -1,9 +1,7 @@ require_relative '../../spec_helper' +require_relative 'shared/month' require 'date' describe "Date#month" do - it "returns the month" do - m = Date.new(2000, 7, 1).month - m.should == 7 - end + it_behaves_like :date_month, :month end diff --git a/library/date/shared/month.rb b/library/date/shared/month.rb new file mode 100644 index 0000000000..5fcb2cbeb0 --- /dev/null +++ b/library/date/shared/month.rb @@ -0,0 +1,6 @@ +describe :date_month, shared: true do + it "returns the month" do + m = Date.new(2000, 7, 1).send(@method) + m.should == 7 + end +end From 97f84c7a2a05789f245ea50fe65c4840ab39714e Mon Sep 17 00:00:00 2001 From: Herwin Date: Wed, 25 Sep 2024 10:56:40 +0200 Subject: [PATCH 2/2] Add specs for Date#mon This is an alias of Date#month, so we can simmply use the shared spec --- library/date/mon_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/date/mon_spec.rb b/library/date/mon_spec.rb index 724e7d6564..616d72cf88 100644 --- a/library/date/mon_spec.rb +++ b/library/date/mon_spec.rb @@ -1,6 +1,7 @@ require_relative '../../spec_helper' +require_relative 'shared/month' require 'date' describe "Date#mon" do - it "needs to be reviewed for spec completeness" + it_behaves_like :date_month, :mon end