spec/ramesh/image_spec.rb in ramesh-1.3.0 vs spec/ramesh/image_spec.rb in ramesh-1.4.0

- old
+ new

@@ -1,80 +1,63 @@ require "spec_helper" require "fileutils" module Ramesh describe Image do - let(:image_name) do - "201405091845" - end + let(:image_name) { "201405091845" } + let(:filename) { "201405091845.jpg" } + let(:tmpdir) { File.expand_path(File.join("..", "..", "tmp"), __FILE__) } - let(:filename) do - "201405091845.jpg" - end - - let(:tmpdir) do - File.expand_path(File.join("..", "..", "tmp"), __FILE__) - end - let(:mesh_url) do "http://tokyo-ame.jwa.or.jp/mesh/000/#{image_name}.gif" end + let(:mesh_url_large) do + "http://tokyo-ame.jwa.or.jp/mesh/100/#{image_name}.gif" + end + let(:background_url) do "http://tokyo-ame.jwa.or.jp/map/map000.jpg" end + let(:background_url_large) do + "http://tokyo-ame.jwa.or.jp/map/map100.jpg" + end + let(:mask_url) do "http://tokyo-ame.jwa.or.jp/map/msk000.png" end + let(:mask_url_large) do + "http://tokyo-ame.jwa.or.jp/map/msk100.png" + end + let(:fixture_image) do open(fixture_path("lena.png")).read end before do stub_request(:get, mesh_url) .to_return(status: 200, body: fixture_image) + stub_request(:get, mesh_url_large) + .to_return(status: 200, body: fixture_image) stub_request(:get, background_url) .to_return(status: 200, body: fixture_image) + stub_request(:get, background_url_large) + .to_return(status: 200, body: fixture_image) stub_request(:get, mask_url) .to_return(status: 200, body: fixture_image) + stub_request(:get, mask_url_large) + .to_return(status: 200, body: fixture_image) end - describe "#background_image" do - it "should download the background image" do - described_class.background_image - expect(a_request(:get, background_url)).to have_been_made.once - end - end - - describe "#mask_image" do - it "should download the mask image" do - described_class.mask_image - expect(a_request(:get, mask_url)).to have_been_made.once - end - end - describe "#initialize" do context "without cached images" do it "should composite the moment image" do described_class.new(image_name) expect(a_request(:get, mesh_url)).to have_been_made.once expect(a_request(:get, background_url)).to have_been_made.once expect(a_request(:get, mask_url)).to have_been_made.once - end - end - - context "with cached images" do - it "should composite the moment image" do - image = double(composite: true) - background_image = double(composite: image) - mask_image = double(composite: image) - - described_class.new(image_name, background_image, mask_image) - expect(a_request(:get, mesh_url)).to have_been_made.once - expect(a_request(:get, background_url)).not_to have_been_made - expect(a_request(:get, mask_url)).not_to have_been_made end end end describe "#save" do