Next step in upgrading Tracks to Rails 2.2. Some highlights:

* Ran rake rails:update
* Added old actionwebservice framework
* Updated RSpec and RSpec-Rails
* Removed asset_packager plugin (not compatible, Scott no longer maintaining), and replaced with bundle_fu. See the bundle_fu README for more info.
* Hacks to UJS and ARTS plugins, which are no longer supported. Probably should move off both UJS and RJS.
* Hack to flashobject_helper plugin (upgrade to Rails 2.2-compatible version if/when it comes out.)
* Hack to skinny-spec plugin, for Rails 2.2 compatibility. Should check for official release.
* Hacks to resource_feeder plugin, for Rails 2.2 compatibility. Should check for official release (not likely) or move off it.
* Addressed some deprecation warnings. More to come.
* My mobile mime type hackery is no longer necessary with new Rails features. Yay!
* Updated environment.rb.tmpl with changes

TODO:
* Restore view specs marked pending
* Fix failing integration tests.
* Try selenium tests.
* Investigate OpenID support.
* Address deprecation warnings.
* Consider moving parts of environment.rb to initializers
* Address annoying config.gem warning about highline gem
This commit is contained in:
Luke Melia 2008-11-29 12:00:06 -05:00
parent 6d11ebd1b0
commit 35ae5fc431
394 changed files with 15184 additions and 9936 deletions

View file

@ -2,63 +2,105 @@ require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/ar_classes'
describe "mock_model" do
before(:each) do
@model = mock_model(SubMockableModel)
describe "responding to interrogation" do
before(:each) do
@model = mock_model(SubMockableModel)
end
it "should say it is_a? if it is" do
@model.is_a?(SubMockableModel).should be(true)
end
it "should say it is_a? if it's ancestor is" do
@model.is_a?(MockableModel).should be(true)
end
it "should say it is kind_of? if it is" do
@model.kind_of?(SubMockableModel).should be(true)
end
it "should say it is kind_of? if it's ancestor is" do
@model.kind_of?(MockableModel).should be(true)
end
it "should say it is instance_of? if it is" do
@model.instance_of?(SubMockableModel).should be(true)
end
it "should not say it instance_of? if it isn't, even if it's ancestor is" do
@model.instance_of?(MockableModel).should be(false)
end
end
it "should say it is_a? if it is" do
@model.is_a?(SubMockableModel).should be(true)
describe "with params" do
it "should not mutate its parameters" do
params = {:a => 'b'}
model = mock_model(MockableModel, params)
params.should == {:a => 'b'}
end
end
it "should say it is_a? if it's ancestor is" do
@model.is_a?(MockableModel).should be(true)
describe "with #id stubbed", :type => :view do
before(:each) do
@model = mock_model(MockableModel, :id => 1)
end
it "should be named using the stubbed id value" do
@model.instance_variable_get(:@name).should == "MockableModel_1"
end
it "should return string of id value for to_param" do
@model.to_param.should == "1"
end
end
it "should say it is kind_of? if it is" do
@model.kind_of?(SubMockableModel).should be(true)
describe "as association", :type => :view do
before(:each) do
@real = AssociatedModel.create!
@mock_model = mock_model(MockableModel)
@real.mockable_model = @mock_model
end
it "should pass associated_model == mock" do
@mock_model.should == @real.mockable_model
end
it "should pass mock == associated_model" do
@real.mockable_model.should == @mock_model
end
end
it "should say it is kind_of? if it's ancestor is" do
@model.kind_of?(MockableModel).should be(true)
describe "with :null_object => true", :type => :view do
before(:each) do
@model = mock_model(MockableModel, :null_object => true, :mocked_method => "mocked")
end
it "should be able to mock methods" do
@model.mocked_method.should == "mocked"
end
it "should return itself to unmocked methods" do
@model.unmocked_method.should equal(@model)
end
end
it "should say it is instance_of? if it is" do
@model.instance_of?(SubMockableModel).should be(true)
describe "#as_null_object", :type => :view do
before(:each) do
@model = mock_model(MockableModel, :mocked_method => "mocked").as_null_object
end
it "should be able to mock methods" do
@model.mocked_method.should == "mocked"
end
it "should return itself to unmocked methods" do
@model.unmocked_method.should equal(@model)
end
end
it "should not say it instance_of? if it isn't, even if it's ancestor is" do
@model.instance_of?(MockableModel).should be(false)
describe "#as_new_record" do
it "should say it is a new record" do
mock_model(MockableModel).as_new_record.should be_new_record
end
it "should have a nil id" do
mock_model(MockableModel).as_new_record.id.should be(nil)
end
it "should return nil for #to_param" do
mock_model(MockableModel).as_new_record.to_param.should be(nil)
end
end
end
describe "mock_model with stubbed id", :type => :view do
before(:each) do
@model = mock_model(MockableModel, :id => 1)
end
it "should be named using the stubbed id value" do
@model.instance_variable_get(:@name).should == "MockableModel_1"
end
end
describe "mock_model with null_object", :type => :view do
before(:each) do
@model = mock_model(MockableModel, :null_object => true, :mocked_method => "mocked")
end
it "should be able to mock methods" do
@model.mocked_method.should == "mocked"
end
it "should return itself to unmocked methods" do
@model.unmocked_method.should equal(@model)
end
end
describe "mock_model as association", :type => :view do
before(:each) do
@real = AssociatedModel.create!
@mock_model = mock_model(MockableModel)
@real.mockable_model = @mock_model
end
it "should pass associated_model == mock" do
@mock_model.should == @real.mockable_model
end
it "should pass mock == associated_model" do
@real.mockable_model.should == @mock_model
end
end

View file

@ -51,29 +51,30 @@ describe "stub_model" do
second.id.should == (first.id + 1)
end
end
describe "stub_model as association" do
before(:each) do
@real = AssociatedModel.create!
@stub_model = stub_model(MockableModel)
@real.mockable_model = @stub_model
end
it "should pass associated_model == mock" do
@stub_model.should == @real.mockable_model
end
it "should pass mock == associated_model" do
@real.mockable_model.should == @stub_model
end
end
describe "stub_model with a block" do
it "should yield the model" do
model = stub_model(MockableModel) do |block_arg|
@block_arg = block_arg
describe "as association" do
before(:each) do
@real = AssociatedModel.create!
@stub_model = stub_model(MockableModel)
@real.mockable_model = @stub_model
end
it "should pass associated_model == mock" do
@stub_model.should == @real.mockable_model
end
it "should pass mock == associated_model" do
@real.mockable_model.should == @stub_model
end
end
describe "with a block" do
it "should yield the model" do
model = stub_model(MockableModel) do |block_arg|
@block_arg = block_arg
end
model.should be(@block_arg)
end
model.should be(@block_arg)
end
end