feat: unit tests

main
James Spencer 2023-09-30 16:03:36 +01:00
parent b4682969e9
commit 45811d4bf4
Signed by: james
SSH Key Fingerprint: SHA256:7tOVvkg3eVqn4GbEInHoSkEG96Cvqgvwx+VHUD9begc
3 changed files with 25 additions and 4 deletions

View File

@ -2,7 +2,8 @@
A super simple Ruby starter project. A super simple Ruby starter project.
Rubocop and Solargraph are included for linting and code completion, respectively and are configured to be used with [Zed](https://zed.dev/). Rubocop and Solargraph are included for linting and code completion,
respectively and are configured to be used with [Zed](https://zed.dev/).
## Prerequisites ## Prerequisites
@ -20,7 +21,9 @@ Rubocop and Solargraph are included for linting and code completion, respectivel
Zed is a rough-around-the-edges editor in Beta. It's not very configurable yet, Zed is a rough-around-the-edges editor in Beta. It's not very configurable yet,
so we're locked into using Solargraph as our language server. Solargraph is so we're locked into using Solargraph as our language server. Solargraph is
only officially compatible with [Rubocop](https://rubocop.org/) _(ACAB)_ for linting, but we use our ruleset of choice, [StandardRB] by configuring it in `.rubocop.yml`. only officially compatible with [Rubocop](https://rubocop.org/) _(ACAB)_ for
linting, but we use our ruleset of choice, StandardRB by configuring it in
`.rubocop.yml`.
For now, make sure that StandardRB is installed globally, as Zed can't yet reach For now, make sure that StandardRB is installed globally, as Zed can't yet reach
into your local Gem's, as far as we are aware. into your local Gem's, as far as we are aware.
@ -45,4 +48,9 @@ inline diagnostics and formatting on save you must add the following to your Zed
## Documentation ## Documentation
If you'd like to generate some user-friendly documentation, you can run If you'd like to generate some user-friendly documentation, you can run
`rake` on the command line to generate some HTML docs in the `rdoc` directory, made up of your comments and some metadata from your code. `rake rdoc` on the command line to generate some HTML docs in the `rdoc` directory, made up of your comments and some metadata from your code.
## Testing
An example unit test is included in `test/example_test.rb`. You can run the
tests with `rake test`.

View File

@ -1,5 +1,5 @@
require "rdoc/task" require "rdoc/task"
task default: [:rdoc] require 'rake/testtask'
Rake::RDocTask.new do |rdoc| Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = "rdoc" rdoc.rdoc_dir = "rdoc"
@ -7,3 +7,9 @@ Rake::RDocTask.new do |rdoc|
rdoc.options << "--line-numbers" << "--inline-source" rdoc.options << "--line-numbers" << "--inline-source"
rdoc.rdoc_files.include("**/*.rb") rdoc.rdoc_files.include("**/*.rb")
end end
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['tests/test*.rb']
t.verbose = true
end

7
tests/test_example.rb Normal file
View File

@ -0,0 +1,7 @@
require "test/unit"
class TestExample < Test::Unit::TestCase
def test_example
assert_equal(4, 2 + 2)
end
end