spec/shutterbug/rackapp_spec.rb in shutterbug-0.2.5 vs spec/shutterbug/rackapp_spec.rb in shutterbug-0.4.3
- old
+ new
@@ -14,12 +14,10 @@
end
describe Shutterbug::Rackapp do
include Rack::Test::Methods
- let(:config) { Shutterbug::Configuration.instance }
-
let(:post_data) do
{
'content' => "<div class='foo'>foo!</div>",
'width' => 1000,
'height' => 700,
@@ -27,68 +25,56 @@
'base_url' => "http://localhost:8080/"
}
end
let(:app) do
- Shutterbug::Rackapp.new do |config|
- config.uri_prefix = "http://localhost:9292"
- config.path_prefix = "/shutterbug"
+ Shutterbug::Rackapp.new do |config|
+ config.uri_prefix = "http://localhost:9292"
+ config.path_prefix = "/shutterbug"
end
end
- let(:filename) { "filename" }
- let(:url) { "url_to_file" }
+ let(:filename) { "filename" }
+ let(:url) { "url_to_file" }
- let(:mock_file) do
+ let(:mock_file) do
mock({
:get_content => "content",
+ :mime_type => "image/png",
:filename => filename,
:url => url
})
end
- let(:test_storage) { mock({ :new => mock_file })}
+ let(:test_storage) { mock({ :new => mock_file })}
before(:each) do
- config.stub!(:storage => test_storage)
+ Shutterbug::Configuration.instance.stub!(:storage => test_storage)
end
describe "routing requests in #call" do
-
describe "do_convert route" do
it "should return a valid image url" do
get "/shutterbug/make_snapshot/", post_data
last_response.should be_ok
last_response.headers['Content-Type'].should match 'text/plain'
last_response.body.should match(/^<img src='url_to_file'[^>]+>$/)
end
end
- describe "get png route" do
- it "should route #do_get_png" do
- Shutterbug::Configuration.instance.stub!(:storage => test_storage)
- get "/shutterbug/get_png/filename.png"
+ describe "get file route" do
+ it "should return without errors" do
+ get "/shutterbug/get_file/foobar.png"
last_response.should be_ok
last_response.headers['Content-Type'].should match 'image/png'
end
end
- describe "get html route" do
- it "should route #do_get_html" do
-
- get "/shutterbug/get_html/filename.html"
- last_response.should be_ok
- last_response.headers['Content-Type'].should match 'text/html'
- end
- end
-
describe "get shutterbug.js javascipt route" do
- it "should route #do_get_shutterbug" do
+ it "should return js file" do
get "/shutterbug/shutterbug.js"
last_response.should be_ok
last_response.headers['Content-Type'].should match 'application/javascript'
end
end
-
end
-
-end
\ No newline at end of file
+end