diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index c8c41fbc..b5f752f6 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -71,3 +71,5 @@ jobs: run: bundle exec rubocop - name: run spec run: bin/rails spec + - name: run spec for bess + run: cd gems/bess && rake spec diff --git a/gems/bess/Gemfile b/gems/bess/Gemfile index 20fd9eb8..09e2a8e2 100644 --- a/gems/bess/Gemfile +++ b/gems/bess/Gemfile @@ -1,4 +1,6 @@ +# frozen_string_literal: true + source 'https://rubygems.org' # Specify your gem's dependencies in bess.gemspec -gemspec \ No newline at end of file +gemspec diff --git a/gems/bess/Rakefile b/gems/bess/Rakefile index 3d1395e4..d216099f 100644 --- a/gems/bess/Rakefile +++ b/gems/bess/Rakefile @@ -6,4 +6,30 @@ require "bundler/setup" load "rails/tasks/statistics.rake" -require "bundler/gem_tasks" \ No newline at end of file +require "bundler/gem_tasks" + +begin + require 'bundler/gem_tasks' +rescue LoadError + nil +end + +require 'rubygems' +require 'bundler' +require 'rdoc/task' +begin + Bundler.setup(:default, :development) +rescue Bundler::BundlerError => e + $stderr.puts e.message + $stderr.puts "Run `bundle install` to install missing gems" + exit e.status_code +end +require 'rake' + +require 'rspec/core' +require 'rspec/core/rake_task' +RSpec::Core::RakeTask.new(:spec) do |spec| + spec.pattern = FileList['spec/**/*_spec.rb'] +end + +task :default => :spec diff --git a/gems/bess/bin/rspec b/gems/bess/bin/rspec new file mode 100755 index 00000000..a6c78521 --- /dev/null +++ b/gems/bess/bin/rspec @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rspec' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rspec-core", "rspec") diff --git a/gems/bess/spec/rails_helper.rb b/gems/bess/spec/rails_helper.rb index ea0acc5f..186f6ce0 100644 --- a/gems/bess/spec/rails_helper.rb +++ b/gems/bess/spec/rails_helper.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + # This file is copied to spec/ when you run 'rails generate rspec:install' require 'spec_helper' ENV['RAILS_ENV'] ||= 'test' -#require File.expand_path('../config/environment', __dir__) +# require File.expand_path('../config/environment', __dir__) # Prevent database truncation if the environment is production -abort("The Rails environment is running in production mode!") if Rails.env.production? +abort('The Rails environment is running in production mode!') if Rails.env.production? require 'rspec/rails' # Add additional requires below this line. Rails is not loaded until this point! @@ -23,33 +25,33 @@ require 'rspec/rails' # Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f } RSpec.configure do |config| - # Remove this line to enable support for ActiveRecord - config.use_active_record = false + # Remove this line to enable support for ActiveRecord + config.use_active_record = false - # If you enable ActiveRecord support you should unncomment these lines, - # note if you'd prefer not to run each example within a transaction, you - # should set use_transactional_fixtures to false. - # - # config.fixture_path = "#{::Rails.root}/spec/fixtures" - # config.use_transactional_fixtures = true + # If you enable ActiveRecord support you should unncomment these lines, + # note if you'd prefer not to run each example within a transaction, you + # should set use_transactional_fixtures to false. + # + # config.fixture_path = "#{::Rails.root}/spec/fixtures" + # config.use_transactional_fixtures = true - # RSpec Rails can automatically mix in different behaviours to your tests - # based on their file location, for example enabling you to call `get` and - # `post` in specs under `spec/controllers`. - # - # You can disable this behaviour by removing the line below, and instead - # explicitly tag your specs with their type, e.g.: - # - # RSpec.describe UsersController, type: :controller do - # # ... - # end - # - # The different available types are documented in the features, such as in - # https://relishapp.com/rspec/rspec-rails/docs - config.infer_spec_type_from_file_location! + # RSpec Rails can automatically mix in different behaviours to your tests + # based on their file location, for example enabling you to call `get` and + # `post` in specs under `spec/controllers`. + # + # You can disable this behaviour by removing the line below, and instead + # explicitly tag your specs with their type, e.g.: + # + # RSpec.describe UsersController, type: :controller do + # # ... + # end + # + # The different available types are documented in the features, such as in + # https://relishapp.com/rspec/rspec-rails/docs + config.infer_spec_type_from_file_location! - # Filter lines from Rails gems in backtraces. - config.filter_rails_from_backtrace! - # arbitrary gems may also be filtered via: - # config.filter_gems_from_backtrace("gem name") + # Filter lines from Rails gems in backtraces. + config.filter_rails_from_backtrace! + # arbitrary gems may also be filtered via: + # config.filter_gems_from_backtrace("gem name") end