connorshea / vscode-ruby-test-adapter

A Ruby test adapter extension for the VS Code Test Explorer
https://marketplace.visualstudio.com/items?itemName=connorshea.vscode-ruby-test-adapter
MIT License
85 stars 52 forks source link

Fix ActiveSupport#to_json error when test is not wrapped with a string-based describe/context block #13

Closed apolzon closed 5 years ago

apolzon commented 5 years ago

If you have a top-level test inside a test defined with describe Klass, the :close step will fail when ActiveSupport attempts to call to_json on a class object. The example group description args only goes up one level, so this error only happens when you have a test at the root of your top-level describe.

ie:

  describe Model do
    it "fails to marshal the description args"

    describe "with inner group" do
      it "passes"
    end
  end

For the first test, example.metadata[:example_group][:description_args] will be [Model(...active record description)], instead of a string representation.

This PR simply calls to_s on all example group description args to ensure we are not attempting to call to_json on a Ruby Class

connorshea commented 5 years ago

Thanks! Will review this later tonight.

connorshea commented 5 years ago

Looks good to me, thanks!