Giter VIP home page Giter VIP logo

Comments (14)

ArturT avatar ArturT commented on May 25, 2024

@caspark What is your version of minitest gem?

from knapsack_pro-ruby.

caspark avatar caspark commented on May 25, 2024

Sorry, should've included that already. Here are all the minitest-related gems we're using:

guard-minitest-2.4.6
minispec-metadata-3.3.1
minitest-5.13.0
minitest-reporters-1.4.2
minitest-retry-0.1.9
minitest-spec-rails-5.4.0
minitest-stub_any_instance-1.0.1

from knapsack_pro-ruby.

ArturT avatar ArturT commented on May 25, 2024

Can you double-check you have RAILS_ENV=test set before running queue mode?

export RAILS_ENV=test

from knapsack_pro-ruby.

ArturT avatar ArturT commented on May 25, 2024

Here is how I run tests in queue mode for minitest

Maybe I should require 'minitest/spec' as well

but not sure if I should do it always even when someone is not using minitest/spec.

I'll try to play more with it tomorrow morning.

from knapsack_pro-ruby.

caspark avatar caspark commented on May 25, 2024

Yep, definitely setting RAILS_ENV - invocation is along the lines of env CI_NODE_TOTAL=2 CI_NODE_INDEX=0 RACK_ENV=test KNAPSACK_GENERATE_REPORT=true KNAPSACK_REPORT_PATH=$KNAPSACK_REPORT_PATH KNAPSACK_PRO_BRANCH=SIP-799-knapsack-pro-hacking-local KNAPSACK_PRO_COMMIT_HASH=$(git rev-parse HEAD) KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST=<replaced> bundle exec rake knapsack_pro:queue:minitest.

from knapsack_pro-ruby.

ArturT avatar ArturT commented on May 25, 2024

I managed to reproduce this bug on my local repo.

Can you update your test/test_helper.rb and add there

 # Allow context to be used like describe
  class << self
    alias :context :describe
  end

I found this tip https://stackoverflow.com/a/25811713/905697

This is from my test_helper.rb:

class ActiveSupport::TestCase
  # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
  fixtures :all

  # Add more helper methods to be used by all tests here...
  extend MiniTest::Spec::DSL

  # Allow context to be used like describe
  class << self
    alias :context :describe
  end

  register_spec_type(self) do |desc|
    desc < ActiveRecord::Base if desc.is_a?(Class)
  end
end

https://github.com/KnapsackPro/rails-app-with-knapsack_pro/blob/8f8d55a636f3b59d9558be8f0bc39e6bdb25c817/test/test_helper.rb#L30,L47

from knapsack_pro-ruby.

ArturT avatar ArturT commented on May 25, 2024

Also, I found out if you use RSpec and minitest at the same time then RSpec overrides some stuff and minitest test inside of describe blocks are not executed at all.

https://stackoverflow.com/questions/23683009/minitest-not-picking-up-describe-blocks

I had to disable loading RSpec when running minitest with ENV:
https://github.com/KnapsackPro/rails-app-with-knapsack_pro/blob/8f8d55a636f3b59d9558be8f0bc39e6bdb25c817/Gemfile#L65,L69

This is my example minitest test file with spec syntax describe/context
https://github.com/KnapsackPro/rails-app-with-knapsack_pro/blob/8f8d55a636f3b59d9558be8f0bc39e6bdb25c817/test/minitest/meme_spec_test.rb#L12,L17

from knapsack_pro-ruby.

ArturT avatar ArturT commented on May 25, 2024

@caspark Did my tips help?

from knapsack_pro-ruby.

ArturT avatar ArturT commented on May 25, 2024

@caspark Can you try the solution I posted? Thank you.

from knapsack_pro-ruby.

caspark avatar caspark commented on May 25, 2024

Sorry @ArturT , have been busy with other things. I suspect that aliasing context -> describe won't be sufficient (context being undefined happened for this test case, but something else was undefined for another test case), but haven't tried it yet. Unfortunately with some PTO coming up I likely won't have time to try it any time soon. You can close this issue in the meantime, and if this approach doesn't work then I'll comment again when I have time to investigate further.

from knapsack_pro-ruby.

ArturT avatar ArturT commented on May 25, 2024

@caspark I will keep this issue open. You can get back to it when you find some time.

Do you use another test runner like RSpec? I noticed that loading RSpec gem breaks minitest. See my previous tip.

from knapsack_pro-ruby.

shadre avatar shadre commented on May 25, 2024

@caspark have you had a chance to revisit this issue?

from knapsack_pro-ruby.

caspark avatar caspark commented on May 25, 2024

No, sorry, haven't looked at this since.

(Also, no, not using an alternative test runner like rspec at the moment.)

from knapsack_pro-ruby.

ArturT avatar ArturT commented on May 25, 2024

@caspark If there is anything we can help with, please let me know. If you would revisit this issue that would be helpful. Otherwise, we are going to close this issue.

from knapsack_pro-ruby.

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.