Skip to content

Commit

Permalink
Do not include tests files in packaged gem (#526)
Browse files Browse the repository at this point in the history
* changing location of rspec file

* trying a graceful fail here

* wrapping in rails env check
  • Loading branch information
jasonfb committed Feb 2, 2022
1 parent c0758a8 commit 3572129
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
39 changes: 21 additions & 18 deletions lib/paranoia/rspec.rb
@@ -1,23 +1,26 @@
require 'rspec/expectations'
if Rails.env.test?
require 'rspec/expectations'

# Validate the subject's class did call "acts_as_paranoid"
RSpec::Matchers.define :act_as_paranoid do
match { |subject| subject.class.ancestors.include?(Paranoia) }
# Validate the subject's class did call "acts_as_paranoid"
RSpec::Matchers.define :act_as_paranoid do
match { |subject| subject.class.ancestors.include?(Paranoia) }

failure_message_proc = lambda do
"expected #{subject.class} to use `acts_as_paranoid`"
end
failure_message_proc = lambda do
"expected #{subject.class} to use `acts_as_paranoid`"
end

failure_message_when_negated_proc = lambda do
"expected #{subject.class} not to use `acts_as_paranoid`"
end
failure_message_when_negated_proc = lambda do
"expected #{subject.class} not to use `acts_as_paranoid`"
end

if respond_to?(:failure_message_when_negated)
failure_message(&failure_message_proc)
failure_message_when_negated(&failure_message_when_negated_proc)
else
# RSpec 2 compatibility:
failure_message_for_should(&failure_message_proc)
failure_message_for_should_not(&failure_message_when_negated_proc)
if respond_to?(:failure_message_when_negated)
failure_message(&failure_message_proc)
failure_message_when_negated(&failure_message_when_negated_proc)
else
# RSpec 2 compatibility:
failure_message_for_should(&failure_message_proc)
failure_message_for_should_not(&failure_message_when_negated_proc)
end
end
end

end
7 changes: 6 additions & 1 deletion paranoia.gemspec
Expand Up @@ -29,7 +29,12 @@ Gem::Specification.new do |s|
s.add_development_dependency "bundler", ">= 1.0.0"
s.add_development_dependency "rake"

s.files = `git ls-files`.split("\n")

s.files = Dir.chdir(File.expand_path('..', __FILE__)) do
files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)}) }
files
end

s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
s.require_path = 'lib'
end

0 comments on commit 3572129

Please sign in to comment.