Skip to content

Commit

Permalink
Tests: Don't hardcode host name
Browse files Browse the repository at this point in the history
  • Loading branch information
ledermann committed Feb 29, 2024
1 parent d0edf00 commit ac9cef5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions spec/lib/senec/local/state_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
RSpec.describe Senec::Local::State do
subject(:state) { described_class.new(connection:) }

let(:senec_host) { ENV.fetch('SENEC_HOST', nil) }

let(:connection) do
Senec::Local::Connection.new(host: ENV.fetch('SENEC_HOST', nil), schema: ENV.fetch('SENEC_SCHEMA'))
Senec::Local::Connection.new(host: senec_host, schema: ENV.fetch('SENEC_SCHEMA'))
end

# Dummy response from the SENEC web interface JavaScript file
Expand Down Expand Up @@ -41,7 +43,7 @@ def mock_response
let(:language) { :en }

before do
stub_request(:any, 'https://senec/js/EN-en.js').to_return(body: mock_response)
stub_request(:any, "https://#{senec_host}/js/EN-en.js").to_return(body: mock_response)
end

it { is_expected.to eq(expected_hash) }
Expand All @@ -51,7 +53,7 @@ def mock_response
let(:language) { :de }

before do
stub_request(:any, 'https://senec/js/DE-de.js').to_return(body: mock_response)
stub_request(:any, "https://#{senec_host}/js/DE-de.js").to_return(body: mock_response)
end

it { is_expected.to eq(expected_hash) }
Expand All @@ -61,7 +63,7 @@ def mock_response
let(:language) { :it }

before do
stub_request(:any, 'https://senec/js/IT-it.js').to_return(body: mock_response)
stub_request(:any, "https://#{senec_host}/js/IT-it.js").to_return(body: mock_response)
end

it { is_expected.to eq(expected_hash) }
Expand Down

0 comments on commit ac9cef5

Please sign in to comment.