Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin helper returns classes list #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/adminos/helpers/plugin.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Adminos::Helpers::Plugin
def plugin_names
Adminos::Plugins::Base.descendants.map(&:name)
def plugins
Adminos::Plugins::Base.descendants
end
end
2 changes: 1 addition & 1 deletion lib/adminos/plugins/base.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Adminos
module Plugins
class Base
def self.name
def self.title
raise NotImplementedError.new('method name is not defined')
end
end
Expand Down
18 changes: 10 additions & 8 deletions spec/lib/adminos/helpers/plugin_spec.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
RSpec.describe Adminos::Helpers::Plugin, type: :helper do
describe '#plugin_names' do
let(:plugin_names_list) { helper.plugin_names }
describe '#plugins' do
subject(:plugins) { helper.plugins }

before do
class SomePlugin < Adminos::Plugins::Base
def self.name
'some name'
def self.title
'some title'
end
end
end

it 'list of plugin names is not empty' do
expect(plugin_names_list).not_to be_empty
let(:plugin_titles) { plugins.map(&:title) }

it 'plugin list is not empty' do
expect(plugins).not_to be_empty
end

it 'return list of plugin names' do
expect(plugin_names_list).to include(SomePlugin.name)
it 'return plugin title' do
expect(plugin_titles).to include(SomePlugin.title)
end
end
end