Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding a bare bones spec to get things started

  • Loading branch information...
commit 3f3efcbf5a9a0be52702aa5ef6e49d5e0599abb4 1 parent 8df4a2f
@ryanb authored
View
12 Manifest
@@ -0,0 +1,12 @@
+CHANGELOG
+lib/association_freezer/model_additions.rb
+lib/association_freezer.rb
+LICENSE
+README
+spec/association_freezer/model_additions_spec.rb
+spec/models/order.rb
+spec/models/ship_method.rb
+spec/spec_helper.rb
+tasks/deployment.rake
+tasks/spec.rake
+Manifest
View
1  lib/association_freezer.rb
@@ -1 +1,2 @@
$:.unshift(File.dirname(__FILE__))
+require 'association_freezer/model_additions'
View
10 lib/association_freezer/model_additions.rb
@@ -0,0 +1,10 @@
+module AssociationFreezer
+ module ModelAdditions
+ def enable_association_freezer
+ end
+ end
+end
+
+class ActiveRecord::Base
+ extend AssociationFreezer::ModelAdditions
+end
View
7 spec/association_freezer/model_additions_spec.rb
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/../spec_helper'
+
+describe AssociationFreezer::ModelAdditions do
+ it "should add enable_association_freezer method to model class" do
+ Order.should respond_to(:enable_association_freezer)
+ end
+end
View
16 spec/models/order.rb
@@ -0,0 +1,16 @@
+class Order < ActiveRecord::Base
+ belongs_to :ship_method
+end
+
+class CreateOrders < ActiveRecord::Migration
+ def self.up
+ create_table :orders do |t|
+ t.integer :ship_method_id
+ t.binary :frozen_ship_method
+ end
+ end
+
+ def self.down
+ drop_table :orders
+ end
+end
View
15 spec/models/ship_method.rb
@@ -0,0 +1,15 @@
+class ShipMethod < ActiveRecord::Base
+ has_many :orders
+end
+
+class CreateShipMethods < ActiveRecord::Migration
+ def self.up
+ create_table :ship_methods do |t|
+ t.decimal :price
+ end
+ end
+
+ def self.down
+ drop_table :ship_methods
+ end
+end
View
7 spec/spec_helper.rb
@@ -10,6 +10,13 @@
:dbfile => File.dirname(__FILE__) + "/test.sqlite3"
})
+# load models
+# there's probably a better way to handle this
+require File.dirname(__FILE__) + '/models/order.rb'
+CreateOrders.migrate(:up) unless Order.table_exists?
+require File.dirname(__FILE__) + '/models/ship_method.rb'
+CreateShipMethods.migrate(:up) unless ShipMethod.table_exists?
+
Spec::Runner.configure do |config|
config.mock_with :mocha
end
Please sign in to comment.
Something went wrong with that request. Please try again.