[rspec-users] describing a mock_model as being an instance

Courtenay court3nay at gmail.com
Mon Aug 20 01:00:08 EDT 2007


On 8/19/07, Edward Ocampo-Gooding <edward.og at gmail.com> wrote:
> David Chelimsky wrote:
> > On 8/19/07, Edward Ocampo-Gooding <edward.og at gmail.com> wrote:
> >> Is there a built-in way of describing a mock_model as being an instance, beyond
> >> stubbing the eval("Object.methods - Object.new.methods") methods to throw
> >> NoMethodErrors?
> >
> > Huh? Can you give an example of what you are trying to achieve?
>
> I'm writing a method that involves deciding if an object is a class or an
> instance of a class. Right now I'm creating a mock_model and setting up an
> expectation on respond_to? :new but I've got a feeling that this isn't the way
> to go.
>
> The current mock_model returns an object that looks more like a class based on
> the methods it has (I should actually go look now and check if it's got the
> typical instantiated Object methods too...), and I'm wondering if there's a
> clean way of creating a mock_model instance that has typical instantiated Object
> methods and no Object class methods.
>
> Edward
>
>

Is there a reason it needs to be more complicated than this?

class Foo
end

Foo.is_a?(Class)
=> true

Foo.new.is_a?(Class)
=> false


More information about the rspec-users mailing list