diff options
author | rick <technoweenie@gmail.com> | 2008-06-27 23:29:03 -0700 |
---|---|---|
committer | rick <technoweenie@gmail.com> | 2008-06-27 23:29:03 -0700 |
commit | 7fc628e3fcda6342a8cee0a6236987b57ac10270 (patch) | |
tree | 45f8566b44533a6a7bbd5bc305144711c60df753 /activemodel/spec | |
parent | 10c581a6deed66e8b62de6e7a3621a63de90baad (diff) | |
download | rails-7fc628e3fcda6342a8cee0a6236987b57ac10270.tar.gz rails-7fc628e3fcda6342a8cee0a6236987b57ac10270.tar.bz2 rails-7fc628e3fcda6342a8cee0a6236987b57ac10270.zip |
convert specs to tests
Diffstat (limited to 'activemodel/spec')
-rw-r--r-- | activemodel/spec/observing_spec.rb | 120 | ||||
-rw-r--r-- | activemodel/spec/spec_helper.rb | 17 |
2 files changed, 0 insertions, 137 deletions
diff --git a/activemodel/spec/observing_spec.rb b/activemodel/spec/observing_spec.rb deleted file mode 100644 index 1919bb5991..0000000000 --- a/activemodel/spec/observing_spec.rb +++ /dev/null @@ -1,120 +0,0 @@ -require File.join(File.dirname(__FILE__), 'spec_helper') - -class ObservedModel < ActiveModel::Base - class Observer - end -end - -class FooObserver < ActiveModel::Observer - class << self - public :new - end - - attr_accessor :stub - - def on_spec(record) - stub.event_with(record) if stub - end -end - -class Foo < ActiveModel::Base -end - -module ActiveModel - describe Observing do - before do - ObservedModel.observers.clear - end - - it "initializes model with no cached observers" do - ObservedModel.observers.should be_empty - end - - it "stores cached observers in an array" do - ObservedModel.observers << :foo - ObservedModel.observers.should include(:foo) - end - - it "flattens array of assigned cached observers" do - ObservedModel.observers = [[:foo], :bar] - ObservedModel.observers.should include(:foo) - ObservedModel.observers.should include(:bar) - end - - it "instantiates observer names passed as strings" do - ObservedModel.observers << 'foo_observer' - FooObserver.should_receive(:instance) - ObservedModel.instantiate_observers - end - - it "instantiates observer names passed as symbols" do - ObservedModel.observers << :foo_observer - FooObserver.should_receive(:instance) - ObservedModel.instantiate_observers - end - - it "instantiates observer classes" do - ObservedModel.observers << ObservedModel::Observer - ObservedModel::Observer.should_receive(:instance) - ObservedModel.instantiate_observers - end - - it "should pass observers to subclasses" do - FooObserver.instance - bar = Class.new(Foo) - bar.count_observers.should == 1 - end - end - - describe Observer do - before do - ObservedModel.observers = :foo_observer - FooObserver.models = nil - end - - it "guesses implicit observable model name" do - FooObserver.observed_class_name.should == 'Foo' - end - - it "tracks implicit observable models" do - instance = FooObserver.new - instance.send(:observed_classes).should include(Foo) - instance.send(:observed_classes).should_not include(ObservedModel) - end - - it "tracks explicit observed model class" do - FooObserver.new.send(:observed_classes).should_not include(ObservedModel) - FooObserver.observe ObservedModel - instance = FooObserver.new - instance.send(:observed_classes).should include(ObservedModel) - end - - it "tracks explicit observed model as string" do - FooObserver.new.send(:observed_classes).should_not include(ObservedModel) - FooObserver.observe 'observed_model' - instance = FooObserver.new - instance.send(:observed_classes).should include(ObservedModel) - end - - it "tracks explicit observed model as symbol" do - FooObserver.new.send(:observed_classes).should_not include(ObservedModel) - FooObserver.observe :observed_model - instance = FooObserver.new - instance.send(:observed_classes).should include(ObservedModel) - end - - it "calls existing observer event" do - foo = Foo.new - FooObserver.instance.stub = stub!(:stub) - FooObserver.instance.stub.should_receive(:event_with).with(foo) - Foo.send(:changed) - Foo.send(:notify_observers, :on_spec, foo) - end - - it "skips nonexistent observer event" do - foo = Foo.new - Foo.send(:changed) - Foo.send(:notify_observers, :whatever, foo) - end - end -end
\ No newline at end of file diff --git a/activemodel/spec/spec_helper.rb b/activemodel/spec/spec_helper.rb deleted file mode 100644 index 004fdfca07..0000000000 --- a/activemodel/spec/spec_helper.rb +++ /dev/null @@ -1,17 +0,0 @@ -ENV['LOG_NAME'] = 'spec' -$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'vendor', 'rspec', 'lib') -$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib') -require 'active_model' -begin - require 'spec' -rescue LoadError - require 'rubygems' - require 'spec' -end - -begin - require 'ruby-debug' - Debugger.start -rescue LoadError - # you do not know the ways of ruby-debug yet, what a shame -end
\ No newline at end of file |