tuwilof / fitting

Library add improve test log for RSpec and WebMock, validate its according to API Blueprint and Open API, show the documentation coverage with log.
MIT License
54 stars 9 forks source link

unable to log tests when we use rspec_api_documentation #161

Open zsan opened 5 months ago

zsan commented 5 months ago

Hello,

Its more to question rather than an issue.

Is there any way for this gem to integrate with the rspec_api_documentation gem? I believe that in its current state, this gem may not be able to log tests written in the rspec_api_documentation style.

tuwilof commented 5 months ago

Hello, fitting need Open API or API Bluerprint documentations to work

Your case will be solved if you can get this documentation from rspec_api_documentation

zsan commented 5 months ago

Hello, fitting need Open API or API Bluerprint documentations to work

Your case will be solved if you can get this documentation from rspec_api_documentation

I ran rake doc:generate to perform tests and generate documentation (including open API JSON) with rspec_api_documentation.

There should have been a log in fitting.log when I did the above, and then I could rake fitting:validate. However, in reality, there is no log in fitting.log, which is why when I execute fitting:validate, I get this:

examples, 0 failure, 0 pending
Coverage: 0.0%

This might have happened because rspec_api_documentation does not expose the response object to the public (https://github.com/zipmark/rspec_api_documentation/issues/289).

By the way, actually, I might not need fitting:validate if I'm using rspec_api_documentation.

tuwilof commented 5 months ago

You're right. Currently, only two types are used: request and controller. For your case, you also need to allow the rspec_api_documentation type.

https://github.com/tuwilof/fitting/blob/master/lib/fitting.rb#L31

        config.after(:each, type: :request) do |example|
          begin
            request = Fitting::Records::Tested::Request.new(response, example)
            responses += "FITTING incoming request #{request.to_spherical.to_json}\n"
          rescue NoMethodError
          end
        end

        config.after(:each, type: :controller) do |example|
          begin
            request = Fitting::Records::Tested::Request.new(response, example)
            responses += "FITTING incoming request #{request.to_spherical.to_json}\n"
          rescue NoMethodError
          end
        end