diff options
author | Abdelkader Boudih <terminale@gmail.com> | 2014-08-29 20:11:17 +0000 |
---|---|---|
committer | Abdelkader Boudih <terminale@gmail.com> | 2014-09-02 07:50:16 +0000 |
commit | fccf3d0b6304a7b8dacad05b63f24cdf41e652df (patch) | |
tree | 50450c272fe7264af1f1f12c1ad03225298b20e6 /activejob/test/cases | |
parent | eb4245dd17ba66c0551f3d4ed841b471bcf01b91 (diff) | |
download | rails-fccf3d0b6304a7b8dacad05b63f24cdf41e652df.tar.gz rails-fccf3d0b6304a7b8dacad05b63f24cdf41e652df.tar.bz2 rails-fccf3d0b6304a7b8dacad05b63f24cdf41e652df.zip |
[ActiveJob] TestCase
Diffstat (limited to 'activejob/test/cases')
-rw-r--r-- | activejob/test/cases/test_case_test.rb | 15 | ||||
-rw-r--r-- | activejob/test/cases/test_helper_test.rb | 20 | ||||
-rw-r--r-- | activejob/test/cases/test_test.rb | 43 |
3 files changed, 24 insertions, 54 deletions
diff --git a/activejob/test/cases/test_case_test.rb b/activejob/test/cases/test_case_test.rb new file mode 100644 index 0000000000..802a796fd1 --- /dev/null +++ b/activejob/test/cases/test_case_test.rb @@ -0,0 +1,15 @@ +# encoding: utf-8 +require 'helper' +require 'jobs/hello_job' +require 'jobs/logging_job' +require 'jobs/nested_job' + +class ActiveJobTestCaseTest < ActiveJob::TestCase + def test_include_helper + assert_includes self.class.ancestors, ActiveJob::TestHelper + end + + def test_set_test_adapter + assert_instance_of ActiveJob::QueueAdapters::TestAdapter, self.queue_adapter + end +end diff --git a/activejob/test/cases/test_helper_test.rb b/activejob/test/cases/test_helper_test.rb index b98c8e01a5..ee558e6d59 100644 --- a/activejob/test/cases/test_helper_test.rb +++ b/activejob/test/cases/test_helper_test.rb @@ -7,8 +7,7 @@ require 'jobs/logging_job' require 'jobs/nested_job' class EnqueuedJobsTest < ActiveJob::TestCase - tests HelloJob - setup :perform_enqueued_at_jobs + setup { queue_adapter.perform_enqueued_at_jobs = true } def test_assert_enqueued_jobs assert_nothing_raised do @@ -87,20 +86,20 @@ class EnqueuedJobsTest < ActiveJob::TestCase end def test_assert_enqueued_job - assert_enqueued_job(job: LoggingJob, queue: 'default') do + assert_enqueued_with(job: LoggingJob, queue: 'default') do NestedJob.enqueue_at(Date.tomorrow.noon) end end def test_assert_enqueued_job_failure assert_raise ActiveSupport::TestCase::Assertion do - assert_enqueued_job(job: LoggingJob, queue: 'default') do + assert_enqueued_with(job: LoggingJob, queue: 'default') do NestedJob.enqueue end end assert_raise ActiveSupport::TestCase::Assertion do - assert_enqueued_job(job: NestedJob, queue: 'low') do + assert_enqueued_with(job: NestedJob, queue: 'low') do NestedJob.enqueue end end @@ -108,7 +107,7 @@ class EnqueuedJobsTest < ActiveJob::TestCase def test_assert_enqueued_job_args assert_raise ArgumentError do - assert_enqueued_job(class: LoggingJob) do + assert_enqueued_with(class: LoggingJob) do NestedJob.enqueue_at(Date.tomorrow.noon) end end @@ -116,8 +115,7 @@ class EnqueuedJobsTest < ActiveJob::TestCase end class PerformedJobsTest < ActiveJob::TestCase - tests HelloJob - setup :perform_enqueued_jobs + setup { queue_adapter.perform_enqueued_jobs = true } def test_assert_performed_jobs assert_nothing_raised do @@ -196,20 +194,20 @@ class PerformedJobsTest < ActiveJob::TestCase end def test_assert_performed_job - assert_performed_job(job: NestedJob, queue: 'default') do + assert_performed_with(job: NestedJob, queue: 'default') do NestedJob.enqueue end end def test_assert_performed_job_failure assert_raise ActiveSupport::TestCase::Assertion do - assert_performed_job(job: LoggingJob, queue: 'default') do + assert_performed_with(job: LoggingJob, queue: 'default') do NestedJob.enqueue_at(Date.tomorrow.noon) end end assert_raise ActiveSupport::TestCase::Assertion do - assert_performed_job(job: NestedJob, queue: 'low') do + assert_performed_with(job: NestedJob, queue: 'low') do NestedJob.enqueue_at(Date.tomorrow.noon) end end diff --git a/activejob/test/cases/test_test.rb b/activejob/test/cases/test_test.rb deleted file mode 100644 index a4d786f3da..0000000000 --- a/activejob/test/cases/test_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# encoding: utf-8 -require 'helper' -require 'jobs/hello_job' -require 'jobs/logging_job' -require 'jobs/nested_job' - -class ActiveJobTestCaseTest < ActiveJob::TestCase - tests HelloJob - - def test_set_job_class_manual - assert_equal HelloJob, self.class.job_class - end -end - -class CrazySymbolNameJobTest < ActiveJob::TestCase - tests :hello_job - - def test_set_job_class_manual_using_symbol - assert_equal HelloJob, self.class.job_class - end -end - -class CrazyStringNameJobTest < ActiveJob::TestCase - tests 'hello_job' - - def test_set_job_class_manual_using_string - assert_equal HelloJob, self.class.job_class - end -end - -class HelloJobTest < ActiveJob::TestCase - def test_set_job_class_manual - assert_equal HelloJob, self.class.job_class - end -end - -class CrazyNameJobTest < ActiveJob::TestCase - def test_determine_default_job_raises_correct_error - assert_raise(ActiveJob::NonInferrableJobError) do - self.class.job_class - end - end -end |