Skip to content

Commit

Permalink
Merge pull request #150 from Shopify/add-skip-until-version-test-helper
Browse files Browse the repository at this point in the history
  • Loading branch information
sambostock authored Nov 15, 2021
2 parents 4730c21 + d3fdeff commit 6c24c05
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 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
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

0 comments on commit 6c24c05

Please sign in to comment.