Skip to content

Instantly share code, notes, and snippets.

@manlycode
Created November 7, 2014 14:23
Show Gist options
  • Save manlycode/56622dcdf20abf92824b to your computer and use it in GitHub Desktop.
Save manlycode/56622dcdf20abf92824b to your computer and use it in GitHub Desktop.
require "rails_helper"
describe Filter do
let(:filter) { Filter.new(User) }
it "can be initialized" do
expect(filter).to be_a(Filter)
end
it "has no rows by default" do
expect(filter.rows).to be_empty
end
describe "#result" do
let(:results) { filter.results }
let!(:chris){ create(:user, first_name: "Chris") }
let!(:trish){ create(:user, first_name: "Trish") }
let!(:james){ create(:user, first_name: "James") }
context "given no rows" do
it "returns all results" do
expect(results.count).to eql(3)
expect(results).to include(chris, trish, james)
end
end
context "given a single row" do
context "and a single column" do
before do
filter.add_row({first_name: {eq: "Chris"}})
end
it "returns the result" do
expect(results).to eq([chris])
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment