Skip to content

Commit

Permalink
Add skip_until_version test helper
Browse files Browse the repository at this point in the history
This helper will skip the test ONLY if the gem version is below the
specified version.

This ensures that changes meant for a particular version release are
included, and not forgotten or otherwise missed.
  • Loading branch information
sambostock committed Nov 13, 2021
1 parent 329e903 commit 63fcddf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion test/integration/integration_behaviour.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module IntegrationBehaviour
end

test "unserializable corruption is prevented" do
skip "Deferred until 2.0.0"
skip_until_version("2.0.0")
# Cursors are serialized as JSON, but not all objects are serializable.
# time = Time.at(0).utc # => 1970-01-01 00:00:00 UTC
# json = JSON.dump(time) # => "\"1970-01-01 00:00:00 UTC\""
Expand Down
4 changes: 4 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ class TestCase
setup do
Redis.current.flushdb
end

def skip_until_version(version)
skip("Deferred until version #{version}") if Gem::Version.new(JobIteration::VERSION) < Gem::Version.new(version)
end
end
end

Expand Down
12 changes: 6 additions & 6 deletions test/unit/iteration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,38 +200,38 @@ def foo
end

def test_jobs_using_time_cursor_will_raise
skip("Deferred until 2.0.0")
skip_until_version("2.0.0")
push(JobWithTimeCursor)
assert_raises_cursor_error { work_one_job }
end

def test_jobs_using_active_record_cursor_will_raise
skip("Deferred until 2.0.0")
skip_until_version("2.0.0")
refute_nil(Product.first)
push(JobWithActiveRecordCursor)
assert_raises_cursor_error { work_one_job }
end

def test_jobs_using_symbol_cursor_will_raise
skip("Deferred until 2.0.0")
skip_until_version("2.0.0")
push(JobWithSymbolCursor)
assert_raises_cursor_error { work_one_job }
end

def test_jobs_using_string_subclass_cursor_will_raise
skip("Deferred until 2.0.0")
skip_until_version("2.0.0")
push(JobWithStringSubclassCursor)
assert_raises_cursor_error { work_one_job }
end

def test_jobs_using_basic_object_cursor_will_raise
skip("Deferred until 2.0.0")
skip_until_version("2.0.0")
push(JobWithBasicObjectCursor)
assert_raises_cursor_error { work_one_job }
end

def test_jobs_using_complex_but_serializable_cursor_will_not_raise
skip("Deferred until 2.0.0")
skip_until_version("2.0.0")
push(JobWithComplexCursor)
work_one_job
end
Expand Down

0 comments on commit 63fcddf

Please sign in to comment.