Skip to content

Commit

Permalink
Brutally ripped out all the caching code.
Browse files Browse the repository at this point in the history
  • Loading branch information
notahat committed Feb 25, 2011
1 parent 729dcf3 commit 2839888
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 253 deletions.
45 changes: 45 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
GEM
remote: http://rubygems.org/
specs:
activemodel (3.0.4)
activesupport (= 3.0.4)
builder (~> 2.1.2)
i18n (~> 0.4)
activerecord (3.0.4)
activemodel (= 3.0.4)
activesupport (= 3.0.4)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activesupport (3.0.4)
arel (2.0.8)
builder (2.1.2)
diff-lcs (1.1.2)
git (1.2.5)
i18n (0.5.0)
jeweler (1.5.2)
bundler (~> 1.0.0)
git (>= 1.2.5)
rake
mysql (2.8.1)
rake (0.8.7)
rcov (0.9.9)
rspec (2.5.0)
rspec-core (~> 2.5.0)
rspec-expectations (~> 2.5.0)
rspec-mocks (~> 2.5.0)
rspec-core (2.5.1)
rspec-expectations (2.5.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.5.0)
tzinfo (0.3.24)

PLATFORMS
ruby

DEPENDENCIES
activerecord
jeweler
mysql
rake
rcov
rspec (>= 2.0.0.beta.12)
12 changes: 0 additions & 12 deletions lib/machinist.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
require 'machinist/blueprint'
require 'machinist/configuration'
require 'machinist/exceptions'
require 'machinist/lathe'
require 'machinist/machinable'
require 'machinist/shop'
require 'machinist/warehouse'

module Machinist

# Call this before each test to get Machinist ready.
def self.reset_before_test
Shop.instance.restock
end

end

32 changes: 0 additions & 32 deletions lib/machinist/configuration.rb

This file was deleted.

10 changes: 2 additions & 8 deletions lib/machinist/machinable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,11 @@ def make(*args)
# :call-seq:
# make!([count], [blueprint_name], [attributes = {}])
#
# A cached object will be returned from the shop if possible. See
# Machinist::Shop.
#
# Arguments are the same as for make.
def make!(*args)
decode_args_to_make(*args) do |blueprint, attributes|
if Machinist.configuration.cache_objects?
Shop.instance.buy(blueprint, attributes)
else
blueprint.make!(attributes)
end
raise BlueprintCantSaveError.new(blueprint) unless blueprint.respond_to?(:make!)
blueprint.make!(attributes)
end
end

Expand Down
52 changes: 0 additions & 52 deletions lib/machinist/shop.rb

This file was deleted.

27 changes: 0 additions & 27 deletions spec/active_record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,9 @@
include ActiveRecordEnvironment

before(:each) do
Machinist::Shop.instance.reset!
empty_database!
end

def fake_a_test
ActiveRecord::Base.transaction do
Machinist.reset_before_test
yield
raise ActiveRecord::Rollback
end
end

context "make" do
it "should return an unsaved object" do
Post.blueprint { }
Expand All @@ -40,24 +31,6 @@ def fake_a_test
User.make!(:username => "")
}.should raise_error(ActiveRecord::RecordInvalid)
end

it "should buy objects from the shop" do
Post.blueprint { }
post_a, post_b = nil, nil
fake_a_test { post_a = Post.make! }
fake_a_test { post_b = Post.make! }
post_a.should == post_b
end

it "should not buy objects from the shop if caching is disabled" do
Machinist.configuration.cache_objects = false
Post.blueprint { }
post_a, post_b = nil, nil
fake_a_test { post_a = Post.make! }
fake_a_test { post_b = Post.make! }
post_a.should_not == post_b
Machinist.configuration.cache_objects = true
end
end

context "associations support" do
Expand Down
94 changes: 0 additions & 94 deletions spec/shop_spec.rb

This file was deleted.

4 changes: 0 additions & 4 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,3 @@
require 'test/unit'
require 'rspec'
require 'machinist'

Machinist.configure do |config|
config.cache_objects = true
end
24 changes: 0 additions & 24 deletions spec/warehouse_spec.rb

This file was deleted.

0 comments on commit 2839888

Please sign in to comment.