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

Make Provider Catalog Types Pluggable #389

Merged
merged 1 commit into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/models/manageiq/providers/azure/cloud_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ def description
ManageIQ::Providers::Azure::Regions.find_by_name(provider_region)[:description]
end

def supported_catalog_types
%w(azure)
def self.catalog_types
{"azure" => N_("Azure")}
end

def allow_targeted_refresh?
Expand Down
6 changes: 3 additions & 3 deletions spec/models/manageiq/providers/azure/cloud_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,11 @@ def create_factory_ems(name, region)
end
end

context 'catalog types' do
describe "#catalog types" do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm totally nitpicking, and I realize that they're synonyms, but I generally use context for inner blocks, and describe for the outer block only.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's funny because in ManageIQ/manageiq#20039 (comment) I got the opposite advice :)

I tend to use describe as the top level for a method, and context if I'm testing different...well...contexts within that method

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@djberg96 I don't do describe vs context based on location (inner vs outer). I tend to recommend more like what @agrare said:

  • Use describe to describe the method under test, trying to use the actual method name if possible (e.g. ".the_method" for class methods, "#the_method" for instance methods and appending " (private)" if the method under test is private).

  • Use context to describe a particular environment in which the tests runs. (e.g. "when there are credentials defined"), and then having a before that sets up specific credentials

  • I tend to avoid creating extraneous describes and contexts unless I have more than one test. That is, if a single it is good enough, I just do that...

    # I don't really like:
    describe ".the_method" do
      it "works" do
        described_class.the_method
      end
    end
    
    # I prefer:
    it ".the_method" do
      described_class.the_method
    end

let(:ems) { FactoryBot.create(:ems_azure) }

it "#supported_catalog_types" do
expect(ems.supported_catalog_types).to eq(%w(azure))
it "#catalog_types" do
expect(ems.catalog_types).to include("azure")
end
end
end