Skip to content

Commit 17ec470

Browse files
committed
test(integration): Load rspec config in integration tests
1 parent 4895792 commit 17ec470

File tree

5 files changed

+28
-20
lines changed

5 files changed

+28
-20
lines changed

Guardfile_integration

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Live-reload integration tests
44
guard :rspec, cmd: 'bundle exec rspec --color --format progress' do
55
watch(%r{^spec/integration/.+_spec\.rb$})
6+
watch('spec/integration/spec_helper.rb') { 'spec/integration' }
67
end
78

89
notification :off

spec/integration/main_spec.rb

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
# frozen_string_literal: true
22

3-
require 'algoliasearch'
4-
5-
SITE_PATH = File.expand_path('./spec/site/_site')
6-
RSpec::Matchers.define :have_file do |expected|
7-
match do
8-
File.exist?(File.join(SITE_PATH, expected))
9-
end
10-
end
3+
require_relative './spec_helper'
114

125
describe('pushed index') do
136
before(:all) do
14-
Algolia.init(
15-
application_id: ENV['ALGOLIA_APPLICATION_ID'],
16-
api_key: ENV['ALGOLIA_API_KEY']
17-
)
187
@index = Algolia::Index.new(ENV['ALGOLIA_INDEX_NAME'])
198
end
209

spec/integration/settings_spec.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
require 'algoliasearch'
5-
require 'awesome_print'
3+
require_relative './spec_helper'
64

75
# Note: Those tests will delete and recreate the index several times, deleting
86
# any records in it, in order to test the settings.
@@ -16,10 +14,6 @@
1614
let(:indexer) { Jekyll::Algolia::Indexer.init }
1715
before(:all) do
1816
# Requesting the index from outside of the Jekyll plugin
19-
Algolia.init(
20-
application_id: ENV['ALGOLIA_APPLICATION_ID'],
21-
api_key: ENV['ALGOLIA_API_KEY']
22-
)
2317
@index = Algolia::Index.new(ENV['ALGOLIA_INDEX_NAME'])
2418

2519
# We keep a reference to what default index settings look like so we can

spec/integration/spec_helper.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# frozen_string_literal: true
2+
3+
require 'algoliasearch'
4+
require 'awesome_print'
5+
require 'jekyll'
6+
require 'jekyll-algolia'
7+
8+
Algolia.init(
9+
application_id: ENV['ALGOLIA_APPLICATION_ID'],
10+
api_key: ENV['ALGOLIA_API_KEY']
11+
)
12+
13+
RSpec.configure do |config|
14+
config.filter_run(focus: true)
15+
config.fail_fast = true
16+
config.run_all_when_everything_filtered = true
17+
end
18+
19+
SITE_PATH = File.expand_path('./spec/site/_site')
20+
RSpec::Matchers.define :have_file do |expected|
21+
match do
22+
File.exist?(File.join(SITE_PATH, expected))
23+
end
24+
end

spec/jekyll/algolia/configurator_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@
188188
stub_const('ENV', 'ALGOLIA_INDEX_NAME' => env_value)
189189
end
190190

191-
describe 'should return nil if none configured' do
191+
describe 'should return the default value if none configured' do
192192
let(:env_value) { nil }
193193
let(:config) { { 'algolia' => { 'index_name' => nil } } }
194194
it { should eq nil }

0 commit comments

Comments
 (0)