Skip to content

Commit

Permalink
Add search spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
nybblr committed Jul 8, 2016
1 parent a5b5793 commit aac1b6a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec/models/search_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'rails_helper'

describe Search do
subject(:search) { Search.new(query) }

let(:alice) { User.create(name: 'Alice', location: 'Anchorage') }
let(:bob) { User.create(name: 'Bob', location: 'Boston') }
let(:charlie) { User.create(name: 'Charlie', location: 'Chicago') }
let(:users) { [alice, bob, charlie] }

# Force user creation
let!(:data) { users }

describe 'searching for users' do
subject(:results) { search.users }
context 'when searching by location' do
let(:query) { 'Chicago' }
it { is_expected.to match_array [charlie] }
end
end
end

0 comments on commit aac1b6a

Please sign in to comment.