diff options
Diffstat (limited to 'spec/support/shared_examples/querying_shared_examples.rb')
-rw-r--r-- | spec/support/shared_examples/querying_shared_examples.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/support/shared_examples/querying_shared_examples.rb b/spec/support/shared_examples/querying_shared_examples.rb new file mode 100644 index 00000000000..1f554ddb441 --- /dev/null +++ b/spec/support/shared_examples/querying_shared_examples.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +def update_column_regex(column) + /UPDATE.+SET.+#{column}[^=*]=.+FROM.*/m +end + +RSpec.shared_examples 'update on column' do |column| + it "#{column} column updated" do + qr = ActiveRecord::QueryRecorder.new do + subject + end + expect(qr.log).to include a_string_matching update_column_regex(column) + end +end + +RSpec.shared_examples 'no update on column' do |column| + it "#{column} column is not updated" do + qr = ActiveRecord::QueryRecorder.new do + subject + end + expect(qr.log).not_to include a_string_matching update_column_regex(column) + end +end |