Displaying 20 results from an estimated 9000 matches similar to: "hash fixture access broken in functional test"
2006 Jan 16
2
My first test - named fixture not autoloading instance variable
I''m trying to write a test like the one at the bottom of page 148 in
Agile Rails.
I''m using rails 1.0
I''ve created the fixture correctly I''m pretty sure because the test
database table is being populated per the fixture.
I have what I think is a simple unit test:
=========
require File.dirname(__FILE__) + ''/../test_helper''
class CaseTest
2006 May 22
1
Agile Web Dev unit test fails with fixture instance variable
I''m following Agile Edition 1. On page 148 it suggests using instance
variables named after the fixture, for example:
assert_equal @version_control_book.id, @product.id
When I introduce this type of instance variable into my test, I get the
following error:
1) Error:
test_not_owner(GroupTest):
RuntimeError: Called id for nil, which would mistakenly be 4 -- if you
really wanted the
2009 Sep 01
13
Function Testing Reloading Fixtures before assertion
Hey Everyone,
I have a function test the is failing (despite the fact the function
actually works in the application). I was looking for some debug
advice on how to find my problem.
Here is the test:
def test_should_delete_word
assert_equal ''published'', words(:one).status
debugger
delete :destroy, :id => words(:one).to_param
assert_equal
2005 Dec 17
10
need some tips for applying patches
I am working with a legacy database that does not always follow the
conventions for table names, primary key and foreign key column names,
and join table names.
This is no problem in my application code because Rails allows me to
override the defaults. However it is making unit testing next to
impossible because fixtures will still try and insert data into the
wrong tables.
Changing the
2005 Dec 31
2
Test Unit Problem
Hello All,
I am experiencing the following test unit error working with Rails that
I can''t fathom.
I have a products.yml file which holds the following test fixture for
the products table:
dell_pc:
id: 1
title: Dell PC
description: Dell PC
image_url: http://.../pc_image.jpg
price: 15000.00
date_available: 2005-12-31 06:53:00
I also have the following product_test.rb file to
2005 Oct 27
2
Fixtures are not loading into instance variables. Why not?
Hi,
I have a fixture in a unit test and I see that the
fixture is loaded correctly into the database table,
but no instance variables are created.
So now I''m stuck.
More background: this is my first RoR project and I
have just installed the SaltedLoginGenerator and
generated its output.
Running the unit tests gives an error, so I cut it
down to just 1 test:
2006 Jun 08
2
accessing fixtures in tests
hi all,
my first attempt at tests and i''m having trouble accessing the
fixture values, if anyone can make it suggestions.
i have news_release_test.rb, using new_releases.yml as the fixture file
according to the agile book, i should be able to access the fixture
properties within my test as such:
assert_equal @first_test.id , @news_release.id
unfortunately, i try that and get:
2006 May 23
2
Putting fixtures into subdirectories
I want to organize my fixtures just like the namespace of my models. So
for example if I have a model Company::Employee I''d like the fixture to
be in fixtures/company/employees.yml.
However, I can''t figure out how to specify the path of the fixture file.
If I do:
fixtures :employees
in my unit test it can''t find the fixture file. Any suggestions?
Thanks,
Todd
2006 Jun 08
1
fixtures instance variable naming
hi all,
trying my first foray into testing and having trouble with accessing
the fixture instance variable
built a test for my NewsRelease model.
have a news_releases.yml as a fixture with:
first:
id: 1
title: my first release
body: this is still my first test of a news release
publish: 0
date_publication: 2006-06-06 17:28:00
in news_release_test.rb, i have
def setup
2006 May 08
8
enforcing special behavior of child rows in HABTM
Hi,
I have a scenario where a doctor can have one or more specialties.
For each doctor, one and only one of her specialties can be designated
as primary.
So I have tables called doctors, specialties, and doctors_specialties,
the last of which has a boolean is_primary column.
The doctor model class specifies that:
has_and_belongs_to_many :specialties
I want to enforce, at the lowest possible
2005 Dec 29
14
Rails 1.0 - Agile book still good?
I''m new to Ruby and RoR but excited to learn what I can do with RoR; I
have Pickaxe second edition and want to get "Agile Web Development with
Rails" but I''m aware that the book was published some while before RoR
version 1.0 was released. Has a lot changed since then, and would I
therefore be advised to wait for a second edition of AWDwR?
Many thanks in advance
2007 Feb 28
2
Fixture name not available as class variable in spec
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
2006 Jan 03
3
Rails Noob Question
Apparently the first time I posted this, it was tacked onto the end of
another thread. Please pardon my repost. Won''t happen again.
--------
Howdy. I''m just getting into Rails, and really enjoying it! I''m coming
from the .NET world, so I''ll embarrassedly admit that I''m running it on
winXP and even using SQLServer (for now, may switch to mysql
2006 Apr 21
2
NoMethodError with test_read_with_hash
While running the product_test.rb test fixture in the Agile Web
Development book (p. 148), but when I run
ruby test/unit/product_test.rb, I get the following error:
1) Error:
test_read_with_hash(ProductTest):
NoMethodError: You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.[]
2005 Dec 23
6
Agile book - test error
Hi all,
I get an error when testing the "store_controller_test.rb"
The troublesome line is in the test below:
def test_add_to_cart
get :add_to_cart, :id => @version_control_book.id <<<
cart = session[:cart]
assert_equal @version_control_book.price, cart.total_price
assert_redirected_to :action => ''display_cart''
follow_redirect
2006 Dec 14
1
create and destroy fixture manually in method
Hi,
My test case has two fixtures and eight methods. But one of the eight
methods need one more fixture. How do I solve this? Okay, I put the
additional fixture in common place so every method has additional access
to the additional fixture. The problem is the additional fixture depend
on that two fixtures (foreign key). When I run the test, it complains
something like this:
2005 Oct 28
2
Accessing fixture
I have a very simple problem. I can''t seem to access
a the fixture by name
I have a sites.yml with:
simple_site:
id: 1
name: demo
description: A demo site
created_on: 2005-10-25 00:00:00
updated_on: 2005-10-25 00:00:00
And I have a test class as:
require File.dirname(__FILE__) + ''/../test_helper''
class SiteTest < Test::Unit::TestCase
fixtures
2006 Apr 28
2
Accessing fixtures from unit tests
I have set up some fixtures in test/fixtures/users.xml:
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
admin:
id: 1
username: admin
password: admin
pbarry:
id: 2
username: pbarry
I have a unit test for my user model:
require File.dirname(__FILE__) + ''/../test_helper''
class UserTest < Test::Unit::TestCase
fixtures :users
def
2006 Apr 26
3
Test fixture syntax
OK, I know I''m doing something bone-headed, but I can''t for the life of
me figure it out.
I''ve read the test fixtures Rdoc about eight dozen times, and it says
(to me) that if I have a YAML fixture file, dogs.yml that looks like
this:
fido:
id: 1
breed: Terrier
fifi:
id: 2
breed: Poodle
Then I can include
fixtures :dogs
in my functional test, and
2006 May 26
4
Using ''validates_inclusion_of'' to validate foreign key
I seem to be missing something trying to use ''validates_inclusion_of'' to
validate a foreign key and was hoping some one could piont out my
mistake?
The problem seems to be that Order.find_all.collect is not returning an
array that contains the order_id, if I replace it with a hardcoded array
everything works as expected.
The model:
class OrderItem < ActiveRecord::Base