Uh... fixtures?

RSpec-ers:

I’m aware this is quite the FAQ. I have probably asked it myself, but I
just
can’t Google up anything but others asking it.

I grabbed the source to Beast, to use as a Rails project uninfluenced by
me, or
RSpec. Then I installed the CURRENT version of RSpec and rspec_on_rails,
and set
up a model spec on Post.

Here’s the spec_helper.rb lines:

config.use_transactional_fixtures = true
config.use_instantiated_fixtures = false
config.fixture_path = RAILS_ROOT + ‘/test/fixtures/’
# borrow existing ones ^
config.global_fixtures = :posts, :topics, :users

And here’s a Beast test translated into a spec:

describe Post do
fixtures :forums, :moderatorships, :monitorships, :posts, :topics,
:users

it ‘should require body for post’ do
@post = topics(:pdi).posts.build
@post.valid?
assert @post.errors.on(:body)
end
end

And the whiny nil error message hits topics(:pid).

Any ideas?


Phlip

On Feb 17, 2008 9:49 PM, Phlip [email protected] wrote:

it ‘should require body for post’ do
@post = topics(:pdi).posts.build

s/pdi/pid

Funny that the typo should lead you to PDI :slight_smile:

 @post.valid?
 assert @post.errors.on(:body)

end
end

And the whiny nil error message hits topics(:pid).

Any ideas?

s/pdi/pid

Funny that the typo should lead you to PDI :slight_smile:

Oh kewt, but that’s copied live out of a passing Beast test. (You know -
always
clone a working test when branching in a new direction…):

/beast/stable-1.0/test/fixtures$ grep pdi *
monitorships.yml:aaron_pdi:
monitorships.yml:sam_pdi:
posts.yml:pdi:
posts.yml: body: P D I pdi
posts.yml:pdi_reply:
posts.yml: body: what? pdi
posts.yml:pdi_rebuttal:
posts.yml: body: you heard me pdi
topics.yml:pdi:

Go ask the Beastmasters why they want an unpronounceable acronym
there…

(And their conversation suspiciously resembles ours!:wink:


Phlip

Sorry - that’s all I got. Anybody else?

In general, all Rails tests have friction, of various types, because
someone had
the bright idea to make ‘fixtures’ like a directive, instead of just a
method
you can call from setup(). So if anyone knew the function we could call
there…


Venkman

BTW it got better! I guess my hard drive just had to cool off… (-;

On Feb 17, 2008 10:30 PM, Phlip [email protected] wrote:

posts.yml:pdi:
posts.yml: body: P D I pdi
posts.yml:pdi_reply:
posts.yml: body: what? pdi
posts.yml:pdi_rebuttal:
posts.yml: body: you heard me pdi
topics.yml:pdi:

Go ask the Beastmasters why they want an unpronounceable acronym there…

(And their conversation suspiciously resembles ours!:wink:

Sorry - that’s all I got. Anybody else?