Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to test organizers #161

Closed
denvaar opened this issue Jan 9, 2019 · 1 comment
Closed

How to test organizers #161

denvaar opened this issue Jan 9, 2019 · 1 comment

Comments

@denvaar
Copy link

denvaar commented Jan 9, 2019

This is probably my favorite gem - thank you!

Not an issue, but a question. I am debating whether or not to have a spec for my organizers. This spec works to enforce that the order of the interactors in my organizer doesn't change, but I think it might not be a good idea to include organizer.organized in my own project specs because it's not really part of the public API. Any thoughts on this?

describe Dibs::SetupWizard::SetupUserAccount do
  subject(:organizer) { described_class }

  it "organizes flow of interactors to setup a user account" do
    expect(organizer.organized).to eq(
      [
        Dibs::SetupWizard::BuildEmployee,
        Dibs::SetupWizard::SaveEmployee,
        Dibs::SetupWizard::CreateUserPassword
      ]
    )
  end
end
@cannikin
Copy link

cannikin commented Mar 11, 2019

I've got an ActiveSupport::TestCase version of this:

def assert_organizes(organizer, interactors)
  assert_equal interactors, organizer.organized, "Expected #{organizer} to organize #{interactors.to_sentence} but didn't"
end

And used like so:

require 'test_helper'

class SubscriptionChangeTest < ActiveSupport::TestCase
  test "is an organizer" do
    assert_organizes SubscriptionChange, [HiringRoleManager, NewHirerTasks, FeatureDowngrade]
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants