Make rspec work without rails dependency
This commit is contained in:
parent
1f067c62a7
commit
e6e9893c1f
8 changed files with 48 additions and 20 deletions
|
|
@ -162,11 +162,13 @@ Metrics/BlockLength:
|
|||
- "spec/**/*.rb"
|
||||
- "test/dummy/config/**/*.rb"
|
||||
|
||||
# Rails cops only for controllers
|
||||
Rails/Date:
|
||||
Exclude:
|
||||
- "spec/support/**/*"
|
||||
Rails/TimeZone:
|
||||
Exclude:
|
||||
- "spec/lib/**/*"
|
||||
|
||||
# Rails cops only for controllers
|
||||
Rails/Delegate:
|
||||
Exclude:
|
||||
- "lib/**/*"
|
||||
|
|
|
|||
10
Gemfile
10
Gemfile
|
|
@ -17,9 +17,9 @@ end
|
|||
|
||||
group :development do
|
||||
# code style
|
||||
gem "pronto", "0.8.2"
|
||||
gem "pronto-rubocop", "0.8.0", require: false
|
||||
gem "rubocop", "0.48.0"
|
||||
gem "pronto", "0.8.2", require: false
|
||||
gem "pronto-rubocop", "0.8.0", require: false
|
||||
gem "rubocop", "0.48.0", require: false
|
||||
|
||||
# automatic test runs
|
||||
gem "guard-rspec", require: false
|
||||
|
|
@ -56,7 +56,9 @@ group :test do
|
|||
end
|
||||
|
||||
group :development, :test do
|
||||
gem "rake"
|
||||
|
||||
# unit tests
|
||||
gem "rspec-core", "~> 3.5.1"
|
||||
gem "rspec", "~> 3.5.0"
|
||||
gem "rspec-rails", "~> 3.5.1"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -248,8 +248,9 @@ DEPENDENCIES
|
|||
pronto-rubocop (= 0.8.0)
|
||||
pry
|
||||
pry-byebug
|
||||
rake
|
||||
rspec (~> 3.5.0)
|
||||
rspec-collection_matchers (~> 1.1.2)
|
||||
rspec-core (~> 3.5.1)
|
||||
rspec-json_expectations (~> 2.1)
|
||||
rspec-rails (~> 3.5.1)
|
||||
rubocop (= 0.48.0)
|
||||
|
|
|
|||
15
Rakefile
15
Rakefile
|
|
@ -13,14 +13,19 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|||
rdoc.rdoc_files.include("lib/**/*.rb")
|
||||
end
|
||||
|
||||
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
||||
load "rails/tasks/engine.rake"
|
||||
if defined?(::Rails)
|
||||
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
||||
load "rails/tasks/engine.rake"
|
||||
load "rails/tasks/statistics.rake"
|
||||
|
||||
load "rails/tasks/statistics.rake"
|
||||
Rails.application.load_tasks
|
||||
else
|
||||
require "rspec/core/rake_task"
|
||||
RSpec::Core::RakeTask.new(:spec)
|
||||
FileList["lib/tasks/**/*.rake"].each {|task| load(task) }
|
||||
end
|
||||
|
||||
Bundler::GemHelper.install_tasks name: "diaspora_federation"
|
||||
|
||||
Rails.application.load_tasks
|
||||
|
||||
task test: :spec
|
||||
task default: :test
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ module DiasporaFederation
|
|||
DiasporaFederation.server_uri = temp
|
||||
end
|
||||
|
||||
context "certificate_authorities" do
|
||||
context "certificate_authorities", rails: true do
|
||||
before do
|
||||
@certificate_authorities = DiasporaFederation.certificate_authorities
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,12 +12,25 @@ unless ENV["NO_COVERAGE"] == "true"
|
|||
end
|
||||
end
|
||||
|
||||
ENV["RAILS_ENV"] ||= "test"
|
||||
require File.join(File.dirname(__FILE__), "..", "test", "dummy", "config", "environment")
|
||||
dummy_app_path = File.join(File.dirname(__FILE__), "..", "test", "dummy")
|
||||
|
||||
require "rspec/rails"
|
||||
require "webmock/rspec"
|
||||
begin
|
||||
require "rails" # try to load rails
|
||||
rescue LoadError
|
||||
Dir["#{File.join(dummy_app_path, 'app', 'models')}/*.rb"].each {|f| require f }
|
||||
require File.join(dummy_app_path, "config", "initializers", "diaspora_federation")
|
||||
else
|
||||
ENV["RAILS_ENV"] ||= "test"
|
||||
require File.join(dummy_app_path, "config", "environment")
|
||||
|
||||
require "rspec/rails"
|
||||
end
|
||||
|
||||
# test helpers
|
||||
require "json-schema-rspec"
|
||||
require "rspec/collection_matchers"
|
||||
require "rspec/json_expectations"
|
||||
require "webmock/rspec"
|
||||
|
||||
# load factories
|
||||
require "factories"
|
||||
|
|
@ -39,7 +52,12 @@ RSpec.configure do |config|
|
|||
expect_config.syntax = :expect
|
||||
end
|
||||
|
||||
config.filter_run_excluding rails: (Rails::VERSION::MAJOR == 5 ? 4 : 5)
|
||||
if defined?(::Rails)
|
||||
config.filter_run_excluding rails: (::Rails::VERSION::MAJOR == 5 ? 4 : 5)
|
||||
else
|
||||
config.exclude_pattern = "**/controllers/**/*_spec.rb, **/routing/**/*_spec.rb"
|
||||
config.filter_run_excluding rails: true
|
||||
end
|
||||
|
||||
# whitelist codeclimate.com so test coverage can be reported
|
||||
config.after(:suite) do
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ shared_examples "a boolean validator" do
|
|||
end
|
||||
|
||||
it "must not be an arbitrary string or other object" do
|
||||
["asdf", Time.zone.today, 1234].each do |val|
|
||||
["asdf", Date.today, 1234].each do |val|
|
||||
validator = described_class.new(entity_stub(entity, property => val))
|
||||
|
||||
expect(validator).not_to be_valid
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
require "diaspora_federation/discovery"
|
||||
require "diaspora_federation"
|
||||
|
||||
ca_file = if File.file?("/etc/ssl/certs/ca-certificates.crt")
|
||||
# For Debian, Ubuntu, Archlinux, Gentoo
|
||||
|
|
|
|||
Loading…
Reference in a new issue