Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

no longer using Test::Unit and using RSpec

all existing tests have been converted to specs. 

A little note on the TODO in spec/job_spec.rb for some reason in describe block I cannot get the shoulda macros "should_validate_presence_of" and "should_require_readonly_attributes" to work. Spent a bit of time trying to figure this out but havent gotten it working. Since this part of the spec really isn't as important as the behavior of the Job API I'm going to go back and adress it later.
  • Loading branch information...
commit ad62f11d8ff6afea85a8658eeb7cd570ca4de1de 1 parent 0ad2ff5
jrwest authored
View
7 spec/lib/job_spec.rb
@@ -1,5 +1,10 @@
require File.join(File.dirname(__FILE__), %w[.. spec_helper])
describe Job do
-
+ #TODO DRY this up. Can't get the shoulda macros working
+ specify { subject.should validate_presence_of :worker_class }
+ specify { subject.should validate_presence_of :worker_method }
+ specify { subject.should have_readonly_attribute :worker_class }
+ specify { subject.should have_readonly_attribute :worker_method }
+ specify { subject.should have_readonly_attribute :args }
end
View
3  spec/spec_helper.rb
@@ -4,6 +4,9 @@
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. .. .. config environment]))
require 'spec/rails'
+require 'shoulda'
+require 'shoulda/active_record'
+
# Uncomment the next line to use webrat's matchers
require 'webrat/integrations/rspec-rails'
View
14 test/job_test.rb
@@ -1,14 +0,0 @@
-require File.dirname(__FILE__) + '/test_helper.rb'
-require File.dirname(__FILE__) + '/../lib/job.rb'
-
-class JobTest < Test::Unit::TestCase
-
- def setup
- ActiveRecord::Base.allow_concurrency = false
- @job = Job.new
- end
-
- should_have_readonly_attributes :worker_class, :worker_method, :args
- should_require_attributes :worker_class, :worker_method
-
-end
View
39 test/test_helper.rb
@@ -1,39 +0,0 @@
-# supress warnings
-$VERBOSE = false
-
-require 'rubygems'
-require 'mocha'
-require 'active_record'
-require 'test/unit'
-
-# gem install thoughtbot-shoulda --source http://gems.github.com
-require 'shoulda'
-require 'shoulda/active_record'
-
-ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), 'test.log'))
-ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :dbfile => ':memory:')
-
-ActiveRecord::Schema.define do
- create_table :jobs do |t|
- t.string :worker_class
- t.string :worker_method
-
- t.text :args
- t.text :result
-
- t.integer :priority
-
- t.integer :progress
- t.string :state
-
- t.integer :lock_version, :default => 0
-
- t.timestamp :start_at
- t.timestamp :started_at
- t.timestamps
- end
-
- add_index :jobs, :state
- add_index :jobs, :start_at
- add_index :jobs, :priority
-end
Please sign in to comment.
Something went wrong with that request. Please try again.