Permalink
Browse files

Started implemented specs. Got AR set up

  • Loading branch information...
1 parent da8b1cf commit f7178d558cfc384a60c1a1fee68609d03d6188b2 @bloudermilk committed Oct 26, 2011
Showing with 71 additions and 10 deletions.
  1. +3 −0 Gemfile
  2. +3 −1 Rakefile
  3. +0 −2 acts_as_async.gemspec
  4. +4 −4 lib/acts_as_async/helper.rb
  5. +13 −2 spec/acts_as_async/base_extensions_spec.rb
  6. +7 −0 spec/models.rb
  7. +9 −0 spec/schema.rb
  8. +32 −1 spec/spec_helper.rb
View
@@ -4,6 +4,9 @@ gemspec
group :test do
gem "rake"
+ gem "rspec", "~> 2.7.0"
+ gem "sqlite3", "~> 1.3.4"
gem "yajl-ruby", "~> 0.8.2", :platforms => :mri
gem "json", "~> 1.5.3", :platforms => [:jruby, :rbx]
+ gem "database_cleaner", "~> 0.6.7"
end
View
@@ -5,7 +5,9 @@ require "rake"
require "rspec"
require "rspec/core/rake_task"
-$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
+lib_path = File.expand_path("../lib", __FILE__)
+$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include? lib_path
+
require "acts_as_async/version"
RSpec::Core::RakeTask.new("spec")
@@ -18,8 +18,6 @@ Gem::Specification.new do |s|
s.add_dependency "activesupport"
s.add_dependency "activerecord"
- s.add_development_dependency "rspec", "~> 2.7.0"
-
s.files = Dir.glob("lib/**/*") + %w(LICENSE Rakefile README.md)
s.require_path = "lib"
end
@@ -84,12 +84,12 @@ def method_missing(method_id, *args, &block)
# exist, since technically we do respond to that method but throw
# an exception.
if RUBY_VERSION >= "1.9.2"
- def respond_to_missing?(method_id, include_private)
- method =~ METHOD_REGEXP || super
+ def respond_to_missing?(method_id, *)
+ method_id =~ METHOD_REGEXP || super
end
else
- def respond_to?(method_id, include_private)
- method =~ METHOD_REGEXP || super
+ def respond_to?(method_id, *)
+ method_id =~ METHOD_REGEXP || super
end
end
end
@@ -1,12 +1,23 @@
require "spec_helper"
describe ActsAsAsync::BaseExtensions do
- it "should be included into ActiveRecord"
+ it "should be included into ActiveRecord" do
+ lambda { BareModel.acts_as_async }.should_not raise_exception
+ end
describe ".acts_as_async" do
- it "should include the rest of the helper methods"
+ it "should include the rest of the helper methods" do
+ AsyncModel.should respond_to(:async)
+ AsyncModel.should respond_to(:async_at)
+ AsyncModel.should respond_to(:async_in)
+ AsyncModel.new.should respond_to(:async)
+ AsyncModel.new.should respond_to(:async_at)
+ AsyncModel.new.should respond_to(:async_in)
+ end
context "when @queue is already set" do
+ let :model { BareModel }
+
context "when :queue is passed as an option" do
it "should override the @queue value to the value passed"
end
View
@@ -0,0 +1,7 @@
+class AsyncModel < ActiveRecord::Base
+ acts_as_async
+end
+
+class BareModel < ActiveRecord::Base
+
+end
View
@@ -0,0 +1,9 @@
+ActiveRecord::Schema.define :version => 0 do
+ create_table :async_models, :force => true do |t|
+ t.string :name
+ end
+
+ create_table :bare_models, :force => true do |t|
+ t.string :name
+ end
+end
View
@@ -1,2 +1,33 @@
-require "rspec"
+# Load up the test environment
+Bundler.setup(:default, :test)
+Bundler.require(:default, :test)
+
+lib_path = File.expand_path("../../lib", __FILE__)
+$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include? lib_path
+
require "acts_as_async"
+
+ActiveRecord::Base.establish_connection({
+ :adapter => "sqlite3",
+ :database => ":memory:"
+})
+
+ActiveRecord::Base.silence do
+ ActiveRecord::Migration.verbose = false
+
+ load(File.expand_path "../schema.rb", __FILE__)
+ load(File.expand_path "../models.rb", __FILE__)
+end
+
+RSpec.configure do |config|
+ config.mock_with :rspec
+
+ config.before(:suite) do
+ DatabaseCleaner.strategy = :truncation
+ DatabaseCleaner.clean
+ end
+
+ config.after(:each) do
+ DatabaseCleaner.clean
+ end
+end

0 comments on commit f7178d5

Please sign in to comment.