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

[WIP] Use common context for setting up local miq server #19507

Closed
wants to merge 1 commit into from

Conversation

kbrock
Copy link
Member

@kbrock kbrock commented Nov 13, 2019

No description provided.

@kbrock
Copy link
Member Author

kbrock commented Nov 14, 2019

rebasing hoping to clear up the sporadic errors

@kbrock kbrock force-pushed the common_context branch 3 times, most recently from 21d400a to fb5b050 Compare November 14, 2019 20:29
@miq-bot
Copy link
Member

miq-bot commented Nov 14, 2019

Checked commit kbrock@9ed0a4e with ruby 2.5.5, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
18 files checked, 0 offenses detected
Everything looks fine. 🏆

Copy link
Member

@NickLaMuro NickLaMuro left a comment

Choose a reason for hiding this comment

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

Just some suggestions. I think it works just fine as is, so I am nit-picking here.

before do
MiqRegion.seed

@zone = EvmSpecHelper.local_miq_server.zone
Copy link
Member

Choose a reason for hiding this comment

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

Can we possibly use rspec constructs for this?

RSpec.shared_context 'with local server', :with_local_miq_server do
  let(:local_miq_server) { EvmSpecHelper.local_miq_server }
  let(:zone)             { local_miq_server }

  before do
    MiqRegion.seed
    zone
  end
end

I just see that you are changing zone to @zone in some places, and this would be an option for avoiding that.

Copy link
Member Author

Choose a reason for hiding this comment

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

2 places ignore the zone
8 places use zone
10 places use @zone (which I don't like)
others use both miq_server and zone but I didn't convert because this code only did @zone. (but those support the let() syntax)

Is the idea to avoid assigning the @zone? Or assign it and slowly go away from it? Not sure how the variable syntax would help us here

    before do	
      _, _, @zone = EvmSpecHelper.create_guid_miq_server_zone	
    end

@@ -0,0 +1,7 @@
RSpec.shared_context 'with local server', :with_local_miq_server do
Copy link
Member

Choose a reason for hiding this comment

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

Minor: But could we possibly add some documentation around this?

I know it seems stupid, but it relates to my other comment about using instances variables. Say someone "did" want to use a @zone variable, and you went along with the changes I suggested. To make modifications to the context, you can do a:

include_context :with_local_miq_server do |var_1, var_2|
  # ...
end

(pretty sure... I forget the DSL for it...)

Then you can even pass variables in at runtime as part of the block, allowing this to be somewhat configurable. But without making that obvious in the docs, it might not be apparent to those who are less familiar with the whole feature set of rspec.

Copy link
Member

Choose a reason for hiding this comment

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

Also: Does this make sense to live in EvmSpecHelper? Just would make it easier to find the code that this context eventually calls, and there is no reason it has to live in support/contexts/ as far as rspec is concerned.

That said, if you disagree, I would argue maybe calling this spec/support/context/with_local_miq_server.rb instead, but that is my two cents.

@kbrock kbrock changed the title Use common context for setting up local miq server [WIP] Use common context for setting up local miq server Nov 15, 2019
@kbrock kbrock added the wip label Nov 15, 2019
@kbrock
Copy link
Member Author

kbrock commented Nov 20, 2019

re-evaluating this change.

Does seem it would be better to pull out an miq_server and not introduce @zone

@kbrock kbrock closed this Nov 20, 2019
@kbrock kbrock deleted the common_context branch November 20, 2019 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants