spec/lib/onebox/helpers_spec.rb in onebox-1.7.5 vs spec/lib/onebox/helpers_spec.rb in onebox-1.7.6

- old
+ new

@@ -22,6 +22,24 @@ it { expect(described_class.truncate(test_string,9)).to eq("Chops off...") } it { expect(described_class.truncate(test_string,10)).to eq("Chops off...") } it { expect(described_class.truncate(test_string,100)).to eq("Chops off on spaces") } it { expect(described_class.truncate(" #{test_string} ",6)).to eq(" Chops...") } end -end \ No newline at end of file + + describe "fetch_response" do + after(:each) do + Onebox.options = Onebox::DEFAULTS + end + + before do + Onebox.options = { max_download_kb: 1 } + fake("http://example.com/large-file", response("slides")) + end + + it "raises an exception when responses are larger than our limit" do + expect { + described_class.fetch_response('http://example.com/large-file') + }.to raise_error(Onebox::Helpers::DownloadTooLarge) + end + end + +end