jantman / serverspec-extended-types

A set of extended types for ServerSpec 2.x
MIT License
28 stars 8 forks source link

http_get: failure to connect to the server halts the whole suite #6

Closed thbar closed 2 years ago

thbar commented 5 years ago

While provisioning a new machine, I have noticed that I use http_get and the server is not yet available (e.g. nginx not installed), instead of just failing this group of test, it will cause the whole ServerSpec suite to crash.

I presume this is because some connection occurs at initialize time.

Not a huge problem but I thought I'd report it, still!

jantman commented 5 years ago

Interesting. I don't remember seeing that in the past, but unfortunately I haven't really used this project in a few years and I'd consider it unsupported at this point.

I'll leave this issue open though, and would gladly accept and merge a pull request to fix this.

Thanks for taking the time to make me (and other users) aware!

thbar commented 2 years ago

One fix that appears to be working is this one: use subject to delay the evaluation.

Before

  describe http_get(80, target_host, '/', 10, 'http', false) do
    it { should be_redirected_to "https://#{target_host}/" }
    its(:status) { should eq 301 }
  end

After

  describe "http access" do
    subject { http_get(80, target_host, '/', 10, 'http', false) }
    it { should be_redirected_to "https://#{target_host}/" }
    its(:status) { should eq 301 }
  end

I'll go ahead and close the issue!