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

Add skip_until_version test helper #150

Merged
merged 1 commit into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions test/unit/throttle_enumerator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ def each_iteration(_record, _params); end
end

test "does not evaluate enumerator when throttled" do
skip("Deferred until 2.0.0")
skip_until_version("2.0.0")
CustomizableThrottleJob.perform_now({
enumerator: Enumerator.new { raise StandardError, "should not evaluate when throttled" },
throttle_on: -> { true },
})
end

test "can only wrap another enumerator" do
skip("Deferred until 2.0.0")
skip_until_version("2.0.0")
error = assert_raises(ArgumentError) do
CustomizableThrottleJob.perform_now({
enumerator: [],
Expand Down