Hello--
I'm not sure if I'm pushing too far out of specing a given model, but
here's what I want to express:
class A < AR::Base
has_many :bs
def okay(segment)
end
end
class B < AR::Base
belongs_to :a
end
it A, "should increase the vote count for a given segment if okayed" do
@a = A.create(stuff)
@a.okay(10) # okay segment 10
# here's where I'm having trouble...
# a.bs should have one row, and it should have a segment number of
10 and various other stuff should happen
# subsequent @a.okay with different values should transform numbers
in a predictable way. This is handled in
# the A model because the transforms occur only in Bs that belong
to a given A.
@a.bs.find_by_segment_number(10).thingie.should be(1) # not too
expressive
@a.okay(9)
@a.bs.find_by_segment_number(9).thingie.should be(1) # still not
too expressive
@a.bs. find_by_segment_number(9).transformed_thingie.should
be(something_else)
end
This kind of spec smells to me, yet I am having trouble figuring out
how to explain, using rspec, exactly what the behavior is to be in a
multi-step sequence.
Anybody have thoughts regarding how this might be done better?
Thanks
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users