phantomjs-gem icon indicating copy to clipboard operation
phantomjs-gem copied to clipboard

How to stub Phantomjs in Rspec

Open snoblenet opened this issue 10 years ago • 1 comments

I'm using Phantomjs to generate Google Charts and convert them to SVG on the server side.

I'm trying to stub this like this:

Phantomjs.stub(:run).and_return("<svg></svg>".html_safe)

But I get:

undefined method `stub' for Phantomjs:Module

Your thoughts?

Thanks,

Steven.

snoblenet avatar Nov 10 '14 23:11 snoblenet

From your syntax, you seem to be using RSpec. RSpec 2 defines the stub method on BasicObject. Phantomjs is definitely a BasicObject, so I don't think this is specific. Try stubbing a method of BasicObject. It will probably fails which means your setup of rspec-mocks is insufficient.

cschramm avatar Nov 11 '14 07:11 cschramm