Created
March 28, 2019 09:57
-
-
Save MaryKuz/b9802f374d8daf82a1a7a7f073192a49 to your computer and use it in GitHub Desktop.
Write tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
RSpec.describe Product, type: :model do | |
describe '.search_by' do | |
let(:relation) { double } | |
before { expect(Product).to receive(:all).and_return(relation) } | |
context do | |
it { expect { Product.search_by }.to_not raise_error } | |
end | |
context do | |
before { expect(relation).to receive(:where).with('name ILIKE ?', 'abc%') } | |
it { expect { Product.search_by 'term' => 'abc' }.to_not raise_error } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment