Skip to content

Commit

Permalink
Add tests for ActiveRecord::Base::where method
Browse files Browse the repository at this point in the history
  • Loading branch information
YOSHIDA Hiroki committed Jul 16, 2014
1 parent 5ddce84 commit d1475bf
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion spec/models/product_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,19 @@
before { FactoryGirl.create(:product, title: 'foobar') }
subject { described_class.utusemi(:sample) }

it '::where by alias column' do
it '::where by alias column in Hash and String' do
expect(subject.where(name: 'foobar').count).to eq(1)
end

it '::where by alias column in Hash and Array' do
FactoryGirl.create(:product, title: 'hoge')
expect(subject.where(name: %w(foobar hoge)).count).to eq(2)
end

it '::where by alias column in String' do
expect(subject.where('name LIKE ?', 'foo%').count).to eq(1)
end

it '::order by alias column' do
expect { subject.order(:name) }.not_to raise_error
end
Expand Down

0 comments on commit d1475bf

Please sign in to comment.