Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some failing round trips #536

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

boutil
Copy link

@boutil boutil commented Nov 16, 2022

In some Debian environment two of the round trips in to_yaml_spec.rb were failing (those using .month_of_year and day_of_year. Applying the same fix as the one used in 4bf17183be02f8efe17b98c401af40db48a931dc to fix #483 solved the issue.

This patch proposes that corresponding change to /spec/examples/to_yaml_spec.rb.

In some Debian environment two of the round trips in to_yaml_spec.rb were failing (those using `.month_of_year` and `day_of_year`. Applying the same fix as the one used in 4bf1718 to fix ice-cube-ruby#483 solved the issue.

This patch proposes that corresponding change to `/spec/examples/to_yaml_spec.rb`.
@adfoster-r7
Copy link

This fixes one of the tests for me 👍

Before

rspec ./spec/examples/to_yaml_spec.rb:80 # IceCube::Schedule to_yaml should be able to make a round-trip to YAML with .day_of_year
rspec ./spec/examples/to_yaml_spec.rb:114 # IceCube::Schedule to_yaml should be able to make a round-trip to YAML with .month_of_year
rspec ./spec/examples/to_yaml_spec.rb:136 # IceCube::Schedule to_yaml should be able to make a round-trip to YAML whilst preserving exception rules

After

rspec ./spec/examples/occurrence_spec.rb:27 # IceCube::Occurrence to_s accepts a format option to comply with ActiveSupport
rspec ./spec/examples/to_yaml_spec.rb:136 # IceCube::Schedule to_yaml should be able to make a round-trip to YAML whilst preserving exception rules

Remaining failures:

Failures:

  1) IceCube::Occurrence to_s accepts a format option to comply with ActiveSupport
     Failure/Error: expect(occurrence.to_s(:short)).to eq time_now.to_s(:short)
     
     ArgumentError:
       wrong number of arguments (given 1, expected 0)
     # /Users/user/.rvm/gems/ruby-3.0.6/gems/activesupport-7.1.3/lib/active_support/time_with_zone.rb:200:in `to_s'
     # ./spec/examples/occurrence_spec.rb:31:in `block (3 levels) in <top (required)>'
     # ./spec/spec_helper.rb:76:in `block (3 levels) in <top (required)>'
     # ./spec/spec_helper.rb:75:in `block (2 levels) in <top (required)>'

  2) IceCube::Schedule to_yaml should be able to make a round-trip to YAML whilst preserving exception rules
     Failure/Error: expect(returned_schedule.first(10).map { |r| r.to_s }).to eq(original_schedule.first(10).map { |r| r.to_s })
     
       expected: ["2024-02-26 22:54:37 +0000", "2024-03-04 22:54:37 +0000", "2024-03-11 22:54:37 +0000", "2024-03-18 2...54:37 +0100", "2024-04-15 22:54:37 +0100", "2024-04-22 22:54:37 +0100", "2024-04-29 22:54:37 +0100"]
            got: ["2024-02-26 22:54:37 +0000", "2024-03-04 22:54:37 +0000", "2024-03-11 22:54:37 +0000", "2024-03-18 2...54:37 +0000", "2024-04-15 22:54:37 +0000", "2024-04-22 22:54:37 +0000", "2024-04-29 22:54:37 +0000"]
     
       (compared using ==)
     # ./spec/examples/to_yaml_spec.rb:145:in `block (2 levels) in <module:IceCube>'
     # ./spec/spec_helper.rb:76:in `block (3 levels) in <top (required)>'
     # ./spec/spec_helper.rb:75:in `block (2 levels) in <top (required)>'

Finished in 1.18 seconds (files took 0.62841 seconds to load)
1114 examples, 2 failures

The first test failure is fixed by #528 - but it looks like the second test is still failing 🤔

@adfoster-r7
Copy link

adfoster-r7 commented Feb 20, 2024

Looks like following your pattern for the final remaining test worked for my env 👍

diff --git a/spec/examples/to_yaml_spec.rb b/spec/examples/to_yaml_spec.rb
index 7166110..913cd05 100644
--- a/spec/examples/to_yaml_spec.rb
+++ b/spec/examples/to_yaml_spec.rb
@@ -134,7 +134,7 @@ module IceCube
     end
 
     it "should be able to make a round-trip to YAML whilst preserving exception rules" do
-      original_schedule = Schedule.new(Time.now)
+      original_schedule = Schedule.new(Time.zone.now)
       original_schedule.add_recurrence_rule Rule.daily.day(:monday, :wednesday)
       original_schedule.add_exception_rule Rule.daily.day(:wednesday)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 to_yaml spec failures with 0.16.3 and ruby2.7
2 participants