[rspec-users] Fixture name not available as class variable in spec

Keith McDonnell keith at dancingtext.com
Fri Mar 2 06:02:46 EST 2007


Hi Graham,

Thanks for the reply. Yes, I did have the fixtures method included in 
the contexts.

I've recently upgraded to the latest spec, rails plugin & rails which 
could be an issue.

I'd prefer not to have to instantiate the fixture variables in the 
setup. It was cleaner & more efficient when they were picked up from the 
fixtures directly.

Regards,

Keith

> Message: 2
> Date: Wed, 28 Feb 2007 08:48:43 -0800
> From: Graeme Nelson <graeme.nelson at gmail.com>
> Subject: Re: [rspec-users] Fixture name not available as class
> 	variable in	spec
> To: rspec-users <rspec-users at rubyforge.org>
> Message-ID: <9BA49959-AF93-44F3-8F82-E001B04F8D4F at gmail.com>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
> 
> Hello Keith -
> 
> You can get access to your fixtures like so:
> 
> context "Some content" do
> 
> 	fixtures :users
> 
> 	setup do
> 	end
> 
> 	specify "some specification" do
> 	end
> end
> 
> Thanks
> graeme
> 
> On Feb 28, 2007, at 7:22 AM, Keith McDonnell wrote:
> 
>> Hi there,
>>
>> I can't seem to access the fixture name as a class variable from my
>> specs. I have to set the variable in the spec setup.
>>
>> ... [fixtures]
>>
>> my_fixture:
>>    id: 1
>>
>> ... [rpsec]
>>
>> @my_fixture.id.should == 1
>>
>> ... [error]
>>
>> You have a nil object when you didn't expect it!
>> The error occurred while evaluating nil.id
>>
>> ... [my setup]
>>
>> RSpec-0.7.5.1 (r1395) - BDD for Ruby
>> Rails 1.2.2
>> Latest rspec_on_rails plugin
>>
>> Is this this a bug or a feature ?
>>
>> Keith
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
> 
> 
> 
> ------------------------------
> 
> Message: 3
> Date: Wed, 28 Feb 2007 17:26:46 +0000
> From: Ashley Moran <work at ashleymoran.me.uk>
> Subject: [rspec-users] Specifying that code is called in a block
> To: rspec-users <rspec-users at rubyforge.org>
> Message-ID: <C91A4E31-BCB5-4EB9-BD42-7852524B9A04 at ashleymoran.me.uk>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
> 
> Not sure if this is possible currently.
> 
> I have a section of code like this:
> 
>    ActiveRecord::Base.transaction do
>      cow.save!
>      duck.save!
>      dog.save!
>    end
> 
> (Names changed to protect the innocent.)
> 
> I'd like to specify that the saves run in a transaction.  I can do
> 
>    ActiveRecord::Base.should_receive(:transaction).and_yield
> 
> But is there any way to specify that the code is called as above, and  
> not as
> 
>    cow.save!
>    ActiveRecord::Base.transaction do
>      duck.save!
>    end
>    dog.save!
> 
> ?
> 
> Ta
> Ashley
> 
> 
> ------------------------------
> 
> Message: 4
> Date: Wed, 28 Feb 2007 05:50:44 -0800 (PST)
> From: gmcinnes <grant.mcinnes at utoronto.ca>
> Subject: Re: [rspec-users] drbspec - "no server running"
> To: rspec-users at rubyforge.org
> Message-ID: <9204085.post at talk.nabble.com>
> Content-Type: text/plain; charset=us-ascii
> 
> 
> Hi:  I can't find the bug report.  Maybe you didn't make it yet.
> 
> I solved this by adding my machine name to /etc/localhosts - i.e. my
> computer is called morgan, and I added:
> 
> 
> 127.0.0.1                      morgan
> 
> 
> to that file.
> 
> 
> It seems os x  fancypants name lookup system doesn't resolve the machine
> name when making a gethostbyaddr(host)[0] call unless the machine name is in
> localhost.  Seems to be a drb problem though.
> 
> 
> 
> aslak hellesoy wrote:
>> On 2/26/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote:
>>> On Feb 26, 2007, at 12:41 AM, aslak hellesoy wrote:
>>>
>>>> On 2/26/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote:
>>>>> I've created a little 30 second screen cast to show the problem:
>>>>>
>>>> Hey, that's a neat bug report format!
>>>>
>>> Well, there is nothing quite like sitting in a room with someone to
>>> watch them reproduce the bug; words can be vague.  I suppose that
>>> this is the closest I'll get to that ideal bug report...(at least
>>> over the internet).  Plus, I've been looking to put that $70 that
>>> I've spent on screencasting software to work.
>>>
>>> I have my project svn'ed, with an externals on the rspec and
>>> rspec_on_rails repositories.  I'm at revision 1536 - Is this correct
>>> for RC1?  Do I also need to update the gem?
>>>
>> Yes - like it's described on the announcement I linked to.
>>
>>> Best,
>>>
>>> Scott
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>> Please try to uninstall your current RSpec release and install 0.8 RC1
>>>> release - I think your problem will be gone.
>>>>
>>>> http://www.nabble.com/-ANN--RSpec-0.8.0-RC1-t3245509.html
>>>>
>>>> In 0.8 you have to say spec --drb instead of drbspec (see the
>>>> release notes)
>>>>
>>>> Also, for the future, please remember to tell us what versions of
>>>> OS/Ruby/RSpec/Rails you're running. (ok, I could see you have a mac
>>>> :-)
>>>>
>>>> HTH,
>>>> Aslak
>>>>
>>>>> http://railsnewbie.com/files/screencasts/rspec_on_rails-
>>>>> no_server_running.mov
>>>>>
>>>>> All I did before this, as I've said in the previous email, was
>>>>> generate a controller with:
>>>>>
>>>>> ./script/generate rspec_controller -c CollectiveDictionary index show
>>>>>
>>>>> Best,
>>>>>
>>>>> Scott
>>>>>
>>>>>
>>>>> On Feb 25, 2007, at 9:22 PM, Scott Taylor wrote:
>>>>>
>>>>>> At times I've gotten the message "No Server Running" from drbspec
>>>>>> with my rails app.  The thing is, the drb server certainly is
>>>>>> running!
>>>>>>
>>>>>> This happened a few times with my model specs.  I'm not sure exactly
>>>>>> what the problem was there - I believe I was loading up fixtures
>>>>>> that
>>>>>> didn't exist.  I was calling fixtures :singular_table_name as
>>>>>> opposed
>>>>>> to fixtures :plural_table_name
>>>>>>
>>>>>> This time it happened with my controller.  I generated the
>>>>>> controller
>>>>>> with the ./script/generate rspec_controller ControllerName
>>>>>> command...
>>>>>>
>>>>>> It doesn't appear that the specs are setup to fail to begin with,
>>>>>> but
>>>>>> if this were the default behavior, one certainly shouldn't see a "No
>>>>>> Server Running"
>>>>>>
>>>>>> I could create a short screen cast if someone would like me to, or
>>>>>> elaborate...
>>>>>>
>>>>>> Best,
>>>>>>
>>>>>> Scott Taylor
>>>>>>
>>>>>> _______________________________________________
>>>>>> rspec-users mailing list
>>>>>> rspec-users at rubyforge.org
>>>>>> http://rubyforge.org/mailman/listinfo/rspec-users
>>>>> _______________________________________________
>>>>> rspec-users mailing list
>>>>> rspec-users at rubyforge.org
>>>>> http://rubyforge.org/mailman/listinfo/rspec-users
>>>>>
>>>> _______________________________________________
>>>> rspec-users mailing list
>>>> rspec-users at rubyforge.org
>>>> http://rubyforge.org/mailman/listinfo/rspec-users
>>> _______________________________________________
>>> rspec-users mailing list
>>> rspec-users at rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/rspec-users
>>>
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>>
>>
> 


More information about the rspec-users mailing list