[rspec-users] How can I spec this? The method gets passed a block...
aslak.hellesoy at gmail.com
Sat Feb 24 06:48:28 EST 2007
On 2/23/07, Pat Maddox <pergesu at gmail.com> wrote:
> I'm using Jim Weirich's Builder library. The code I want to spec is
> xml.video do
> xml.id @video_id
> xml.views @views
> xml.date(@date.to_s) if @date
> I'd like to mock it, rather than asserting that the XML is the right
> string. I can do one spec:
> specify "should create a video tag" do
> but I can't do anything else. Setting an expectation for :id, :views,
> and :date all fail. It's obvious to me why it does...the stubbed
> :video method doesn't know to execute the stuff in the block. So
> what's the best way to spec this?
There is no "best" way to do anything, but in this case I think I
would avoid mocking the API I don't own (builder).
I would mock the objects that builder *interacts* with, kick of
builder and expect the generated XML to eql some expected XML.
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users