fitting icon indicating copy to clipboard operation
fitting copied to clipboard

unable to log tests when we use rspec_api_documentation

Open zsan opened this issue 10 months ago • 3 comments

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.

zsan avatar Apr 09 '24 02:04 zsan

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

tuwilof avatar Apr 09 '24 20:04 tuwilof

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.

zsan avatar Apr 10 '24 01:04 zsan

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

tuwilof avatar Apr 10 '24 20:04 tuwilof