From fc78886d5b82c229dab38ac80d24e99f6244ee27 Mon Sep 17 00:00:00 2001 From: Brandon Robins Date: Tue, 19 Dec 2017 23:41:28 -0600 Subject: [PATCH] Configure dummy app, rake tasks, and travis --- .gitignore | 7 ++ .travis.yml | 8 +++ Gemfile | 1 - Gemfile.lock | 3 + Rakefile | 62 ++++++++++++++++++ calligraphy.gemspec | 2 + spec/dummy/app/models/concerns/.keep | 0 spec/dummy/config/initializers/calligraphy.rb | 47 +++++++++++++ spec/dummy/config/routes.rb | 2 +- spec/dummy/db/test.sqlite3 | Bin 20480 -> 20480 bytes 10 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 .travis.yml create mode 100644 Rakefile delete mode 100644 spec/dummy/app/models/concerns/.keep create mode 100644 spec/dummy/config/initializers/calligraphy.rb diff --git a/.gitignore b/.gitignore index 5e1422c..db47603 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ *.gem +*.log *.rbc /.config /coverage/ /InstalledFiles +/litmus*/ /pkg/ /spec/reports/ /spec/examples.txt @@ -48,3 +50,8 @@ build-iPhoneSimulator/ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: .rvmrc + +## Dummy app +/spec/dummy/lib/ +/spec/dummy/log/ +/spec/dummy/tmp/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..dfd4ea2 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +language: ruby +rvm: + - 2.2 + - 2.3 + - 2.4 +script: + - bundle exec rake spec + - bundle exec rake litmus:run diff --git a/Gemfile b/Gemfile index 1417808..fa75df1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,3 @@ source 'https://rubygems.org' -# Specify gem dependencies in calligraphy.gemspec gemspec diff --git a/Gemfile.lock b/Gemfile.lock index 66c6fab..a200d9a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -66,6 +66,7 @@ GEM nio4r (2.1.0) nokogiri (1.8.1) mini_portile2 (~> 2.3.0) + puma (3.11.0) rack (2.0.3) rack-test (0.8.2) rack (>= 1.0, < 3) @@ -131,6 +132,8 @@ PLATFORMS DEPENDENCIES calligraphy! + puma (~> 3.11.0) + rake (~> 12.3.0) rspec-rails (~> 3.7.2) sqlite3 (~> 1.3.13) diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..09bfbea --- /dev/null +++ b/Rakefile @@ -0,0 +1,62 @@ +#!/usr/bin/env rake +require "rake/clean" +require "rspec/core/rake_task" + +task default: %w(spec litmus:run) + +desc "Run rspec tests" +RSpec::Core::RakeTask.new :spec + +desc "Run litmus test suite" +task :litmus => %w(litmus:run) + +namespace :litmus do + tmp_dir = "#{Dir.pwd}/tmp" + litmus_archive = "#{tmp_dir}/litmus-0.13.tar.gz" + + desc "Fetch litmus test suite zip file" + task :fetch do + sh "mkdir tmp" unless File.directory? "#{tmp_dir}" + sh "mkdir tmp/webdav" unless File.directory? "#{tmp_dir}/webdav" + + unless File.exist? litmus_archive + sh "wget -O #{tmp_dir}/litmus-0.13.tar.gz https://github.com/eanlain/litmus/releases/download/v0.13/litmus-0.13.tar.gz" + end + end + CLEAN.include("tmp") + + task :unarchive => :fetch do + unless File.directory? "#{Dir.pwd}/litmus-0.13" + sh "tar -xvzf #{tmp_dir}/litmus-0.13.tar.gz" + end + end + CLEAN.include("litmus-0.13") + + task :configure => :unarchive do + unless File.exist? "litmus-0.13/configured" + sh "cd litmus-0.13 && ./configure" + sh "cd litmus-0.13 && touch configured" + end + end + + task :make_clean do + sh "cd litmus-0.13 && make clean" + sh "rm litmus-0.13/configured" + end + + task :run => :configure do + sh "cd spec/dummy/ && rails server -d" + puma_pid = `cat spec/dummy/tmp/pids/server.pid` + exit_code = 0 + + begin + sh "cd litmus-0.13 && make URL=http://localhost:3000/webdav/ CREDS='jon_deaux changeme!' check" + rescue + exit_code = 1 + puts "!!!!! Failure encountered during litmus test suite !!!!!" + end + + sh "kill #{puma_pid}" + exit exit_code + end +end diff --git a/calligraphy.gemspec b/calligraphy.gemspec index baae413..c7a4b45 100644 --- a/calligraphy.gemspec +++ b/calligraphy.gemspec @@ -20,6 +20,8 @@ Gem::Specification.new do |s| s.add_dependency 'rails', '~> 5.0' + s.add_development_dependency 'puma', '~> 3.11.0' + s.add_development_dependency 'rake', '~> 12.3.0' s.add_development_dependency 'rspec-rails', '~> 3.7.2' s.add_development_dependency 'sqlite3', '~> 1.3.13' end diff --git a/spec/dummy/app/models/concerns/.keep b/spec/dummy/app/models/concerns/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/spec/dummy/config/initializers/calligraphy.rb b/spec/dummy/config/initializers/calligraphy.rb new file mode 100644 index 0000000..790bb62 --- /dev/null +++ b/spec/dummy/config/initializers/calligraphy.rb @@ -0,0 +1,47 @@ +Calligraphy.configure do |config| + # The HTTP actions Calligraphy uses to create mappings between WebDAV + # HTTP verbs and URLs and WebDAV controller actions. + # config.web_dav_actions = [ + # :options, :get, :put, :delete, :copy, :move, + # :mkcol, :propfind, :proppatch, :lock, :unlock + # ] + + # HTTP methods allowed by the WebDavRequests controller. + # Before responding to a WebDav request, the WebDavRequests controller + # checks this list to determine if it is allowed to make the request. + # If a method is disallowed, the controller will respond by sending an + # HTTP 405 (Method Not Allowed) response. + # config.allowed_http_methods = %w( + # options get put delete copy move + # mkcol propfind proppatch lock unlock + # ) + + # If Digest Authentication is enabled by default. False by default. + config.enable_digest_authentication = true + + # Proc responsible for returning the user's password, API key, + # or HA1 digest hash so that Rails can check user credentials. + # Should be configured to handle your particular application's + # user and/or authentication setup. + # + # For example, in an API setup where an email/API key are sent with the + # request, in lieu of a username/password, the digest_password_procedure + # would be defined as: + # + # config.digest_password_procedure = Proc.new do |email| + # u = User.find_by(email: email) + # u.authentication_token + # end + # + # Digest Authentication would need to be enabled for this proc to + # actually be called. + config.digest_password_procedure = Proc.new do |username| + 'changeme!' + end + + # The realm used in HTTP Digest Authentication. 'Application' by default. + # config.http_authentication_realm = 'Application' + + # Maximum lock lifetime in seconds. 86400 by default. + # config.lock_timeout_period = 86400 +end diff --git a/spec/dummy/config/routes.rb b/spec/dummy/config/routes.rb index c1ff480..45d8836 100644 --- a/spec/dummy/config/routes.rb +++ b/spec/dummy/config/routes.rb @@ -1,4 +1,4 @@ Rails.application.routes.draw do calligraphy_resource :test - calligraphy_resource :webdav, resource_class: Calligraphy::FileResource + calligraphy_resource :webdav, resource_class: Calligraphy::FileResource, resource_root_path: File.expand_path('../../../../tmp/webdav', __FILE__) end diff --git a/spec/dummy/db/test.sqlite3 b/spec/dummy/db/test.sqlite3 index 321c42c44215bdc14889ab815c046725251246f9..9898f491199bfe823e327ac5be1ced03cecd46c9 100644 GIT binary patch delta 57 wcmZozz}T>Wal;jR9U}t;15+zw3oBD2J!1<4BTG{w14DCNLnB>GnMDo)0K6Ct*8l(j delta 57 wcmZozz}T>Wal;jR9YYHR12ZcF6DwnLJwpo%BU2M214DCNLnB>GnMDo)0KH-j;Q#;t