Make test run, use appraisal, cleanup

This commit is contained in:
Max Melentiev
2018-07-09 12:15:18 +03:00
parent de194a7a18
commit c00c110cf9
24 changed files with 114 additions and 59 deletions

4
.gitignore vendored
View File

@@ -1,2 +1,4 @@
Gemfile.lock
.ruby-version
Gemfile.lock
gemfiles/*.lock
tmp/

15
Appraisals Normal file
View File

@@ -0,0 +1,15 @@
appraise 'rails_40' do
gem 'rails', '~> 4.0.0'
end
appraise 'rails_41' do
gem 'rails', '~> 4.1.0'
end
appraise 'rails_42' do
gem 'rails', '~> 4.2.0'
end
appraise 'rails_5' do
gem 'rails', '~> 5.2.0'
end

11
Gemfile
View File

@@ -1,6 +1,15 @@
# coding: utf-8
source 'http://rubygems.org'
gemspec
gem 'appraisal'
gem 'fastimage'
gem 'sqlite3'
gemspec
gem 'test-unit'
gem 'thoughtbot-shoulda', '>= 2.9.0'
gem 'mocha'
gem 'pry'
gem 'pry-byebug'

View File

@@ -12,7 +12,7 @@ task :default => [:clean, :test]
desc 'Test the paperclip plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib' << 'profile'
t.libs << 'lib' << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end

15
gemfiles/rails_40.gemfile Normal file
View File

@@ -0,0 +1,15 @@
# This file was generated by Appraisal
source "http://rubygems.org"
gem "appraisal"
gem "fastimage"
gem "sqlite3"
gem "test-unit"
gem "thoughtbot-shoulda", ">= 2.9.0"
gem "mocha"
gem "pry"
gem "pry-byebug"
gem "rails", "~> 4.0.0"
gemspec path: "../"

15
gemfiles/rails_41.gemfile Normal file
View File

@@ -0,0 +1,15 @@
# This file was generated by Appraisal
source "http://rubygems.org"
gem "appraisal"
gem "fastimage"
gem "sqlite3"
gem "test-unit"
gem "thoughtbot-shoulda", ">= 2.9.0"
gem "mocha"
gem "pry"
gem "pry-byebug"
gem "rails", "~> 4.1.0"
gemspec path: "../"

15
gemfiles/rails_42.gemfile Normal file
View File

@@ -0,0 +1,15 @@
# This file was generated by Appraisal
source "http://rubygems.org"
gem "appraisal"
gem "fastimage"
gem "sqlite3"
gem "test-unit"
gem "thoughtbot-shoulda", ">= 2.9.0"
gem "mocha"
gem "pry"
gem "pry-byebug"
gem "rails", "~> 4.2.0"
gemspec path: "../"

15
gemfiles/rails_5.gemfile Normal file
View File

@@ -0,0 +1,15 @@
# This file was generated by Appraisal
source "http://rubygems.org"
gem "appraisal"
gem "fastimage"
gem "sqlite3"
gem "test-unit"
gem "thoughtbot-shoulda", ">= 2.9.0"
gem "mocha"
gem "pry"
gem "pry-byebug"
gem "rails", "~> 5.2.0"
gemspec path: "../"

View File

@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
s.date = %q{2009-06-18}
s.email = %q{jyurek@thoughtbot.com}
s.extra_rdoc_files = ["README.rdoc"]
s.files = ["README.rdoc", "LICENSE", "Rakefile", "init.rb", "generators/paperclip", "generators/paperclip/paperclip_generator.rb", "generators/paperclip/templates", "generators/paperclip/templates/paperclip_migration.rb.erb", "generators/paperclip/USAGE", "lib/paperclip", "lib/paperclip/attachment.rb", "lib/paperclip/callback_compatability.rb", "lib/paperclip/geometry.rb", "lib/paperclip/interpolations.rb", "lib/paperclip/iostream.rb", "lib/paperclip/matchers", "lib/paperclip/matchers/have_attached_file_matcher.rb", "lib/paperclip/matchers/validate_attachment_content_type_matcher.rb", "lib/paperclip/matchers/validate_attachment_presence_matcher.rb", "lib/paperclip/matchers/validate_attachment_size_matcher.rb", "lib/paperclip/matchers.rb", "lib/paperclip/processor.rb", "lib/paperclip/storage.rb", "lib/paperclip/thumbnail.rb", "lib/paperclip/upfile.rb", "lib/paperclip.rb", "tasks/paperclip_tasks.rake", "test/attachment_test.rb", "test/database.yml", "test/fixtures", "test/fixtures/12k.png", "test/fixtures/50x50.png", "test/fixtures/5k.png", "test/fixtures/bad.png", "test/fixtures/s3.yml", "test/fixtures/text.txt", "test/fixtures/twopage.pdf", "test/geometry_test.rb", "test/helper.rb", "test/integration_test.rb", "test/interpolations_test.rb", "test/iostream_test.rb", "test/matchers", "test/matchers/have_attached_file_matcher_test.rb", "test/matchers/validate_attachment_content_type_matcher_test.rb", "test/matchers/validate_attachment_presence_matcher_test.rb", "test/matchers/validate_attachment_size_matcher_test.rb", "test/paperclip_test.rb", "test/processor_test.rb", "test/storage_test.rb", "test/thumbnail_test.rb", "shoulda_macros/paperclip.rb"]
s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|gemfiles)/}) }
s.has_rdoc = true
s.homepage = %q{http://www.thoughtbot.com/projects/paperclip}
s.rdoc_options = ["--line-numbers", "--inline-source"]
@@ -19,20 +19,4 @@ Gem::Specification.new do |s|
s.summary = %q{File attachments as attributes for ActiveRecord}
s.add_dependency('sidekiq', ["~> 2.0"])
if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 2
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
s.add_development_dependency(%q<mocha>, [">= 0"])
else
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
s.add_dependency(%q<mocha>, [">= 0"])
end
else
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
s.add_dependency(%q<mocha>, [">= 0"])
end
end

View File

@@ -1,4 +1,4 @@
require 'test/helper'
require 'test_helper'
class Dummy
# This is a dummy class
@@ -105,12 +105,11 @@ class AttachmentTest < Test::Unit::TestCase
@dummy.stubs(:id).returns(@id)
@file = StringIO.new(".")
@dummy.avatar = @file
Rails.stub(:env) { @rails_env }
end
should "return the proper path" do
temporary_rails_env(@rails_env) {
assert_equal "#{@rails_env}/#{@id}.png", @dummy.avatar.path
}
end
end

View File

@@ -1,4 +1,4 @@
require 'test/helper'
require 'test_helper'
class GeometryTest < Test::Unit::TestCase
context "Paperclip::Geometry" do

View File

@@ -1,4 +1,4 @@
require 'test/helper'
require 'test_helper'
class IntegrationTest < Test::Unit::TestCase
context "Many models at once" do

View File

@@ -1,4 +1,4 @@
require 'test/helper'
require 'test_helper'
class InterpolationsTest < Test::Unit::TestCase
should "return all methods but the infrastructure when sent #all" do

View File

@@ -1,4 +1,4 @@
require 'test/helper'
require 'test_helper'
class IOStreamTest < Test::Unit::TestCase
context "IOStream" do

View File

@@ -1,4 +1,4 @@
require 'test/helper'
require 'test_helper'
class HaveAttachedFileMatcherTest < Test::Unit::TestCase
context "have_attached_file" do

View File

@@ -1,4 +1,4 @@
require 'test/helper'
require 'test_helper'
class ValidateAttachmentContentTypeMatcherTest < Test::Unit::TestCase
context "validate_attachment_content_type" do

View File

@@ -1,4 +1,4 @@
require 'test/helper'
require 'test_helper'
class ValidateAttachmentPresenceMatcherTest < Test::Unit::TestCase
context "validate_attachment_presence" do

View File

@@ -1,4 +1,4 @@
require 'test/helper'
require 'test_helper'
class ValidateAttachmentSizeMatcherTest < Test::Unit::TestCase
context "validate_attachment_size" do

View File

@@ -1,4 +1,4 @@
require 'test/helper'
require 'test_helper'
class PaperclipTest < Test::Unit::TestCase
[:image_magick_path, :convert_path].each do |path|

View File

@@ -1,4 +1,4 @@
require 'test/helper'
require 'test_helper'
class ProcessorTest < Test::Unit::TestCase
should "instantiate and call #make when sent #make to the class" do

View File

@@ -1,4 +1,4 @@
require 'test/helper'
require 'test_helper'
class StorageTest < Test::Unit::TestCase
context "Parsing S3 credentials" do

View File

@@ -1,23 +1,20 @@
require 'rubygems'
require 'test/unit'
gem 'thoughtbot-shoulda', ">= 2.9.0"
require 'shoulda'
require 'mocha'
require 'mocha/test_unit'
require 'pry'
require 'tempfile'
gem 'sqlite3-ruby'
require 'sqlite3'
require 'active_record'
require 'active_support'
begin
require 'ruby-debug'
rescue LoadError
puts "ruby-debug not loaded"
end
require 'rails'
ROOT = File.join(File.dirname(__FILE__), '..')
Rails.root = ROOT
Rails.env = "test"
ROOT = File.expand_path('../', __dir__)
ENV['RAILS_ENV'] = 'test'
class TestRailsApp < Rails::Application; end
Rails.application.config.root = "#{ROOT}/tmp/rails"
$LOAD_PATH << File.join(ROOT, 'lib')
$LOAD_PATH << File.join(ROOT, 'lib', 'paperclip')
@@ -69,17 +66,6 @@ def rebuild_class options = {}
end
end
def temporary_rails_env(new_env)
old_env = Object.const_defined?("Rails.env") ? Rails.env : nil
silence_warnings do
Object.const_set("Rails.env", new_env)
end
yield
silence_warnings do
Object.const_set("Rails.env", old_env)
end
end
class FakeModel
attr_accessor :avatar_file_name,
:avatar_file_size,

View File

@@ -1,4 +1,4 @@
require 'test/helper'
require 'test_helper'
class ThumbnailTest < Test::Unit::TestCase