Skip to content

Commit

Permalink
Merge #342
Browse files Browse the repository at this point in the history
342: Split `spec/support/active_record_classes.rb` r=ellnix a=ellnix

A first step toward #332 


Co-authored-by: ellnix <103502144+ellnix@users.noreply.github.com>
  • Loading branch information
meili-bors[bot] and ellnix authored Feb 29, 2024
2 parents 69701cc + d00f686 commit 7459bde
Show file tree
Hide file tree
Showing 25 changed files with 570 additions and 527 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ Style/FrozenStringLiteralComment:
RSpec/MultipleExpectations:
Enabled: false

RSpec/DescribeClass:
Enabled: false

Metrics/BlockLength:
Enabled: true
Exclude:
Expand Down
21 changes: 21 additions & 0 deletions spec/integration/sequel/record_is_created_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'support/sequel_models/book'

describe 'When sequel record is created' do
before do
SequelBook.clear_index!(true)
end

it 'indexes the book' do
steve_jobs = SequelBook.create name: 'Steve Jobs', author: 'Walter Isaacson', premium: true, released: true
results = SequelBook.search('steve')

expect(results.size).to eq(1)
expect(results[0].id).to eq(steve_jobs.id)
end

it 'does not override after hooks' do
allow(SequelBook).to receive(:new).and_call_original
SequelBook.create name: 'Steve Jobs', author: 'Walter Isaacson', premium: true, released: true
expect(SequelBook).to have_received(:new).twice
end
end
20 changes: 0 additions & 20 deletions spec/integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
require 'spec_helper'

describe 'SequelBook' do
before do
SequelBook.clear_index!(true)
end

it 'indexes the book' do
steve_jobs = SequelBook.create name: 'Steve Jobs', author: 'Walter Isaacson', premium: true, released: true
results = SequelBook.search('steve')

expect(results.size).to eq(1)
expect(results[0].id).to eq(steve_jobs.id)
end

it 'does not override after hooks' do
expect(SequelBook).to receive(:new).twice.and_call_original
SequelBook.create name: 'Steve Jobs', author: 'Walter Isaacson', premium: true, released: true
end
end

if defined?(ActiveModel::Serializer)
describe 'SerializedDocument' do
before(:all) do
Expand All @@ -32,7 +13,6 @@
end
end
end

describe 'Encoding' do
before(:all) do
EncodedString.clear_index!(true)
Expand Down
2 changes: 1 addition & 1 deletion spec/multi_search_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe 'multi-search' do # rubocop:todo RSpec/DescribeClass
describe 'multi-search' do
def reset_indexes
[Book, Color, Product].each do |klass|
klass.delete_all
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@

# Required for running background jobs on demand (deterministically)
ActiveJob::Base.queue_adapter = :test
# Required for serializing objects in similar to production environments
# Required for serializing objects similar to production environments
GlobalID.app = 'meilisearch-test'

OLD_RAILS = Gem.loaded_specs['rails'].version < Gem::Version.new('4.0')
NEW_RAILS = Gem.loaded_specs['rails'].version >= Gem::Version.new('6.0')

Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |file| require file }
Dir["#{File.dirname(__FILE__)}/support/*.rb"].sort.each { |file| require file }

RSpec.configure do |c|
c.mock_with :rspec
Expand Down
Loading

0 comments on commit 7459bde

Please sign in to comment.