2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-27 22:27:38 -04:00
|
|
|
RSpec.describe Plugin::Metadata do
|
2013-08-23 02:21:52 -04:00
|
|
|
context "parse" do
|
|
|
|
it "correctly parses plugin info" do
|
|
|
|
metadata = Plugin::Metadata.parse <<TEXT
|
|
|
|
# name: plugin-name
|
|
|
|
# about: about: my plugin
|
|
|
|
# version: 0.1
|
|
|
|
# authors: Frank Zappa
|
2021-01-28 11:17:00 -05:00
|
|
|
# contact emails: frankz@example.com
|
2015-02-06 18:08:57 -05:00
|
|
|
# url: http://discourse.org
|
2015-04-27 13:06:53 -04:00
|
|
|
# required version: 1.3.0beta6+48
|
2013-08-23 02:21:52 -04:00
|
|
|
|
|
|
|
some_ruby
|
|
|
|
TEXT
|
|
|
|
|
2015-01-09 11:34:37 -05:00
|
|
|
expect(metadata.name).to eq("plugin-name")
|
|
|
|
expect(metadata.about).to eq("about: my plugin")
|
|
|
|
expect(metadata.version).to eq("0.1")
|
|
|
|
expect(metadata.authors).to eq("Frank Zappa")
|
2021-01-28 11:17:00 -05:00
|
|
|
expect(metadata.contact_emails).to eq("frankz@example.com")
|
2015-02-06 18:08:57 -05:00
|
|
|
expect(metadata.url).to eq("http://discourse.org")
|
2015-04-27 13:06:53 -04:00
|
|
|
expect(metadata.required_version).to eq("1.3.0beta6+48")
|
2013-08-23 02:21:52 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-11-14 19:42:55 -05:00
|
|
|
def official(name)
|
|
|
|
metadata = Plugin::Metadata.parse <<TEXT
|
|
|
|
# name: #{name}
|
|
|
|
TEXT
|
|
|
|
|
|
|
|
expect(metadata.official?).to eq(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
def unofficial(name)
|
|
|
|
metadata = Plugin::Metadata.parse <<TEXT
|
|
|
|
# name: #{name}
|
|
|
|
TEXT
|
|
|
|
|
|
|
|
expect(metadata.official?).to eq(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "correctly detects official vs unofficial plugins" do
|
|
|
|
official("discourse-adplugin")
|
|
|
|
official("discourse-akismet")
|
|
|
|
official("discourse-cakeday")
|
|
|
|
official("Canned Replies")
|
|
|
|
official("discourse-data-explorer")
|
|
|
|
unofficial("babble")
|
|
|
|
end
|
|
|
|
|
2013-08-23 02:21:52 -04:00
|
|
|
end
|