ronin 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +11 -0
  3. data/.github/workflows/ruby.yml +32 -0
  4. data/.gitignore +7 -7
  5. data/.ruby-version +1 -0
  6. data/COPYING.txt +3 -3
  7. data/ChangeLog.md +25 -11
  8. data/Gemfile +21 -20
  9. data/README.md +102 -81
  10. data/Rakefile +4 -5
  11. data/bin/ronin +7 -12
  12. data/bin/ronin-campaigns +7 -12
  13. data/bin/ronin-console +7 -12
  14. data/bin/ronin-creds +7 -12
  15. data/bin/ronin-database +7 -12
  16. data/bin/ronin-emails +7 -12
  17. data/bin/ronin-exec +7 -12
  18. data/bin/ronin-fuzzer +7 -12
  19. data/bin/ronin-help +7 -12
  20. data/bin/ronin-hosts +7 -12
  21. data/bin/ronin-install +7 -12
  22. data/bin/ronin-ips +7 -12
  23. data/bin/ronin-net-proxy +7 -12
  24. data/bin/ronin-repos +7 -12
  25. data/bin/ronin-uninstall +7 -12
  26. data/bin/ronin-update +7 -12
  27. data/bin/ronin-urls +7 -12
  28. data/bin/ronin-wordlist +7 -12
  29. data/gemspec.yml +8 -8
  30. data/lib/bond/completions/ronin.rb +23 -23
  31. data/lib/ronin.rb +3 -3
  32. data/lib/ronin/address.rb +6 -7
  33. data/lib/ronin/arch.rb +3 -3
  34. data/lib/ronin/author.rb +5 -7
  35. data/lib/ronin/auto_load.rb +5 -5
  36. data/lib/ronin/bootstrap.rb +3 -3
  37. data/lib/ronin/campaign.rb +3 -3
  38. data/lib/ronin/config.rb +5 -7
  39. data/lib/ronin/credential.rb +3 -3
  40. data/lib/ronin/database.rb +3 -3
  41. data/lib/ronin/database/database.rb +8 -12
  42. data/lib/ronin/database/exceptions.rb +3 -3
  43. data/lib/ronin/database/exceptions/invalid_config.rb +3 -3
  44. data/lib/ronin/database/exceptions/unknown_repository.rb +3 -3
  45. data/lib/ronin/database/migrations.rb +3 -3
  46. data/lib/ronin/database/migrations/1.0.0.rb +3 -3
  47. data/lib/ronin/database/migrations/1.1.0.rb +3 -3
  48. data/lib/ronin/database/migrations/exceptions.rb +3 -3
  49. data/lib/ronin/database/migrations/exceptions/duplicate_migration.rb +3 -3
  50. data/lib/ronin/database/migrations/exceptions/unknown_migration.rb +3 -3
  51. data/lib/ronin/database/migrations/graph.rb +3 -3
  52. data/lib/ronin/database/migrations/migration.rb +3 -3
  53. data/lib/ronin/database/migrations/migrations.rb +3 -3
  54. data/lib/ronin/email_address.rb +5 -7
  55. data/lib/ronin/environment.rb +3 -3
  56. data/lib/ronin/exceptions.rb +3 -3
  57. data/lib/ronin/exceptions/duplicate_repository.rb +3 -3
  58. data/lib/ronin/exceptions/repository_not_found.rb +3 -3
  59. data/lib/ronin/host_name.rb +3 -3
  60. data/lib/ronin/host_name_ip_address.rb +3 -3
  61. data/lib/ronin/installation.rb +5 -7
  62. data/lib/ronin/ip_address.rb +6 -8
  63. data/lib/ronin/ip_address_mac_address.rb +3 -3
  64. data/lib/ronin/license.rb +6 -6
  65. data/lib/ronin/mac_address.rb +3 -3
  66. data/lib/ronin/model.rb +3 -3
  67. data/lib/ronin/model/has_authors.rb +3 -3
  68. data/lib/ronin/model/has_description.rb +3 -3
  69. data/lib/ronin/model/has_license.rb +3 -3
  70. data/lib/ronin/model/has_name.rb +3 -3
  71. data/lib/ronin/model/has_title.rb +3 -3
  72. data/lib/ronin/model/has_unique_name.rb +5 -7
  73. data/lib/ronin/model/has_version.rb +3 -3
  74. data/lib/ronin/model/importable.rb +3 -3
  75. data/lib/ronin/model/model.rb +7 -8
  76. data/lib/ronin/model/types.rb +3 -3
  77. data/lib/ronin/model/types/description.rb +9 -12
  78. data/lib/ronin/open_port.rb +5 -7
  79. data/lib/ronin/organization.rb +3 -3
  80. data/lib/ronin/os.rb +5 -7
  81. data/lib/ronin/os_guess.rb +3 -3
  82. data/lib/ronin/password.rb +3 -3
  83. data/lib/ronin/port.rb +3 -3
  84. data/lib/ronin/repositories.rb +3 -3
  85. data/lib/ronin/repository.rb +3 -3
  86. data/lib/ronin/ronin.rb +3 -3
  87. data/lib/ronin/script.rb +3 -3
  88. data/lib/ronin/script/buildable.rb +3 -3
  89. data/lib/ronin/script/deployable.rb +3 -3
  90. data/lib/ronin/script/exceptions.rb +3 -3
  91. data/lib/ronin/script/exceptions/build_failed.rb +3 -3
  92. data/lib/ronin/script/exceptions/deploy_failed.rb +3 -3
  93. data/lib/ronin/script/exceptions/exception.rb +3 -3
  94. data/lib/ronin/script/exceptions/not_built.rb +3 -3
  95. data/lib/ronin/script/exceptions/test_failed.rb +3 -3
  96. data/lib/ronin/script/path.rb +3 -3
  97. data/lib/ronin/script/script.rb +3 -3
  98. data/lib/ronin/script/testable.rb +3 -3
  99. data/lib/ronin/service.rb +3 -3
  100. data/lib/ronin/service_credential.rb +3 -3
  101. data/lib/ronin/software.rb +3 -3
  102. data/lib/ronin/spec/database.rb +27 -21
  103. data/lib/ronin/target.rb +3 -3
  104. data/lib/ronin/tcp_port.rb +3 -3
  105. data/lib/ronin/udp_port.rb +3 -3
  106. data/lib/ronin/ui.rb +3 -3
  107. data/lib/ronin/ui/cli.rb +3 -3
  108. data/lib/ronin/ui/cli/class_command.rb +14 -7
  109. data/lib/ronin/ui/cli/cli.rb +5 -5
  110. data/lib/ronin/ui/cli/command.rb +5 -7
  111. data/lib/ronin/ui/cli/commands.rb +3 -3
  112. data/lib/ronin/ui/cli/commands/campaigns.rb +5 -7
  113. data/lib/ronin/ui/cli/commands/console.rb +3 -3
  114. data/lib/ronin/ui/cli/commands/creds.rb +3 -3
  115. data/lib/ronin/ui/cli/commands/database.rb +3 -3
  116. data/lib/ronin/ui/cli/commands/emails.rb +3 -3
  117. data/lib/ronin/ui/cli/commands/exec.rb +3 -3
  118. data/lib/ronin/ui/cli/commands/fuzzer.rb +16 -16
  119. data/lib/ronin/ui/cli/commands/help.rb +3 -3
  120. data/lib/ronin/ui/cli/commands/hosts.rb +5 -7
  121. data/lib/ronin/ui/cli/commands/install.rb +7 -11
  122. data/lib/ronin/ui/cli/commands/ips.rb +5 -7
  123. data/lib/ronin/ui/cli/commands/net/proxy.rb +19 -12
  124. data/lib/ronin/ui/cli/commands/repos.rb +3 -3
  125. data/lib/ronin/ui/cli/commands/uninstall.rb +3 -3
  126. data/lib/ronin/ui/cli/commands/update.rb +3 -3
  127. data/lib/ronin/ui/cli/commands/urls.rb +3 -3
  128. data/lib/ronin/ui/cli/commands/wordlist.rb +3 -3
  129. data/lib/ronin/ui/cli/exceptions.rb +3 -3
  130. data/lib/ronin/ui/cli/exceptions/unknown_command.rb +3 -3
  131. data/lib/ronin/ui/cli/model_command.rb +6 -9
  132. data/lib/ronin/ui/cli/printing.rb +3 -3
  133. data/lib/ronin/ui/cli/resources_command.rb +7 -11
  134. data/lib/ronin/ui/cli/script_command.rb +5 -10
  135. data/lib/ronin/ui/console.rb +3 -3
  136. data/lib/ronin/ui/console/commands.rb +3 -3
  137. data/lib/ronin/ui/console/console.rb +3 -3
  138. data/lib/ronin/ui/console/context.rb +3 -3
  139. data/lib/ronin/ui/console/shell.rb +3 -3
  140. data/lib/ronin/url.rb +5 -7
  141. data/lib/ronin/url_query_param.rb +3 -3
  142. data/lib/ronin/url_query_param_name.rb +6 -6
  143. data/lib/ronin/url_scheme.rb +4 -4
  144. data/lib/ronin/user_name.rb +3 -3
  145. data/lib/ronin/vendor.rb +3 -3
  146. data/lib/ronin/version.rb +5 -5
  147. data/lib/ronin/web_credential.rb +5 -7
  148. data/man/ronin-campaigns.1.md +20 -20
  149. data/man/ronin-console.1.md +17 -17
  150. data/man/ronin-creds.1.md +16 -16
  151. data/man/ronin-database.1.md +23 -23
  152. data/man/ronin-emails.1.md +18 -18
  153. data/man/ronin-exec.1.md +11 -11
  154. data/man/ronin-fuzzer.1.md +23 -23
  155. data/man/ronin-help.1.md +5 -5
  156. data/man/ronin-hosts.1.md +20 -20
  157. data/man/ronin-install.1.md +18 -18
  158. data/man/ronin-ips.1.md +21 -21
  159. data/man/ronin-net-proxy.1.md +24 -24
  160. data/man/ronin-repos.1.md +18 -18
  161. data/man/ronin-uninstall.1.md +14 -14
  162. data/man/ronin-update.1.md +14 -14
  163. data/man/ronin-urls.1.md +22 -22
  164. data/man/ronin-wordlist.1.md +14 -13
  165. data/man/ronin.1.md +1 -1
  166. data/spec/arch_spec.rb +59 -46
  167. data/spec/author_spec.rb +14 -14
  168. data/spec/campaign_spec.rb +8 -0
  169. data/spec/credential_spec.rb +11 -8
  170. data/spec/database_spec.rb +6 -6
  171. data/spec/email_address_spec.rb +23 -20
  172. data/spec/host_name_spec.rb +24 -22
  173. data/spec/installation_spec.rb +6 -6
  174. data/spec/ip_address_spec.rb +31 -26
  175. data/spec/license_spec.rb +15 -9
  176. data/spec/mac_address_spec.rb +17 -8
  177. data/spec/model/has_authors_spec.rb +56 -37
  178. data/spec/model/has_description_spec.rb +36 -23
  179. data/spec/model/has_license_spec.rb +38 -28
  180. data/spec/model/has_name_spec.rb +36 -19
  181. data/spec/model/has_title_spec.rb +27 -14
  182. data/spec/model/has_version_spec.rb +64 -35
  183. data/spec/model/model_spec.rb +57 -33
  184. data/spec/model/models/{basic_model.rb → base_model.rb} +1 -1
  185. data/spec/model/models/{custom_model.rb → inherited_model.rb} +2 -3
  186. data/spec/os_spec.rb +24 -20
  187. data/spec/password_spec.rb +17 -9
  188. data/spec/port_spec.rb +30 -22
  189. data/spec/repository_spec.rb +59 -60
  190. data/spec/ronin_spec.rb +4 -4
  191. data/spec/script/buildable_spec.rb +8 -8
  192. data/spec/script/deployable_spec.rb +7 -7
  193. data/spec/script/path_spec.rb +42 -40
  194. data/spec/script/script_spec.rb +23 -23
  195. data/spec/script/testable_spec.rb +20 -20
  196. data/spec/service_spec.rb +14 -8
  197. data/spec/software_spec.rb +30 -17
  198. data/spec/spec_helper.rb +4 -4
  199. data/spec/ui/cli/classes/test_command.rb +2 -4
  200. data/spec/ui/cli/cli_spec.rb +5 -5
  201. data/spec/ui/cli/command_spec.rb +34 -30
  202. data/spec/url_query_param_spec.rb +23 -14
  203. data/spec/url_scheme_spec.rb +12 -9
  204. data/spec/url_spec.rb +64 -61
  205. data/spec/vendor_spec.rb +15 -8
  206. metadata +122 -150
  207. 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
- it "should require name and description attributes" do
6
- license = License.new
7
- license.should_not be_valid
6
+ describe "validations" do
7
+ it "should require name and description attributes" do
8
+ expect(subject).not_to be_valid
8
9
 
9
- license.name = 'joke'
10
- license.should_not be_valid
10
+ subject.name = 'joke'
11
+ expect(subject).not_to be_valid
11
12
 
12
- license.description = "yep, it's a joke."
13
- license.should be_valid
13
+ subject.description = "yep, it's a joke."
14
+ expect(subject).to be_valid
15
+ end
14
16
  end
15
17
 
16
- it "should provide built-in licenses"do
17
- License.cc_by.should_not be_nil
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
@@ -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 { MACAddress.new(:address => address) }
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).should == [mac1, mac2]
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.should == [mac1, mac2]
26
+ expect(macs).to eq([mac1, mac2])
26
27
  end
27
28
  end
28
29
 
29
- it "should require an address" do
30
- mac = MACAddress.new
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
- mac.should_not be_valid
35
+ mac.address = address
36
+ expect(mac).to be_valid
37
+ end
33
38
  end
34
39
 
35
- it "should convert the MAC Address to an Integer" do
36
- subject.to_i.should == 0x000102030405
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
- subject { AuthoredModel }
7
+ let(:model) { AuthoredModel }
8
8
 
9
- before(:all) do
10
- subject.auto_migrate!
9
+ describe ".included" do
10
+ subject { model }
11
11
 
12
- resource = subject.new(:content => 'Test')
13
- resource.author(
14
- :name => 'Alice',
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
- resource.save
20
- end
16
+ it "should define an authors relationship" do
17
+ relationship = subject.relationships['authors']
21
18
 
22
- it "should include Ronin::Model" do
23
- subject.ancestors.should include(Model)
24
- end
19
+ expect(relationship).not_to be_nil
20
+ expect(relationship.child_model).to eq(Author)
21
+ end
25
22
 
26
- it "should define an authors relationship" do
27
- relationship = subject.relationships['authors']
23
+ it "should define relationships with Author" do
24
+ relationship = Author.relationships['authored_models']
28
25
 
29
- relationship.should_not be_nil
30
- relationship.child_model.should == Author
26
+ expect(relationship).not_to be_nil
27
+ expect(relationship.child_model).to eq(subject)
28
+ end
31
29
  end
32
30
 
33
- it "should define relationships with Author" do
34
- relationship = Author.relationships['authored_models']
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
- it "should allow adding authors to a resource" do
41
- resource = subject.new
42
- resource.author(:name => 'Alice', :email => 'alice@example.com')
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
- resource.authors.should_not be_empty
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
- it "should allow querying resources based on their Author" do
48
- resources = subject.written_by('Alice')
49
+ describe ".written_by" do
50
+ subject { model }
49
51
 
50
- resources.length.should == 1
51
- resources[0].authors[0].name.should == 'Alice'
52
- end
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
- it "should allow querying resources based on their Organization" do
55
- resources = subject.written_for('Crew')
73
+ expect(resources.length).to eq(1)
74
+ expect(resources[0].authors[0].organization).to be == organization
75
+ end
56
76
 
57
- resources.length.should == 1
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
- subject { DescribedModel }
7
+ let(:model) { DescribedModel }
8
8
 
9
- before(:all) { subject.auto_migrate! }
9
+ describe ".included" do
10
+ subject { model }
10
11
 
11
- it "should include Ronin::Model" do
12
- subject.ancestors.should include(Model)
13
- end
12
+ it "should include Ronin::Model" do
13
+ expect(subject.ancestors).to include(Model)
14
+ end
14
15
 
15
- it "should define a description property" do
16
- subject.properties.should be_named(:description)
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
- let(:resource) { DescribedModel.new }
22
+ subject { model.new }
21
23
 
22
24
  it "should allow the setting of the description" do
23
- resource.description = 'test one'
24
- resource.description.should == 'test one'
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
- resource.description = %{ test two }
30
+ subject.description = %{ test two }
29
31
 
30
- resource.description.should == 'test two'
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
- resource.description = %{
36
+ subject.description = %{
35
37
  test
36
38
  three
37
39
  }
38
40
 
39
- resource.description.should == "test\nthree"
41
+ expect(subject.description).to eq("test\nthree")
40
42
  end
41
43
 
42
44
  it "should preserve non-bordering empty lines" do
43
- resource.description = %{
45
+ subject.description = %{
44
46
  test
45
47
 
46
48
  four
47
49
  }
48
50
 
49
- resource.description.should == "test\n\nfour"
51
+ expect(subject.description).to eq("test\n\nfour")
50
52
  end
51
53
  end
52
54
 
53
- it "should be able to find resources with similar descriptions" do
54
- subject.create!(:description => 'foo one')
55
- subject.create!(:description => 'foo bar two')
55
+ describe ".describing" do
56
+ subject { model }
57
+
58
+ let(:description1) { 'foo one' }
59
+ let(:description2) { 'foo bar two' }
56
60
 
57
- resources = subject.describing('foo')
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
- resources.length.should == 2
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
- subject { LicensedModel }
7
+ let(:model) { LicensedModel }
8
8
 
9
- before(:all) do
10
- subject.auto_migrate!
9
+ describe ".included" do
10
+ subject { model }
11
11
 
12
- subject.create(
13
- :content => 'stuff here',
14
- :license => License.gpl2
15
- )
16
- end
12
+ it "should include Ronin::Model" do
13
+ expect(subject.ancestors).to include(Model)
14
+ end
17
15
 
18
- it "should include Ronin::Model" do
19
- subject.ancestors.should include(Model)
20
- end
16
+ it "should define a license relationship" do
17
+ relationship = subject.relationships['license']
21
18
 
22
- it "should define a license relationship" do
23
- relationship = subject.relationships['license']
19
+ expect(relationship).not_to be_nil
20
+ expect(relationship.parent_model).to eq(License)
21
+ end
24
22
 
25
- relationship.should_not be_nil
26
- relationship.parent_model.should == License
27
- end
23
+ it "should define relationships with License" do
24
+ relationship = License.relationships['licensed_models']
28
25
 
29
- it "should define relationships with License" do
30
- relationship = License.relationships['licensed_models']
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
- it "should not require a license" do
37
- resource = subject.new(:content => 'bla')
31
+ describe "validations" do
32
+ subject { model }
38
33
 
39
- resource.should be_valid
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.should == 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.should == 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.should == license
68
+ expect(resource.license).to be == license
61
69
  end
70
+
71
+ after { subject.destroy }
62
72
  end
63
73
  end
@@ -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
- subject { NamedModel }
7
+ let(:model) { NamedModel }
8
8
 
9
- before(:all) { subject.auto_migrate! }
9
+ describe ".included" do
10
+ subject { model }
10
11
 
11
- it "should include Ronin::Model" do
12
- subject.ancestors.should include(Model)
13
- end
12
+ it "should include Ronin::Model" do
13
+ expect(subject.ancestors).to include(Model)
14
+ end
14
15
 
15
- it "should define a name property" do
16
- subject.properties.should be_named(:name)
16
+ it "should define a name property" do
17
+ expect(subject.properties).to be_named(:name)
18
+ end
17
19
  end
18
20
 
19
- it "should require a name" do
20
- resource = subject.new
21
- resource.should_not be_valid
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
- resource.name = 'foo'
24
- resource.should be_valid
28
+ resource.name = 'foo'
29
+ expect(resource).to be_valid
30
+ end
25
31
  end
26
32
 
27
- it "should be able to find resources with similar names" do
28
- subject.create!(:name => 'foo1')
29
- subject.create!(:name => 'foo2')
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
- resources = subject.named('foo')
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
- resources.length.should == 2
34
- resources[0].name.should == 'foo1'
35
- resources[1].name.should == 'foo2'
52
+ after { subject.destroy }
36
53
  end
37
54
  end