Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mimoco

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mimoco

  • 1.0.3
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

MiMoCo

Gem Version GEM Downloads rake Ruby Style Guide MIT License

Mimoco (MInitest MOdels COntrollers) DRY your tests by specifying some (trivial) of them via a table.

Mimoco doesn't replace the "assert"s of MiniTest. It is more a kind of a quick and dirty check. Still, it has demonstrated to be useful, in particular, to detect code changes which often went unseen.

Installation

As usual:

# Gemfile
gem "mimoco"

and run "bundle install".

Usage for Models

require "test_helper"
require "mimoco"

class ModelsTest < Minitest::Test
  def test_some
    models = {
      Order => {
        valid: {name: "Name", qty: 123},
        invalid: {qty: :abc},
        class_methods: %i[class_method],
        call_class_methods: %i[class_method],
        public_methods: %i[public_method],
        call_public_methods: %i[public_method]
      },
      Article => ...
    }

    check_models models
  end
end

Furthermore, "valids" and "invalids" accepts an array of hashes to create models to be checked.

"call_public_methods" requires a "valid" item to instantiated a model used to applicate the methods.

Usage for Controllers

require "test_helper"
require "mimoco"

class ControllersTest < ActionDispatch::IntegrationTest
  def test_some
    controllers = {
      OrdersController => {
        respond_to: %i[create destroy edit index new show update],
        class_methods: %i[class_method],
        call_class_methods: %i[class_method],
        public_methods: %i[create destroy edit index new show update]
      }
      ArticlesController => ...
    }

    check_controllers controllers
  end
end

Parameter

Rails magic adds a few additional methods to a model or a controller (e.g. #column_headers).

MiMoCo ignores them, but future versions of Rails may add more. They can be ignored by:

check_models models, ignore_methods: magic_method
...
check_controllers controllers, ignore_methods: %i[magic2 magic3]

Miscellaneous

Copyright (c) 2022-2024 Dittmar Krall (www.matiq.com), released under the MIT license.

FAQs

Package last updated on 11 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc