[rspec-users] Using mocks
barjunk at attglobal.net
Wed May 30 20:44:25 EDT 2007
> Message: 11
> Date: Wed, 30 May 2007 19:45:58 -0400
> From: "David Chelimsky" <dchelimsky at gmail.com>
> Subject: Re: [rspec-users] Using mocks
> To: rspec-users <rspec-users at rubyforge.org>
> <57c63afe0705301645y15868ecqb8e65803529a3a5e at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> On 5/30/07, barsalou <barjunk at attglobal.net> wrote:
>> I've just started doing TDD/BDD and like the idea of mocks. So I set
>> out to use them. The doc pages seem great, I setup the mock and then
>> it just works. Here is what I am trying to do:
>> Myuser is a non-rails model of user attributes. We are going to be
>> mocking the connection to the ldap server. The user class has a login
>> method that connects to the ldap server and if successful, returns the
>> user object. For now though, I'd be happy for it to return the true
>> I'm writing this message cause it doesn't work for me, but I'm sure it
>> is because I am not doing something right...but unsure what exactly
>> that is.
>> describe Myuser do
>> before(:each) do
>> my_mock = mock(:some_name)
> These need to be instance variables:
> describe Myuser do
> before(:each) do
> @my_mock = mock(:some_name)
> it "should be logged in" do
> See if that works.
That worked for me just fine. What do I need to do to change the
examples page to include an example of the usage of the created mock as
well as mention that those mocks should be instance variables?
I'm assuming they have to be instance variables because they go out of
scope at the end of before_each?
Thanks for the help.
This message was sent using IMP, the Internet Messaging Program.
More information about the rspec-users