require 'spec_helper' require 'rack/test' describe 'SkinBuilder server' do include Rack::Test::Methods let(:skins_directory) { File.expand_path(File.join(File.dirname(__FILE__), '../../fixtures/skins')) } let(:skin_code) { "DV3tf95f" } def app Adyen::SkinBuilder::Server.tap do |app| app.set :skins_directory, skins_directory end.new end before do Adyen::Admin.stub(:login) Adyen::Admin::Skin.purge_cache Adyen::Admin::Skin.default_path = skins_directory end describe 'assets' do let(:file) { '/css/screen.css' } before(:each) do get File.join( "/sf", skin_code, file) end it 'responds with 200 status' do last_response.status.should == 200 end it 'responds with "text/css" content type header for CSS file' do last_response.headers.fetch('Content-Type').should == 'text/css;charset=utf-8' end it 'returns file content' do last_response.body.should == File.read(File.join(skins_directory, skin_code, file)) end context 'file not available, falls back to base' do let(:file) { '/css/print.css' } it 'responds with 200 status' do last_response.status.should == 200 end it 'responds with "text/css" content type header for CSS file' do last_response.headers.fetch('Content-Type').should == 'text/css;charset=utf-8' end it 'returns file content from base' do last_response.body.should == File.read(skins_directory + "/base" + file) end end end describe 'GET' do describe '/' do let(:path) { '/' } before(:each) do get path end it 'responds with 200 status' do last_response.status.should == 200 end it 'returns adyen skeleton in HTML format' do last_response.headers.fetch('Content-Type').should == 'text/html;charset=utf-8' end it 'returns skins_directory' do last_response.body.should include(skins_directory) end it 'returns avilable skins' do last_response.body.should include(skin_code) end end describe "/:skin_code" do let(:path) { "/#{skin_code}" } before(:each) do get path end it 'responds with 200 status' do last_response.status.should == 200 end it 'returns adyen skeleton in HTML format' do last_response.headers.fetch('Content-Type').should == 'text/html;charset=utf-8' end it 'returns adyen form' do last_response.body.should include('