Giter Site home page Giter Site logo

Comments (5)

jagthedrummer avatar jagthedrummer commented on June 30, 2024

@newstler, wondering if you have any suggestions on how we can handle this better.

from bullet_train.

jagthedrummer avatar jagthedrummer commented on June 30, 2024

After poking around at this for a while I found that I could get the test to pass by updating test/factories/weidgets.rb.

It started like this:

FactoryBot.define do
  factory :widget do
    association :team
    name { "MyString" }
  end
end

And once I did this, the test started passing:

FactoryBot.define do
  factory :widget do
    association :team
    name { "MyString" }
    factory :widget_example do
      id { 42 }
      team { FactoryBot.example(:team) }
    end
  end
end

I think we either need to update the scaffolding process to automatically add the _example factory OR we need to figure out some other way to prevent scaffolding for instantly causing test failures that don't provide any useful info about what's wrong.

from bullet_train.

jagthedrummer avatar jagthedrummer commented on June 30, 2024

An example factory like this also works:

    factory :widget_example do
      id { 42 }
      team_id { 42 }
    end

(Hard coding a team_id instead of using FactoryBot.example to create an example team.

from bullet_train.

jagthedrummer avatar jagthedrummer commented on June 30, 2024

After looking at this some more I think maybe our test is just overly fragile. The "failures" are actually just letting you know about warnings issued by redocly. I'm not sure we should fail the tests just due to warnings.

These are the lines causing the problem:

failures = output.match(/You have (\d+) warnings/) || output.match("Failed to parse api definition")
puts output if failures
refute failures

I'm currently thinking that we shouldn't lump together warnings and failures from redocly and treat them all as failures. Instead I think that we should separate them and only treat redocly failures as failures. And then just output a message if there are warnings.

Maybe something like:

    failures = output.match("Failed to parse api definition")
    puts output if failures
    refute failures

    warnings = output.match(/You have (\d+) warnings/)
    if warnings
      puts "-----------------".yellow
      puts warnings.yellow
      puts "-----------------".yellow
    end

@newstler do you see any problems with doing something like this?

from bullet_train.

newstler avatar newstler commented on June 30, 2024

Hey, I’m sorry I haven’t seen that due to absence of notifications on GitHub some why.

You’re right saying that the solution would be to update the scaffolding process to automatically add the _example factory.

I wouldn't change the test itself though, as redocly's warnings are basically OpenAPI errors, meaning the documentation is noncompliant.

from bullet_train.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.