phantomjs-gem
phantomjs-gem copied to clipboard
How to stub Phantomjs in Rspec
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.
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.