Sha256: 88fdcdb87d0e048526bb80b1284bc1ad724f425c95e4c564210514ff58155b65
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
require 'spec_helper' describe WordsToImage::Flickr do describe ".fetch" do context "image found" do before do photo_info = {id: 123, server: 456, title: "Pure beauty"} allow(flickr.photos).to receive("search").and_return([photo_info]) allow(FlickRaw).to receive("url_q").with(OpenStruct).and_return("http://image_url") end it "should fetch an image using flickr API" do expect(WordsToImage::Flickr.fetch("weihnachten")).to eq "http://image_url" end end context "nothing found" do before do allow(flickr.photos).to receive("search").and_return([]) end it "should return nil if nothing fetched" do expect(WordsToImage::Flickr.fetch("weihnachten")).to be_nil end end context "fetch is impossible" do before do allow(flickr.photos).to receive("search").and_raise(StandardError, "no internet") end it "should raise an error" do expect{WordsToImage::Flickr.fetch("weihnachten")}.to raise_error(RuntimeError, "problem connecting to flickr API: no internet") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
words_to_image-0.0.3 | spec/words_to_image/flickr_spec.rb |
words_to_image-0.0.2 | spec/words_to_image/flickr_spec.rb |