ronin 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +11 -0
- data/.github/workflows/ruby.yml +32 -0
- data/.gitignore +7 -7
- data/.ruby-version +1 -0
- data/COPYING.txt +3 -3
- data/ChangeLog.md +25 -11
- data/Gemfile +21 -20
- data/README.md +102 -81
- data/Rakefile +4 -5
- data/bin/ronin +7 -12
- data/bin/ronin-campaigns +7 -12
- data/bin/ronin-console +7 -12
- data/bin/ronin-creds +7 -12
- data/bin/ronin-database +7 -12
- data/bin/ronin-emails +7 -12
- data/bin/ronin-exec +7 -12
- data/bin/ronin-fuzzer +7 -12
- data/bin/ronin-help +7 -12
- data/bin/ronin-hosts +7 -12
- data/bin/ronin-install +7 -12
- data/bin/ronin-ips +7 -12
- data/bin/ronin-net-proxy +7 -12
- data/bin/ronin-repos +7 -12
- data/bin/ronin-uninstall +7 -12
- data/bin/ronin-update +7 -12
- data/bin/ronin-urls +7 -12
- data/bin/ronin-wordlist +7 -12
- data/gemspec.yml +8 -8
- data/lib/bond/completions/ronin.rb +23 -23
- data/lib/ronin.rb +3 -3
- data/lib/ronin/address.rb +6 -7
- data/lib/ronin/arch.rb +3 -3
- data/lib/ronin/author.rb +5 -7
- data/lib/ronin/auto_load.rb +5 -5
- data/lib/ronin/bootstrap.rb +3 -3
- data/lib/ronin/campaign.rb +3 -3
- data/lib/ronin/config.rb +5 -7
- data/lib/ronin/credential.rb +3 -3
- data/lib/ronin/database.rb +3 -3
- data/lib/ronin/database/database.rb +8 -12
- data/lib/ronin/database/exceptions.rb +3 -3
- data/lib/ronin/database/exceptions/invalid_config.rb +3 -3
- data/lib/ronin/database/exceptions/unknown_repository.rb +3 -3
- data/lib/ronin/database/migrations.rb +3 -3
- data/lib/ronin/database/migrations/1.0.0.rb +3 -3
- data/lib/ronin/database/migrations/1.1.0.rb +3 -3
- data/lib/ronin/database/migrations/exceptions.rb +3 -3
- data/lib/ronin/database/migrations/exceptions/duplicate_migration.rb +3 -3
- data/lib/ronin/database/migrations/exceptions/unknown_migration.rb +3 -3
- data/lib/ronin/database/migrations/graph.rb +3 -3
- data/lib/ronin/database/migrations/migration.rb +3 -3
- data/lib/ronin/database/migrations/migrations.rb +3 -3
- data/lib/ronin/email_address.rb +5 -7
- data/lib/ronin/environment.rb +3 -3
- data/lib/ronin/exceptions.rb +3 -3
- data/lib/ronin/exceptions/duplicate_repository.rb +3 -3
- data/lib/ronin/exceptions/repository_not_found.rb +3 -3
- data/lib/ronin/host_name.rb +3 -3
- data/lib/ronin/host_name_ip_address.rb +3 -3
- data/lib/ronin/installation.rb +5 -7
- data/lib/ronin/ip_address.rb +6 -8
- data/lib/ronin/ip_address_mac_address.rb +3 -3
- data/lib/ronin/license.rb +6 -6
- data/lib/ronin/mac_address.rb +3 -3
- data/lib/ronin/model.rb +3 -3
- data/lib/ronin/model/has_authors.rb +3 -3
- data/lib/ronin/model/has_description.rb +3 -3
- data/lib/ronin/model/has_license.rb +3 -3
- data/lib/ronin/model/has_name.rb +3 -3
- data/lib/ronin/model/has_title.rb +3 -3
- data/lib/ronin/model/has_unique_name.rb +5 -7
- data/lib/ronin/model/has_version.rb +3 -3
- data/lib/ronin/model/importable.rb +3 -3
- data/lib/ronin/model/model.rb +7 -8
- data/lib/ronin/model/types.rb +3 -3
- data/lib/ronin/model/types/description.rb +9 -12
- data/lib/ronin/open_port.rb +5 -7
- data/lib/ronin/organization.rb +3 -3
- data/lib/ronin/os.rb +5 -7
- data/lib/ronin/os_guess.rb +3 -3
- data/lib/ronin/password.rb +3 -3
- data/lib/ronin/port.rb +3 -3
- data/lib/ronin/repositories.rb +3 -3
- data/lib/ronin/repository.rb +3 -3
- data/lib/ronin/ronin.rb +3 -3
- data/lib/ronin/script.rb +3 -3
- data/lib/ronin/script/buildable.rb +3 -3
- data/lib/ronin/script/deployable.rb +3 -3
- data/lib/ronin/script/exceptions.rb +3 -3
- data/lib/ronin/script/exceptions/build_failed.rb +3 -3
- data/lib/ronin/script/exceptions/deploy_failed.rb +3 -3
- data/lib/ronin/script/exceptions/exception.rb +3 -3
- data/lib/ronin/script/exceptions/not_built.rb +3 -3
- data/lib/ronin/script/exceptions/test_failed.rb +3 -3
- data/lib/ronin/script/path.rb +3 -3
- data/lib/ronin/script/script.rb +3 -3
- data/lib/ronin/script/testable.rb +3 -3
- data/lib/ronin/service.rb +3 -3
- data/lib/ronin/service_credential.rb +3 -3
- data/lib/ronin/software.rb +3 -3
- data/lib/ronin/spec/database.rb +27 -21
- data/lib/ronin/target.rb +3 -3
- data/lib/ronin/tcp_port.rb +3 -3
- data/lib/ronin/udp_port.rb +3 -3
- data/lib/ronin/ui.rb +3 -3
- data/lib/ronin/ui/cli.rb +3 -3
- data/lib/ronin/ui/cli/class_command.rb +14 -7
- data/lib/ronin/ui/cli/cli.rb +5 -5
- data/lib/ronin/ui/cli/command.rb +5 -7
- data/lib/ronin/ui/cli/commands.rb +3 -3
- data/lib/ronin/ui/cli/commands/campaigns.rb +5 -7
- data/lib/ronin/ui/cli/commands/console.rb +3 -3
- data/lib/ronin/ui/cli/commands/creds.rb +3 -3
- data/lib/ronin/ui/cli/commands/database.rb +3 -3
- data/lib/ronin/ui/cli/commands/emails.rb +3 -3
- data/lib/ronin/ui/cli/commands/exec.rb +3 -3
- data/lib/ronin/ui/cli/commands/fuzzer.rb +16 -16
- data/lib/ronin/ui/cli/commands/help.rb +3 -3
- data/lib/ronin/ui/cli/commands/hosts.rb +5 -7
- data/lib/ronin/ui/cli/commands/install.rb +7 -11
- data/lib/ronin/ui/cli/commands/ips.rb +5 -7
- data/lib/ronin/ui/cli/commands/net/proxy.rb +19 -12
- data/lib/ronin/ui/cli/commands/repos.rb +3 -3
- data/lib/ronin/ui/cli/commands/uninstall.rb +3 -3
- data/lib/ronin/ui/cli/commands/update.rb +3 -3
- data/lib/ronin/ui/cli/commands/urls.rb +3 -3
- data/lib/ronin/ui/cli/commands/wordlist.rb +3 -3
- data/lib/ronin/ui/cli/exceptions.rb +3 -3
- data/lib/ronin/ui/cli/exceptions/unknown_command.rb +3 -3
- data/lib/ronin/ui/cli/model_command.rb +6 -9
- data/lib/ronin/ui/cli/printing.rb +3 -3
- data/lib/ronin/ui/cli/resources_command.rb +7 -11
- data/lib/ronin/ui/cli/script_command.rb +5 -10
- data/lib/ronin/ui/console.rb +3 -3
- data/lib/ronin/ui/console/commands.rb +3 -3
- data/lib/ronin/ui/console/console.rb +3 -3
- data/lib/ronin/ui/console/context.rb +3 -3
- data/lib/ronin/ui/console/shell.rb +3 -3
- data/lib/ronin/url.rb +5 -7
- data/lib/ronin/url_query_param.rb +3 -3
- data/lib/ronin/url_query_param_name.rb +6 -6
- data/lib/ronin/url_scheme.rb +4 -4
- data/lib/ronin/user_name.rb +3 -3
- data/lib/ronin/vendor.rb +3 -3
- data/lib/ronin/version.rb +5 -5
- data/lib/ronin/web_credential.rb +5 -7
- data/man/ronin-campaigns.1.md +20 -20
- data/man/ronin-console.1.md +17 -17
- data/man/ronin-creds.1.md +16 -16
- data/man/ronin-database.1.md +23 -23
- data/man/ronin-emails.1.md +18 -18
- data/man/ronin-exec.1.md +11 -11
- data/man/ronin-fuzzer.1.md +23 -23
- data/man/ronin-help.1.md +5 -5
- data/man/ronin-hosts.1.md +20 -20
- data/man/ronin-install.1.md +18 -18
- data/man/ronin-ips.1.md +21 -21
- data/man/ronin-net-proxy.1.md +24 -24
- data/man/ronin-repos.1.md +18 -18
- data/man/ronin-uninstall.1.md +14 -14
- data/man/ronin-update.1.md +14 -14
- data/man/ronin-urls.1.md +22 -22
- data/man/ronin-wordlist.1.md +14 -13
- data/man/ronin.1.md +1 -1
- data/spec/arch_spec.rb +59 -46
- data/spec/author_spec.rb +14 -14
- data/spec/campaign_spec.rb +8 -0
- data/spec/credential_spec.rb +11 -8
- data/spec/database_spec.rb +6 -6
- data/spec/email_address_spec.rb +23 -20
- data/spec/host_name_spec.rb +24 -22
- data/spec/installation_spec.rb +6 -6
- data/spec/ip_address_spec.rb +31 -26
- data/spec/license_spec.rb +15 -9
- data/spec/mac_address_spec.rb +17 -8
- data/spec/model/has_authors_spec.rb +56 -37
- data/spec/model/has_description_spec.rb +36 -23
- data/spec/model/has_license_spec.rb +38 -28
- data/spec/model/has_name_spec.rb +36 -19
- data/spec/model/has_title_spec.rb +27 -14
- data/spec/model/has_version_spec.rb +64 -35
- data/spec/model/model_spec.rb +57 -33
- data/spec/model/models/{basic_model.rb → base_model.rb} +1 -1
- data/spec/model/models/{custom_model.rb → inherited_model.rb} +2 -3
- data/spec/os_spec.rb +24 -20
- data/spec/password_spec.rb +17 -9
- data/spec/port_spec.rb +30 -22
- data/spec/repository_spec.rb +59 -60
- data/spec/ronin_spec.rb +4 -4
- data/spec/script/buildable_spec.rb +8 -8
- data/spec/script/deployable_spec.rb +7 -7
- data/spec/script/path_spec.rb +42 -40
- data/spec/script/script_spec.rb +23 -23
- data/spec/script/testable_spec.rb +20 -20
- data/spec/service_spec.rb +14 -8
- data/spec/software_spec.rb +30 -17
- data/spec/spec_helper.rb +4 -4
- data/spec/ui/cli/classes/test_command.rb +2 -4
- data/spec/ui/cli/cli_spec.rb +5 -5
- data/spec/ui/cli/command_spec.rb +34 -30
- data/spec/url_query_param_spec.rb +23 -14
- data/spec/url_scheme_spec.rb +12 -9
- data/spec/url_spec.rb +64 -61
- data/spec/vendor_spec.rb +15 -8
- metadata +122 -150
- data/.gemtest +0 -0
data/spec/license_spec.rb
CHANGED
@@ -1,19 +1,25 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
|
2
3
|
require 'ronin/license'
|
3
4
|
|
4
5
|
describe License do
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
describe "validations" do
|
7
|
+
it "should require name and description attributes" do
|
8
|
+
expect(subject).not_to be_valid
|
8
9
|
|
9
|
-
|
10
|
-
|
10
|
+
subject.name = 'joke'
|
11
|
+
expect(subject).not_to be_valid
|
11
12
|
|
12
|
-
|
13
|
-
|
13
|
+
subject.description = "yep, it's a joke."
|
14
|
+
expect(subject).to be_valid
|
15
|
+
end
|
14
16
|
end
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
+
describe "predefined licenses" do
|
19
|
+
subject { described_class }
|
20
|
+
|
21
|
+
it "should provide built-in licenses"do
|
22
|
+
expect(subject.cc_by).not_to be_nil
|
23
|
+
end
|
18
24
|
end
|
19
25
|
end
|
data/spec/mac_address_spec.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
|
2
3
|
require 'ronin/mac_address'
|
3
4
|
|
4
5
|
describe MACAddress do
|
5
6
|
let(:address) { '00:01:02:03:04:05' }
|
6
7
|
|
7
|
-
subject {
|
8
|
+
subject { described_class.new(:address => address) }
|
8
9
|
|
9
10
|
describe "extract" do
|
10
11
|
subject { described_class }
|
@@ -14,7 +15,7 @@ describe MACAddress do
|
|
14
15
|
let(:text) { "MACs: #{mac1}, #{mac2}." }
|
15
16
|
|
16
17
|
it "should extract multiple MAC Addresses from text" do
|
17
|
-
subject.extract(text).
|
18
|
+
expect(subject.extract(text)).to eq([mac1, mac2])
|
18
19
|
end
|
19
20
|
|
20
21
|
it "should yield the extracted MAC Addresses if a block is given" do
|
@@ -22,17 +23,25 @@ describe MACAddress do
|
|
22
23
|
|
23
24
|
subject.extract(text) { |mac| macs << mac }
|
24
25
|
|
25
|
-
macs.
|
26
|
+
expect(macs).to eq([mac1, mac2])
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
29
|
-
|
30
|
-
|
30
|
+
describe "validations" do
|
31
|
+
it "should require an address" do
|
32
|
+
mac = described_class.new
|
33
|
+
expect(mac).not_to be_valid
|
31
34
|
|
32
|
-
|
35
|
+
mac.address = address
|
36
|
+
expect(mac).to be_valid
|
37
|
+
end
|
33
38
|
end
|
34
39
|
|
35
|
-
|
36
|
-
|
40
|
+
describe "#to_i" do
|
41
|
+
let(:integer) { 0x000102030405 }
|
42
|
+
|
43
|
+
it "should convert the MAC Address to an Integer" do
|
44
|
+
expect(subject.to_i).to eq(integer)
|
45
|
+
end
|
37
46
|
end
|
38
47
|
end
|
@@ -4,57 +4,76 @@ require 'model/models/authored_model'
|
|
4
4
|
require 'ronin/model/has_authors'
|
5
5
|
|
6
6
|
describe Model::HasAuthors do
|
7
|
-
|
7
|
+
let(:model) { AuthoredModel }
|
8
8
|
|
9
|
-
|
10
|
-
subject
|
9
|
+
describe ".included" do
|
10
|
+
subject { model }
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
:email => 'alice@example.com',
|
16
|
-
:organization => 'Crew'
|
17
|
-
)
|
12
|
+
it "should include Ronin::Model" do
|
13
|
+
expect(subject.ancestors).to include(Model)
|
14
|
+
end
|
18
15
|
|
19
|
-
|
20
|
-
|
16
|
+
it "should define an authors relationship" do
|
17
|
+
relationship = subject.relationships['authors']
|
21
18
|
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
expect(relationship).not_to be_nil
|
20
|
+
expect(relationship.child_model).to eq(Author)
|
21
|
+
end
|
25
22
|
|
26
|
-
|
27
|
-
|
23
|
+
it "should define relationships with Author" do
|
24
|
+
relationship = Author.relationships['authored_models']
|
28
25
|
|
29
|
-
|
30
|
-
|
26
|
+
expect(relationship).not_to be_nil
|
27
|
+
expect(relationship.child_model).to eq(subject)
|
28
|
+
end
|
31
29
|
end
|
32
30
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
relationship.should_not be_nil
|
37
|
-
relationship.child_model.should == subject
|
38
|
-
end
|
31
|
+
let(:author_name) { 'Alice' }
|
32
|
+
let(:author_email) { 'alice@example.com' }
|
33
|
+
let(:organization) { 'Org' }
|
39
34
|
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
describe "#author" do
|
36
|
+
subject do
|
37
|
+
model.new.tap do |resource|
|
38
|
+
resource.author(:name => author_name, :email => author_email)
|
39
|
+
end
|
40
|
+
end
|
43
41
|
|
44
|
-
|
42
|
+
it "should allow adding authors to a resource" do
|
43
|
+
expect(subject.authors).not_to be_empty
|
44
|
+
expect(subject.authors[0].name).to be(author_name)
|
45
|
+
expect(subject.authors[0].email).to be(author_email)
|
46
|
+
end
|
45
47
|
end
|
46
48
|
|
47
|
-
|
48
|
-
|
49
|
+
describe ".written_by" do
|
50
|
+
subject { model }
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
|
52
|
+
before do
|
53
|
+
resource = subject.new(:content => 'Test')
|
54
|
+
resource.author(
|
55
|
+
:name => author_name,
|
56
|
+
:email => author_email,
|
57
|
+
:organization => organization
|
58
|
+
)
|
59
|
+
|
60
|
+
resource.save
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should allow querying resources based on their Author" do
|
64
|
+
resources = subject.written_by(author_name)
|
65
|
+
|
66
|
+
expect(resources.length).to eq(1)
|
67
|
+
expect(resources[0].authors[0].name).to be == author_name
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should allow querying resources based on their Organization" do
|
71
|
+
resources = subject.written_for(organization)
|
53
72
|
|
54
|
-
|
55
|
-
|
73
|
+
expect(resources.length).to eq(1)
|
74
|
+
expect(resources[0].authors[0].organization).to be == organization
|
75
|
+
end
|
56
76
|
|
57
|
-
|
58
|
-
resources[0].authors[0].organization.should == 'Crew'
|
77
|
+
after { subject.destroy }
|
59
78
|
end
|
60
79
|
end
|
@@ -4,60 +4,73 @@ require 'model/models/described_model'
|
|
4
4
|
require 'ronin/model/has_description'
|
5
5
|
|
6
6
|
describe Model::HasDescription do
|
7
|
-
|
7
|
+
let(:model) { DescribedModel }
|
8
8
|
|
9
|
-
|
9
|
+
describe ".included" do
|
10
|
+
subject { model }
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
it "should include Ronin::Model" do
|
13
|
+
expect(subject.ancestors).to include(Model)
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
it "should define a description property" do
|
17
|
+
expect(subject.properties).to be_named(:description)
|
18
|
+
end
|
17
19
|
end
|
18
20
|
|
19
21
|
describe "#description" do
|
20
|
-
|
22
|
+
subject { model.new }
|
21
23
|
|
22
24
|
it "should allow the setting of the description" do
|
23
|
-
|
24
|
-
|
25
|
+
subject.description = 'test one'
|
26
|
+
expect(subject.description).to eq('test one')
|
25
27
|
end
|
26
28
|
|
27
29
|
it "should strip leading and tailing white-space" do
|
28
|
-
|
30
|
+
subject.description = %{ test two }
|
29
31
|
|
30
|
-
|
32
|
+
expect(subject.description).to eq('test two')
|
31
33
|
end
|
32
34
|
|
33
35
|
it "should strip leading and tailing white-space from each line" do
|
34
|
-
|
36
|
+
subject.description = %{
|
35
37
|
test
|
36
38
|
three
|
37
39
|
}
|
38
40
|
|
39
|
-
|
41
|
+
expect(subject.description).to eq("test\nthree")
|
40
42
|
end
|
41
43
|
|
42
44
|
it "should preserve non-bordering empty lines" do
|
43
|
-
|
45
|
+
subject.description = %{
|
44
46
|
test
|
45
47
|
|
46
48
|
four
|
47
49
|
}
|
48
50
|
|
49
|
-
|
51
|
+
expect(subject.description).to eq("test\n\nfour")
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
53
|
-
|
54
|
-
subject
|
55
|
-
|
55
|
+
describe ".describing" do
|
56
|
+
subject { model }
|
57
|
+
|
58
|
+
let(:description1) { 'foo one' }
|
59
|
+
let(:description2) { 'foo bar two' }
|
56
60
|
|
57
|
-
|
61
|
+
before do
|
62
|
+
subject.create!(:description => description1)
|
63
|
+
subject.create!(:description => description2)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should be able to find resources with similar descriptions" do
|
67
|
+
resources = subject.describing('foo')
|
68
|
+
|
69
|
+
expect(resources.length).to be(2)
|
70
|
+
expect(resources[0].description).to be == description1
|
71
|
+
expect(resources[1].description).to be == description2
|
72
|
+
end
|
58
73
|
|
59
|
-
|
60
|
-
resources[0].description.should == 'foo one'
|
61
|
-
resources[1].description.should == 'foo bar two'
|
74
|
+
after { subject.destroy }
|
62
75
|
end
|
63
76
|
end
|
@@ -4,60 +4,70 @@ require 'model/models/licensed_model'
|
|
4
4
|
require 'ronin/model/has_license'
|
5
5
|
|
6
6
|
describe Model::HasLicense do
|
7
|
-
|
7
|
+
let(:model) { LicensedModel }
|
8
8
|
|
9
|
-
|
10
|
-
subject
|
9
|
+
describe ".included" do
|
10
|
+
subject { model }
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
)
|
16
|
-
end
|
12
|
+
it "should include Ronin::Model" do
|
13
|
+
expect(subject.ancestors).to include(Model)
|
14
|
+
end
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
end
|
16
|
+
it "should define a license relationship" do
|
17
|
+
relationship = subject.relationships['license']
|
21
18
|
|
22
|
-
|
23
|
-
|
19
|
+
expect(relationship).not_to be_nil
|
20
|
+
expect(relationship.parent_model).to eq(License)
|
21
|
+
end
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
end
|
23
|
+
it "should define relationships with License" do
|
24
|
+
relationship = License.relationships['licensed_models']
|
28
25
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
relationship.should_not be_nil
|
33
|
-
relationship.child_model.should == subject
|
26
|
+
expect(relationship).not_to be_nil
|
27
|
+
expect(relationship.child_model).to eq(subject)
|
28
|
+
end
|
34
29
|
end
|
35
30
|
|
36
|
-
|
37
|
-
|
31
|
+
describe "validations" do
|
32
|
+
subject { model }
|
38
33
|
|
39
|
-
|
34
|
+
it "should not require a license" do
|
35
|
+
resource = subject.new(:content => 'bla')
|
36
|
+
|
37
|
+
expect(resource).to be_valid
|
38
|
+
end
|
40
39
|
end
|
41
40
|
|
42
|
-
describe "licensed_under" do
|
41
|
+
describe ".licensed_under" do
|
42
|
+
subject { model }
|
43
|
+
|
44
|
+
before do
|
45
|
+
subject.create(
|
46
|
+
:content => 'stuff here',
|
47
|
+
:license => License.gpl2
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
43
51
|
let(:license) { License.gpl2 }
|
44
52
|
|
45
53
|
it "should accept License resources" do
|
46
54
|
resource = subject.licensed_under(license).first
|
47
55
|
|
48
|
-
resource.license.
|
56
|
+
expect(resource.license).to be == license
|
49
57
|
end
|
50
58
|
|
51
59
|
it "should accept the names of predefined Licenses" do
|
52
60
|
resource = subject.licensed_under(:gpl2).first
|
53
61
|
|
54
|
-
resource.license.
|
62
|
+
expect(resource.license).to be == license
|
55
63
|
end
|
56
64
|
|
57
65
|
it "should accept the names of licenses" do
|
58
66
|
resource = subject.licensed_under('GPL-2').first
|
59
67
|
|
60
|
-
resource.license.
|
68
|
+
expect(resource.license).to be == license
|
61
69
|
end
|
70
|
+
|
71
|
+
after { subject.destroy }
|
62
72
|
end
|
63
73
|
end
|
data/spec/model/has_name_spec.rb
CHANGED
@@ -4,34 +4,51 @@ require 'model/models/named_model'
|
|
4
4
|
require 'ronin/model/has_name'
|
5
5
|
|
6
6
|
describe Model::HasName do
|
7
|
-
|
7
|
+
let(:model) { NamedModel }
|
8
8
|
|
9
|
-
|
9
|
+
describe ".included" do
|
10
|
+
subject { model }
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
it "should include Ronin::Model" do
|
13
|
+
expect(subject.ancestors).to include(Model)
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
it "should define a name property" do
|
17
|
+
expect(subject.properties).to be_named(:name)
|
18
|
+
end
|
17
19
|
end
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
describe "validations" do
|
22
|
+
subject { model }
|
23
|
+
|
24
|
+
it "should require a name" do
|
25
|
+
resource = subject.new
|
26
|
+
expect(resource).not_to be_valid
|
22
27
|
|
23
|
-
|
24
|
-
|
28
|
+
resource.name = 'foo'
|
29
|
+
expect(resource).to be_valid
|
30
|
+
end
|
25
31
|
end
|
26
32
|
|
27
|
-
|
28
|
-
subject
|
29
|
-
|
33
|
+
describe ".named" do
|
34
|
+
subject { model }
|
35
|
+
|
36
|
+
let(:name1) { 'foo1' }
|
37
|
+
let(:name2) { 'foo2' }
|
38
|
+
|
39
|
+
before do
|
40
|
+
subject.create!(:name => name1)
|
41
|
+
subject.create!(:name => name2)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should be able to find resources with similar names" do
|
45
|
+
resources = subject.named('foo')
|
30
46
|
|
31
|
-
|
47
|
+
expect(resources.length).to eq(2)
|
48
|
+
expect(resources[0].name).to be == name1
|
49
|
+
expect(resources[1].name).to be == name2
|
50
|
+
end
|
32
51
|
|
33
|
-
|
34
|
-
resources[0].name.should == 'foo1'
|
35
|
-
resources[1].name.should == 'foo2'
|
52
|
+
after { subject.destroy }
|
36
53
|
end
|
37
54
|
end
|