Skip to content

Commit

Permalink
Started implemented specs. Got AR set up
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendan Loudermilk committed Oct 26, 2011
1 parent da8b1cf commit f7178d5
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 10 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Expand Up @@ -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
4 changes: 3 additions & 1 deletion Rakefile
Expand Up @@ -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")
Expand Down
2 changes: 0 additions & 2 deletions acts_as_async.gemspec
Expand Up @@ -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
8 changes: 4 additions & 4 deletions lib/acts_as_async/helper.rb
Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions spec/acts_as_async/base_extensions_spec.rb
@@ -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
Expand Down
7 changes: 7 additions & 0 deletions spec/models.rb
@@ -0,0 +1,7 @@
class AsyncModel < ActiveRecord::Base
acts_as_async
end

class BareModel < ActiveRecord::Base

end
9 changes: 9 additions & 0 deletions spec/schema.rb
@@ -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
33 changes: 32 additions & 1 deletion spec/spec_helper.rb
@@ -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.