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/script/path_spec.rb
CHANGED
@@ -10,73 +10,73 @@ describe Script::Path do
|
|
10
10
|
let(:repo) { repository('scripts') }
|
11
11
|
let(:script_class) { MyScript }
|
12
12
|
|
13
|
-
before
|
13
|
+
before { repo.cache_scripts! }
|
14
14
|
|
15
15
|
describe "cached file" do
|
16
16
|
subject { repo.find_script('cached/cached.rb') }
|
17
17
|
|
18
18
|
it "should be saved" do
|
19
|
-
subject.
|
19
|
+
expect(subject).to be_saved
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should have a path" do
|
23
|
-
subject.path.
|
23
|
+
expect(subject.path).not_to be_nil
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should have a timestamp" do
|
27
|
-
subject.timestamp.
|
27
|
+
expect(subject.timestamp).not_to be_nil
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should not have updated code" do
|
31
|
-
subject.
|
31
|
+
expect(subject).not_to be_updated
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should not have cache exceptions" do
|
35
|
-
subject.cache_exception.
|
35
|
+
expect(subject.cache_exception).to be_nil
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should not have cache errors" do
|
39
|
-
subject.cache_errors.
|
39
|
+
expect(subject.cache_errors).to be_nil
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should have the model name of the cached object" do
|
43
|
-
subject.class_name.
|
43
|
+
expect(subject.class_name).to eq(script_class.name)
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should have the model path of the cached object" do
|
47
|
-
subject.class_path.
|
47
|
+
expect(subject.class_path).to eq('my_script')
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should be able to load the Model of the cached object" do
|
51
|
-
subject.script_class.
|
51
|
+
expect(subject.script_class).to eq(script_class)
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should be able to load a fresh model from the cached file" do
|
55
55
|
obj = subject.load_script
|
56
56
|
|
57
|
-
obj.
|
58
|
-
obj.class.
|
57
|
+
expect(obj).not_to be_nil
|
58
|
+
expect(obj.class).to eq(script_class)
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should cache the loaded object along with the cached file" do
|
62
62
|
obj = script_class.first(:script_path => subject)
|
63
63
|
|
64
|
-
obj.
|
64
|
+
expect(obj).not_to be_nil
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should be able to load the cached object" do
|
68
|
-
subject.cached_script.
|
69
|
-
subject.cached_script.class.
|
68
|
+
expect(subject.cached_script).not_to be_nil
|
69
|
+
expect(subject.cached_script.class).to eq(script_class)
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should call the cache method before saving the new object" do
|
73
|
-
subject.cached_script.name.
|
73
|
+
expect(subject.cached_script.name).to eq('cached')
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should delete the cached object along with the cached file" do
|
77
77
|
subject.destroy
|
78
78
|
|
79
|
-
script_class.first(:script_path => subject).
|
79
|
+
expect(script_class.first(:script_path => subject)).to be_nil
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
@@ -89,41 +89,43 @@ describe Script::Path do
|
|
89
89
|
let(:validation_error) { repo.find_script('failures/validation_errors.rb') }
|
90
90
|
|
91
91
|
it "should not save new cached files that raised exceptions" do
|
92
|
-
syntax_error.
|
93
|
-
load_error.
|
94
|
-
exception.
|
92
|
+
expect(syntax_error).not_to be_saved
|
93
|
+
expect(load_error).not_to be_saved
|
94
|
+
expect(exception).not_to be_saved
|
95
95
|
end
|
96
96
|
|
97
|
-
|
98
|
-
|
97
|
+
pending "https://github.com/ronin-rb/ronin/issues/7" do
|
98
|
+
it "should not save new cached files that contain validation errors" do
|
99
|
+
expect(validation_error).to_not be_saved
|
100
|
+
end
|
99
101
|
end
|
100
102
|
|
101
103
|
it "should store syntax errors" do
|
102
|
-
syntax_error.cache_exception.
|
103
|
-
syntax_error.cache_exception.class.
|
104
|
+
expect(syntax_error.cache_exception).not_to be_nil
|
105
|
+
expect(syntax_error.cache_exception.class).to eq(SyntaxError)
|
104
106
|
end
|
105
107
|
|
106
108
|
it "should store LoadError exceptions" do
|
107
|
-
load_error.cache_exception.
|
108
|
-
load_error.cache_exception.class.
|
109
|
+
expect(load_error.cache_exception).not_to be_nil
|
110
|
+
expect(load_error.cache_exception.class).to eq(LoadError)
|
109
111
|
end
|
110
112
|
|
111
113
|
it "should store NameError exceptions" do
|
112
|
-
name_error.cache_exception.
|
113
|
-
name_error.cache_exception.class.
|
114
|
+
expect(name_error.cache_exception).not_to be_nil
|
115
|
+
expect(name_error.cache_exception.class).to eq(NameError)
|
114
116
|
end
|
115
117
|
|
116
118
|
it "should store NoMethodError exceptions" do
|
117
|
-
no_method_error.cache_exception.
|
118
|
-
no_method_error.cache_exception.class.
|
119
|
+
expect(no_method_error.cache_exception).not_to be_nil
|
120
|
+
expect(no_method_error.cache_exception.class).to eq(NoMethodError)
|
119
121
|
end
|
120
122
|
|
121
123
|
it "should store Exceptions raised when creating the fresh object" do
|
122
|
-
exception.cache_exception.
|
124
|
+
expect(exception.cache_exception).not_to be_nil
|
123
125
|
end
|
124
126
|
|
125
127
|
it "should store validation errors" do
|
126
|
-
validation_error.cache_errors.
|
128
|
+
expect(validation_error.cache_errors).not_to be_nil
|
127
129
|
end
|
128
130
|
end
|
129
131
|
|
@@ -135,18 +137,18 @@ describe Script::Path do
|
|
135
137
|
end
|
136
138
|
|
137
139
|
it "should not re-cache unmodified files" do
|
138
|
-
subject.sync.
|
140
|
+
expect(subject.sync).to be(false)
|
139
141
|
end
|
140
142
|
|
141
143
|
it "should not have cache errors" do
|
142
|
-
subject.cache_errors.
|
144
|
+
expect(subject.cache_errors).to be_nil
|
143
145
|
end
|
144
146
|
end
|
145
147
|
|
146
148
|
describe "modified cached file" do
|
147
149
|
subject { repo.find_script('cached/modified.rb') }
|
148
150
|
|
149
|
-
before
|
151
|
+
before do
|
150
152
|
subject.update(:timestamp => (subject.timestamp - 10))
|
151
153
|
end
|
152
154
|
|
@@ -155,29 +157,29 @@ describe Script::Path do
|
|
155
157
|
end
|
156
158
|
|
157
159
|
it "should re-cache modified files" do
|
158
|
-
subject.sync.
|
160
|
+
expect(subject.sync).to be(true)
|
159
161
|
end
|
160
162
|
|
161
163
|
it "should not have cache errors" do
|
162
|
-
subject.cache_errors.
|
164
|
+
expect(subject.cache_errors).to be_nil
|
163
165
|
end
|
164
166
|
end
|
165
167
|
|
166
168
|
describe "missing cached file" do
|
167
169
|
subject { repo.find_script('cached/missing.rb') }
|
168
170
|
|
169
|
-
before
|
171
|
+
before do
|
170
172
|
subject.update(:path => File.join('','missing','file.rb'))
|
171
173
|
|
172
174
|
subject.sync
|
173
175
|
end
|
174
176
|
|
175
177
|
it "should delete the cached files" do
|
176
|
-
described_class.count(:id => subject.id).
|
178
|
+
expect(described_class.count(:id => subject.id)).to eq(0)
|
177
179
|
end
|
178
180
|
|
179
181
|
it "should delete cached objects for missing files" do
|
180
|
-
script_class.count(:script_path => subject).
|
182
|
+
expect(script_class.count(:script_path => subject)).to eq(0)
|
181
183
|
end
|
182
184
|
end
|
183
185
|
end
|
data/spec/script/script_spec.rb
CHANGED
@@ -11,70 +11,70 @@ describe Script do
|
|
11
11
|
|
12
12
|
let(:repo) { repository('scripts') }
|
13
13
|
|
14
|
-
before
|
14
|
+
before { repo.cache_scripts! }
|
15
15
|
|
16
16
|
it "should be a Model" do
|
17
|
-
subject.included_modules.
|
17
|
+
expect(subject.included_modules).to include(Model)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should have a name" do
|
21
|
-
subject.included_modules.
|
21
|
+
expect(subject.included_modules).to include(Model::HasName)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should have a description" do
|
25
|
-
subject.included_modules.
|
25
|
+
expect(subject.included_modules).to include(Model::HasDescription)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should have a version" do
|
29
|
-
subject.included_modules.
|
29
|
+
expect(subject.included_modules).to include(Model::HasVersion)
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should include ObjectLoader" do
|
33
|
-
subject.included_modules.
|
33
|
+
expect(subject.included_modules).to include(ObjectLoader)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should include DataPaths::Finders" do
|
37
|
-
subject.included_modules.
|
37
|
+
expect(subject.included_modules).to include(DataPaths::Finders)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should include Parameters" do
|
41
|
-
subject.included_modules.
|
41
|
+
expect(subject.included_modules).to include(Parameters)
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should include UI::Output::Helpers" do
|
45
|
-
subject.included_modules.
|
45
|
+
expect(subject.included_modules).to include(UI::Output::Helpers)
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should add the type property to the model" do
|
49
|
-
subject.properties.
|
49
|
+
expect(subject.properties).to be_named(:type)
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should add a relation between Script::Path and the script" do
|
53
|
-
subject.relationships.
|
53
|
+
expect(subject.relationships).to be_named(:script_path)
|
54
54
|
end
|
55
55
|
|
56
56
|
describe "#initialize" do
|
57
57
|
it "should initialize attributes" do
|
58
58
|
resource = subject.new(:name => 'test')
|
59
59
|
|
60
|
-
resource.name.
|
60
|
+
expect(resource.name).to eq('test')
|
61
61
|
end
|
62
62
|
|
63
63
|
it "should initialize parameters" do
|
64
64
|
resource = subject.new(:x => 5)
|
65
65
|
|
66
|
-
resource.x.
|
66
|
+
expect(resource.x).to eq(5)
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should allow custom initialize methods" do
|
70
70
|
resource = subject.new
|
71
71
|
|
72
|
-
resource.var.
|
72
|
+
expect(resource.var).to eq(2)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should have an short-name" do
|
77
|
-
subject.short_name.
|
77
|
+
expect(subject.short_name).to eq('MyScript')
|
78
78
|
end
|
79
79
|
|
80
80
|
describe "load_from" do
|
@@ -83,23 +83,23 @@ describe Script do
|
|
83
83
|
subject { Script.load_from(path) }
|
84
84
|
|
85
85
|
it "should have a script_path resource" do
|
86
|
-
subject.script_path.
|
86
|
+
expect(subject.script_path).not_to be_nil
|
87
87
|
end
|
88
88
|
|
89
89
|
it "should prepare the object to be cached" do
|
90
|
-
subject.content.
|
90
|
+
expect(subject.content).to eq('this is a test')
|
91
91
|
end
|
92
92
|
|
93
93
|
it "should preserve instance variables" do
|
94
|
-
subject.var.
|
94
|
+
expect(subject.var).to eq(2)
|
95
95
|
end
|
96
96
|
|
97
97
|
it "should preserve instance methods" do
|
98
|
-
subject.greeting.
|
98
|
+
expect(subject.greeting).to eq('hello')
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should load the script source" do
|
102
|
-
subject.
|
102
|
+
expect(subject).to be_script_loaded
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
@@ -107,13 +107,13 @@ describe Script do
|
|
107
107
|
subject { MyScript.first(:name => 'test') }
|
108
108
|
|
109
109
|
it "should have a cached_file resource" do
|
110
|
-
subject.script_path.
|
110
|
+
expect(subject.script_path).not_to be_nil
|
111
111
|
end
|
112
112
|
|
113
113
|
it "should be able to load the script source" do
|
114
114
|
subject.load_script!
|
115
115
|
|
116
|
-
subject.greeting.
|
116
|
+
expect(subject.greeting).to eq('hello')
|
117
117
|
end
|
118
118
|
|
119
119
|
it "should only load the script source once" do
|
@@ -122,7 +122,7 @@ describe Script do
|
|
122
122
|
subject.var = false
|
123
123
|
subject.load_script!
|
124
124
|
|
125
|
-
subject.var.
|
125
|
+
expect(subject.var).to be(false)
|
126
126
|
end
|
127
127
|
end
|
128
128
|
end
|
@@ -17,10 +17,10 @@ describe Script::Testable do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
obj.var = 20
|
20
|
-
|
20
|
+
expect { obj.test! }.to raise_error(Script::TestFailed)
|
21
21
|
|
22
22
|
obj.var = 4
|
23
|
-
obj.test
|
23
|
+
expect(obj.test!).to be(true)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should test an expression is true" do
|
@@ -31,87 +31,87 @@ describe Script::Testable do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
obj.var = 1
|
34
|
-
|
34
|
+
expect { obj.test! }.to raise_error(Script::TestFailed)
|
35
35
|
|
36
36
|
obj.var = 2
|
37
|
-
obj.test
|
37
|
+
expect(obj.test!).to be(true)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should test a method returns an expected value" do
|
41
41
|
obj = subject.new { test_equal :var, 5 }
|
42
42
|
|
43
|
-
|
43
|
+
expect { obj.test! }.to raise_error(Script::TestFailed)
|
44
44
|
|
45
45
|
obj.var = 5
|
46
|
-
obj.test
|
46
|
+
expect(obj.test!).to be(true)
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should test a method does not return an expected value" do
|
50
50
|
obj = subject.new { test_not_equal :var, 5 }
|
51
51
|
|
52
52
|
obj.var = 5
|
53
|
-
|
53
|
+
expect { obj.test! }.to raise_error(Script::TestFailed)
|
54
54
|
|
55
55
|
obj.var = 2
|
56
|
-
obj.test
|
56
|
+
expect(obj.test!).to be(true)
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should test a method returns a non-nil value" do
|
60
60
|
obj = subject.new { test_set :var }
|
61
61
|
|
62
|
-
|
62
|
+
expect { obj.test! }.to raise_error(Script::TestFailed)
|
63
63
|
|
64
64
|
obj.var = 2
|
65
|
-
obj.test
|
65
|
+
expect(obj.test!).to be(true)
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should test a method returns a non-empty value" do
|
69
69
|
obj = subject.new { test_set :var }
|
70
70
|
|
71
71
|
obj.var = ''
|
72
|
-
|
72
|
+
expect { obj.test! }.to raise_error(Script::TestFailed)
|
73
73
|
|
74
74
|
obj.var = 'hello'
|
75
|
-
obj.test
|
75
|
+
expect(obj.test!).to be(true)
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should test a method matches a pattern" do
|
79
79
|
obj = subject.new { test_match :var, /lo/ }
|
80
80
|
|
81
81
|
obj.var = 'goodbye'
|
82
|
-
|
82
|
+
expect { obj.test! }.to raise_error(Script::TestFailed)
|
83
83
|
|
84
84
|
obj.var = 'hello'
|
85
|
-
obj.test
|
85
|
+
expect(obj.test!).to be(true)
|
86
86
|
end
|
87
87
|
|
88
88
|
it "should test a method does not match a pattern" do
|
89
89
|
obj = subject.new { test_no_match :var, /lo/ }
|
90
90
|
|
91
91
|
obj.var = 'hello'
|
92
|
-
|
92
|
+
expect { obj.test! }.to raise_error(Script::TestFailed)
|
93
93
|
|
94
94
|
obj.var = 'goodbye'
|
95
|
-
obj.test
|
95
|
+
expect(obj.test!).to be(true)
|
96
96
|
end
|
97
97
|
|
98
98
|
it "should test a method returns a value in a set of values" do
|
99
99
|
obj = subject.new { test_in :var, [0, 2, 4, 8] }
|
100
100
|
|
101
101
|
obj.var = 3
|
102
|
-
|
102
|
+
expect { obj.test! }.to raise_error(Script::TestFailed)
|
103
103
|
|
104
104
|
obj.var = 2
|
105
|
-
obj.test
|
105
|
+
expect(obj.test!).to be(true)
|
106
106
|
end
|
107
107
|
|
108
108
|
it "should test a method returns a value not in a set of values" do
|
109
109
|
obj = subject.new { test_not_in :var, [0, 2, 4, 8] }
|
110
110
|
|
111
111
|
obj.var = 2
|
112
|
-
|
112
|
+
expect { obj.test! }.to raise_error(Script::TestFailed)
|
113
113
|
|
114
114
|
obj.var = 3
|
115
|
-
obj.test
|
115
|
+
expect(obj.test!).to be(true)
|
116
116
|
end
|
117
117
|
end
|