Skip to content
Snippets Groups Projects
Verified Commit f2c9ac13 authored by Alexander Olofsson's avatar Alexander Olofsson
Browse files

Do proper testing

parent 4fa707de
No related branches found
Tags v0.2.0
No related merge requests found
Pipeline #83973 failed
......@@ -2,23 +2,23 @@
require File.join File.expand_path('lib', __dir__), 'foreman_notification_send/version'
Gem::Specification.new do |s|
s.name = 'foreman_notification_send'
s.version = ForemanNotificationSend::VERSION
s.authors = ['Alexander Olofsson']
s.email = ['alexander.olofsson@liu.se']
Gem::Specification.new do |spec|
spec.name = 'foreman_notification_send'
spec.version = ForemanNotificationSend::VERSION
spec.authors = ['Alexander Olofsson']
spec.email = ['alexander.olofsson@liu.se']
s.homepage = 'https://github.com/ananace/foreman_notification_send'
s.summary = 'Send Foreman notifications to external systems'
s.description = s.summary
s.license = 'GPL-3.0'
spec.homepage = 'https://github.com/ananace/foreman_notification_send'
spec.summary = 'Send Foreman notifications to external systems'
spec.description = spec.summary
spec.license = 'GPL-3.0'
s.files = Dir['{app,config,db,lib}/**/*.{rake,rb}'] + %w[LICENSE.txt README.md]
s.require_paths = ['lib']
spec.files = Dir['{app,config,db,lib}/**/*.{rake,rb}'] + %w[LICENSE.txt README.md]
s.add_dependency 'matrix_sdk', '~> 2.6'
spec.add_dependency 'matrix_sdk', '~> 2.6'
s.add_development_dependency 'bundler'
s.add_development_dependency 'minitest'
s.add_development_dependency 'rake'
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rubocop-minitest'
spec.add_development_dependency 'rubocop-performance'
spec.add_development_dependency 'rubocop-rails'
end
# desc "Explaining what the task does"
# task :foreman_notification_send do
# # Task goes here
# end
# frozen_string_literal: true
namespace :test do
desc 'Test ForemanNotificationSend'
Rake::TestTask.new(:foreman_notification_send) do |t|
test_dir = File.join(__dir__, '../..', 'test')
t.libs << ['test', test_dir]
t.pattern = "#{test_dir}/**/*_test.rb"
t.verbose = true
t.warning = false
end
end
Rake::Task[:test].enhance %w[test:foreman_notification_send]
require 'test_helper'
class ForemanNotificationSend::Test < ActiveSupport::TestCase
test "truth" do
assert_kind_of Module, ForemanNotificationSend
end
end
# Configure Rails Environment
ENV["RAILS_ENV"] = "test"
require_relative "../test/dummy/config/environment"
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)]
require "rails/test_help"
# Filter out Minitest backtrace while allowing backtrace from other libraries
# to be shown.
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
require "rails/test_unit/reporter"
Rails::TestUnitReporter.executable = 'bin/test'
# Load fixtures from the engine
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
ActiveSupport::TestCase.fixture_path = File.expand_path("fixtures", __dir__)
ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files"
ActiveSupport::TestCase.fixtures :all
end
# frozen_string_literal: true
# This calls the main test_helper in Foreman-core
require 'test_helper'
require 'database_cleaner'
# Add plugin to FactoryBot's paths
FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
FactoryBot.reload
# Foreman's setup doesn't handle cleaning up for Minitest::Spec
DatabaseCleaner.strategy = :transaction
class Minitest::Spec
before :each do
DatabaseCleaner.start
end
after :each do
DatabaseCleaner.clean
end
end
# frozen_string_literal: true
require 'test_plugin_helper'
class NotificationTest < ActiveSupport::TestCase
let(:blueprint) { NotificationBlueprint.new group: 'test', level: 'info' }
let(:notification) { Notification.new notification_blueprint: blueprint, message: 'example' }
context 'Handling data manipulation' do
test 'it should serialize to valid text' do
assert_equal <<~MD.strip, notification.to_markdown
**test**:
ℹ️ example
MD
assert_equal <<~HTML.strip, notification.to_html
<b>test</b>:<br/>ℹ️ example
HTML
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment