Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ruby: Add support for running tests #12052

Merged
merged 2 commits into from
May 21, 2024

Conversation

vitallium
Copy link
Contributor

@vitallium vitallium commented May 20, 2024

Hello, this pull request adds two things related to each other. I hope it's fine to submit both in the same pull request but I am totally fine with submitting them in separate pull requests, just let me know. This is an initial version for both features. Thanks!

Symbols outline support for testing frameworks: minitest and RSPec

Symbols outline support in Minitest (the testing framework that comes with Ruby on Rails out of the box) and RSpec (another testing framework that is popular in Ruby and Ruby on Rails world). Here are some screenshots:

Minitest

Given this Ruby code:

require "test_helper"

class CategoryTest < ActiveSupport::TestCase
  context "validations" do
    subject { build(:category) }

    should validate_presence_of(:title)
    should validate_length_of(:title).is_at_most(255)
    should validate_uniqueness_of(:title)
  end
end

class TestNamesWithMiniTest < ActiveSupport::TestCase
  def test_foo_1; assert true; end
  def test_foo_2; assert true; end
  def test_bar_1; assert true; end
  def test_bar_2; assert true; end
end

We have this symbols outline:

CleanShot 2024-05-20 at 12 35 46@2x

RSpec

I used mastodon application for testing because it's written in Ruby. Given the following file https://github.com/mastodon/mastodon/blob/main/spec/models/account_spec.rb We have the following symbols outline:

CleanShot 2024-05-20 at 12 44 42@2x

Running Ruby tests

Minitest

Given the same file as above, we have the following workflow:

CleanShot.2024-05-20.at.13.01.54.mp4

RSpec

Given the following file https://github.com/mastodon/mastodon/blob/main/spec/models/account_spec.rb We have the following workflow:

CleanShot.2024-05-20.at.13.03.43.mp4

Release Notes:

  • N/A

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label May 20, 2024
@maxdeviant maxdeviant changed the title ruby: Add support for running tests to Ruby extension ruby: Add support for running tests May 20, 2024
Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

@SomeoneToIgnore SomeoneToIgnore self-assigned this May 21, 2024
@SomeoneToIgnore SomeoneToIgnore merged commit 99570f9 into zed-industries:main May 21, 2024
11 checks passed
@vitallium vitallium mentioned this pull request May 21, 2024
maxdeviant pushed a commit that referenced this pull request May 21, 2024
This PR bumps the Ruby extension to v0.0.4.
    
Changes:

- #11869
- #12012
- #12052
    
Release Notes:

- N/A
@MoskitoHero
Copy link

MoskitoHero commented May 23, 2024

Very nice, this feature is great, however, it does not seem to pick up my bundle context. Is there a way to tweak it?

Screenshot 2024-05-23 at 03 31 00

@joeldrapper
Copy link

@MoskitoHero I opened a new issue for this and problems with test detection here. #12579

@vitallium vitallium deleted the vs/ruby-test-run branch July 17, 2024 15:41
notpeter pushed a commit to zed-extensions/ruby that referenced this pull request Oct 11, 2024
Hello, this pull request adds two things related to each other. I hope
it's fine to submit both in the same pull request but I am totally fine
with submitting them in separate pull requests, just let me know. This
is an initial version for both features. Thanks!

## Symbols outline support for testing frameworks: minitest and RSPec

Symbols outline support in
[Minitest](https://github.com/minitest/minitest) (the testing framework
that comes with Ruby on Rails out of the box) and RSpec (another testing
framework that is popular in Ruby and Ruby on Rails world). Here are
some screenshots:

### Minitest

Given this Ruby code:

```ruby
require "test_helper"

class CategoryTest < ActiveSupport::TestCase
  context "validations" do
    subject { build(:category) }

    should validate_presence_of(:title)
    should validate_length_of(:title).is_at_most(255)
    should validate_uniqueness_of(:title)
  end
end

class TestNamesWithMiniTest < ActiveSupport::TestCase
  def test_foo_1; assert true; end
  def test_foo_2; assert true; end
  def test_bar_1; assert true; end
  def test_bar_2; assert true; end
end
```

We have this symbols outline:

![CleanShot 2024-05-20 at 12 35
46@2x](https://github.com/zed-industries/zed/assets/1894248/c63a61d8-38cc-4969-a49b-dd9ce6920a0e)

### RSpec

I used `mastodon` application for testing because it's written in Ruby.
Given the following file
https://github.com/mastodon/mastodon/blob/main/spec/models/account_spec.rb
We have the following symbols outline:

![CleanShot 2024-05-20 at 12 44
42@2x](https://github.com/zed-industries/zed/assets/1894248/a754cf4c-f9cc-43f3-b365-1ce0ff942941)



## Running Ruby tests

### Minitest

Given the same file as above, we have the following workflow:



https://github.com/zed-industries/zed/assets/1894248/dc335495-3460-4a6d-95c4-e4cbc87a1ea0



### RSpec

Given the following file
`https://github.com/mastodon/mastodon/blob/main/spec/models/account_spec.rb`
We have the following workflow:



https://github.com/zed-industries/zed/assets/1894248/a17067ea-73b6-4229-8f1b-1b88dde63401

<hr />

Release Notes: Added Ruby test runnables support
notpeter pushed a commit to zed-extensions/ruby that referenced this pull request Oct 11, 2024
This PR bumps the Ruby extension to v0.0.4.
    
Changes:

- zed-industries/zed#11869
- zed-industries/zed#12012
- zed-industries/zed#12052
    
Release Notes:

- N/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants