Skip to content

Commit

Permalink
spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
justinko committed May 30, 2011
1 parent 4ac10d8 commit 09b76dc
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions spec/rspec/rails/mocks/mock_model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,11 @@
before(:each) do
@model = mock_model(SubMockableModel)
end

it "says it is_a?(RealModel)" do
@model.is_a?(SubMockableModel).should be(true)
end

it "says it is_a?(OtherModel) if RealModel is an ancestors" do
@model.is_a?(MockableModel).should be(true)
end
Expand All @@ -118,9 +120,11 @@
before(:each) do
@model = mock_model(SubMockableModel)
end

it "says it is kind_of? if RealModel is" do
@model.kind_of?(SubMockableModel).should be(true)
end

it "says it is kind_of? if RealModel's ancestor is" do
@model.kind_of?(MockableModel).should be(true)
end
Expand All @@ -130,9 +134,11 @@
before(:each) do
@model = mock_model(SubMockableModel)
end

it "says it is instance_of? if RealModel is" do
@model.instance_of?(SubMockableModel).should be(true)
end

it "does not say it instance_of? if RealModel isn't, even if it's ancestor is" do
@model.instance_of?(MockableModel).should be(false)
end
Expand Down Expand Up @@ -162,6 +168,7 @@
@model.respond_to?("title_before_type_cast").should be(false)
end
end

context "with as_null_object" do
it "says it will respond_to?(key) if RealModel has the attribute 'key'" do
@model.as_null_object.respond_to?("column_a").should be(true)
Expand All @@ -180,6 +187,7 @@
model = NonActiveRecordModel.new
model.should respond_to(:to_param)
end

context "with as_null_object" do
it "says it will not respond_to?(xxx_before_type_cast)" do
model = NonActiveRecordModel.new.as_null_object
Expand All @@ -194,9 +202,11 @@
@param = to_param
@model = mock_model(MockableModel)
end

it "returns class name underscore rspec context id" do
@model.to_s.should == "MockableModel_#{@param}"
end

context "stubbed to return 'foobar'" do
it "returns 'foobar'" do
mock_model(MockableModel, :to_s => 'foobar').to_s.should == 'foobar'
Expand Down Expand Up @@ -248,6 +258,7 @@
mock_model(MockableModel).should be_valid
end
end

context "stubbed with false" do
it "returns false" do
mock_model(MockableModel, :valid? => false).should_not be_valid
Expand Down

0 comments on commit 09b76dc

Please sign in to comment.