filter_factory 0.0.3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a20357253719ea11df36bea4aa7d70143b595c69
4
+ data.tar.gz: f9ba46a6e9d1e41e8690dde28861fa5ff00c5d78
5
+ SHA512:
6
+ metadata.gz: 053d07b99b084c136f9982e7b65f30fdb922759f6e669e1e0def7a31e45684e58961322cd160edce9bf08fbc87063ef940db8805cee1730a5f7a382b013644be
7
+ data.tar.gz: fc547558634b40fe8a0859d5ffb08d9948d3c04b238b36ad2e333f5c8dd61a2d14a45aaa2bf5b0f84d613b09f2f8ae7b747b67659a8a82474bc23d844790db82
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
- Gemfile.lock
7
6
  InstalledFiles
8
7
  _yardoc
9
8
  coverage
@@ -15,4 +14,5 @@ spec/reports
15
14
  test/tmp
16
15
  test/version_tmp
17
16
  tmp
18
- .idea
17
+ .idea
18
+ .gems
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - "2.3.0"
4
+ services:
5
+ - mongodb
6
+ - mysql
7
+ script: bundle exec rspec spec
data/Gemfile CHANGED
@@ -3,15 +3,14 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in filter_factory.gemspec
4
4
  gemspec
5
5
 
6
- gem 'rails', '>= 3.0'
6
+ gem 'rails', '>= 4.0'
7
7
 
8
8
  group :development do
9
- gem 'mongoid', '>= 3.0'
9
+ gem 'mongoid', '>= 5.0'
10
10
  gem 'mysql2'
11
11
  end
12
12
 
13
13
  group :test do
14
14
  gem 'rspec'
15
- gem 'database_cleaner'
16
15
  gem 'factory_girl'
17
- end
16
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,141 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ filter_factory (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actionmailer (4.2.6)
10
+ actionpack (= 4.2.6)
11
+ actionview (= 4.2.6)
12
+ activejob (= 4.2.6)
13
+ mail (~> 2.5, >= 2.5.4)
14
+ rails-dom-testing (~> 1.0, >= 1.0.5)
15
+ actionpack (4.2.6)
16
+ actionview (= 4.2.6)
17
+ activesupport (= 4.2.6)
18
+ rack (~> 1.6)
19
+ rack-test (~> 0.6.2)
20
+ rails-dom-testing (~> 1.0, >= 1.0.5)
21
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
22
+ actionview (4.2.6)
23
+ activesupport (= 4.2.6)
24
+ builder (~> 3.1)
25
+ erubis (~> 2.7.0)
26
+ rails-dom-testing (~> 1.0, >= 1.0.5)
27
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
+ activejob (4.2.6)
29
+ activesupport (= 4.2.6)
30
+ globalid (>= 0.3.0)
31
+ activemodel (4.2.6)
32
+ activesupport (= 4.2.6)
33
+ builder (~> 3.1)
34
+ activerecord (4.2.6)
35
+ activemodel (= 4.2.6)
36
+ activesupport (= 4.2.6)
37
+ arel (~> 6.0)
38
+ activesupport (4.2.6)
39
+ i18n (~> 0.7)
40
+ json (~> 1.7, >= 1.7.7)
41
+ minitest (~> 5.1)
42
+ thread_safe (~> 0.3, >= 0.3.4)
43
+ tzinfo (~> 1.1)
44
+ arel (6.0.3)
45
+ bson (4.0.4)
46
+ builder (3.2.2)
47
+ concurrent-ruby (1.0.1)
48
+ diff-lcs (1.2.5)
49
+ erubis (2.7.0)
50
+ factory_girl (4.7.0)
51
+ activesupport (>= 3.0.0)
52
+ globalid (0.3.6)
53
+ activesupport (>= 4.1.0)
54
+ i18n (0.7.0)
55
+ json (1.8.3)
56
+ loofah (2.0.3)
57
+ nokogiri (>= 1.5.9)
58
+ mail (2.6.4)
59
+ mime-types (>= 1.16, < 4)
60
+ mime-types (3.0)
61
+ mime-types-data (~> 3.2015)
62
+ mime-types-data (3.2016.0221)
63
+ mini_portile2 (2.0.0)
64
+ minitest (5.8.4)
65
+ mongo (2.2.4)
66
+ bson (~> 4.0)
67
+ mongoid (5.1.2)
68
+ activemodel (~> 4.0)
69
+ mongo (~> 2.1)
70
+ origin (~> 2.2)
71
+ tzinfo (>= 0.3.37)
72
+ mysql2 (0.4.3)
73
+ nokogiri (1.6.7.2)
74
+ mini_portile2 (~> 2.0.0.rc2)
75
+ origin (2.2.0)
76
+ rack (1.6.4)
77
+ rack-test (0.6.3)
78
+ rack (>= 1.0)
79
+ rails (4.2.6)
80
+ actionmailer (= 4.2.6)
81
+ actionpack (= 4.2.6)
82
+ actionview (= 4.2.6)
83
+ activejob (= 4.2.6)
84
+ activemodel (= 4.2.6)
85
+ activerecord (= 4.2.6)
86
+ activesupport (= 4.2.6)
87
+ bundler (>= 1.3.0, < 2.0)
88
+ railties (= 4.2.6)
89
+ sprockets-rails
90
+ rails-deprecated_sanitizer (1.0.3)
91
+ activesupport (>= 4.2.0.alpha)
92
+ rails-dom-testing (1.0.7)
93
+ activesupport (>= 4.2.0.beta, < 5.0)
94
+ nokogiri (~> 1.6.0)
95
+ rails-deprecated_sanitizer (>= 1.0.1)
96
+ rails-html-sanitizer (1.0.3)
97
+ loofah (~> 2.0)
98
+ railties (4.2.6)
99
+ actionpack (= 4.2.6)
100
+ activesupport (= 4.2.6)
101
+ rake (>= 0.8.7)
102
+ thor (>= 0.18.1, < 2.0)
103
+ rake (11.1.2)
104
+ rspec (3.4.0)
105
+ rspec-core (~> 3.4.0)
106
+ rspec-expectations (~> 3.4.0)
107
+ rspec-mocks (~> 3.4.0)
108
+ rspec-core (3.4.4)
109
+ rspec-support (~> 3.4.0)
110
+ rspec-expectations (3.4.0)
111
+ diff-lcs (>= 1.2.0, < 2.0)
112
+ rspec-support (~> 3.4.0)
113
+ rspec-mocks (3.4.1)
114
+ diff-lcs (>= 1.2.0, < 2.0)
115
+ rspec-support (~> 3.4.0)
116
+ rspec-support (3.4.1)
117
+ sprockets (3.6.0)
118
+ concurrent-ruby (~> 1.0)
119
+ rack (> 1, < 3)
120
+ sprockets-rails (3.0.4)
121
+ actionpack (>= 4.0)
122
+ activesupport (>= 4.0)
123
+ sprockets (>= 3.0.0)
124
+ thor (0.19.1)
125
+ thread_safe (0.3.5)
126
+ tzinfo (1.2.2)
127
+ thread_safe (~> 0.1)
128
+
129
+ PLATFORMS
130
+ ruby
131
+
132
+ DEPENDENCIES
133
+ factory_girl
134
+ filter_factory!
135
+ mongoid (>= 5.0)
136
+ mysql2
137
+ rails (>= 4.0)
138
+ rspec
139
+
140
+ BUNDLED WITH
141
+ 1.11.2
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # FilterFactory
2
2
 
3
+ [![Build Status](https://travis-ci.org/hck/filter_factory.png)](https://travis-ci.org/hck/filter_factory)
4
+
3
5
  FilterFactory allows you to easily fetch ActiveRecord/Mongoid models that match specified filters.
4
6
 
5
7
  ## Installation
@@ -7,7 +7,7 @@ module FilterFactory
7
7
  raise ArgumentError unless FilterFactory::Filter::CONDITIONS.include?(condition)
8
8
 
9
9
  valid_options = [:alias]
10
- @name, @condition, @options = name, condition, options.reject{|k,v| !valid_options.include?(k)}
10
+ @name, @condition, @options = name, condition, options.reject{|k,| !valid_options.include?(k)}
11
11
  @alias = @options[:alias] || @name
12
12
  end
13
13
 
@@ -7,14 +7,14 @@ module FilterFactory
7
7
 
8
8
  attr_reader :fields
9
9
 
10
- CONDITIONS = [:eq, :ne, :lt, :lte, :gt, :gte, :all, :in, :nin, :regex, :exists, :presents]
10
+ CONDITIONS = [:eq, :ne, :lt, :lte, :gt, :gte, :all, :in, :nin, :regex, :exists, :presents].freeze
11
11
 
12
12
  def initialize
13
13
  @fields = []
14
14
  end
15
15
 
16
16
  def attributes
17
- @fields.inject(HashWithIndifferentAccess.new) do |acc,field|
17
+ @fields.inject(HashWithIndifferentAccess.new) do |acc, field|
18
18
  acc[field.alias] = field.value
19
19
  acc
20
20
  end
@@ -28,11 +28,11 @@ module FilterFactory
28
28
  end
29
29
 
30
30
  def filled_fields
31
- fields.select{|f| !f.value.nil? && f.value != ''}
31
+ fields.select { |f| !f.value.nil? && f.value != '' }
32
32
  end
33
33
 
34
34
  def get_field(name)
35
- fields.find{|f| f.name == name}
35
+ fields.find { |f| f.name == name }
36
36
  end
37
37
 
38
38
  def persisted?
@@ -40,29 +40,31 @@ module FilterFactory
40
40
  end
41
41
 
42
42
  CONDITIONS.each do |condition|
43
- define_method condition do |name,options={}|
43
+ define_method condition do |name, options={}|
44
44
  field(name, condition, options)
45
45
  end
46
46
  end
47
47
 
48
+ class << self
49
+ def create(&block)
50
+ new.tap { |filter| filter.instance_eval &block }
51
+ end
52
+ end
53
+
54
+ class DuplicateFieldError < StandardError;
55
+ end
56
+
48
57
  private
58
+
49
59
  def field(name, condition, options={})
50
60
  Field.new(name, condition, options).tap do |field|
51
61
  raise DuplicateFieldError if fields.include?(field)
52
62
 
53
- define_singleton_method(field.alias){ field.value }
54
- define_singleton_method("#{field.alias}="){|val| field.value = val }
63
+ define_singleton_method(field.alias) { field.value }
64
+ define_singleton_method("#{field.alias}=") { |val| field.value = val }
55
65
 
56
66
  @fields << field
57
67
  end
58
68
  end
59
-
60
- class << self
61
- def create &block
62
- new.tap{|filter| filter.instance_eval &block}
63
- end
64
- end
65
-
66
- class DuplicateFieldError < StandardError; end
67
69
  end
68
- end
70
+ end
@@ -6,35 +6,35 @@ module FilterFactory
6
6
  end
7
7
 
8
8
  def ne(obj)
9
- obj.where(field_name => {'$ne' => value})
9
+ obj.where(field_name => { '$ne' => value })
10
10
  end
11
11
 
12
12
  def lt(obj)
13
- obj.where(field_name => {'$lt' => value})
13
+ obj.where(field_name => { '$lt' => value })
14
14
  end
15
15
 
16
16
  def lte(obj)
17
- obj.where(field_name => {'$lte' => value})
17
+ obj.where(field_name => { '$lte' => value })
18
18
  end
19
19
 
20
20
  def gt(obj)
21
- obj.where(field_name => {'$gt' => value})
21
+ obj.where(field_name => { '$gt' => value })
22
22
  end
23
23
 
24
24
  def gte(obj)
25
- obj.where(field_name => {'$gte' => value})
25
+ obj.where(field_name => { '$gte' => value })
26
26
  end
27
27
 
28
28
  def all(obj)
29
- obj.where(field_name => {'$all' => value})
29
+ obj.where(field_name => { '$all' => value })
30
30
  end
31
31
 
32
32
  def in(obj)
33
- obj.where(field_name => {'$in' => value})
33
+ obj.where(field_name => { '$in' => value })
34
34
  end
35
35
 
36
36
  def nin(obj)
37
- obj.where(field_name => {'$nin' => value})
37
+ obj.where(field_name => { '$nin' => value })
38
38
  end
39
39
 
40
40
  def regex(obj)
@@ -42,12 +42,18 @@ module FilterFactory
42
42
  end
43
43
 
44
44
  def exists(obj)
45
- obj.where(field_name => {'$exists' => value})
45
+ obj.where(field_name => { '$exists' => value })
46
46
  end
47
47
 
48
48
  def presents(obj)
49
- ['true', '1', 1].include?(value) ? obj.where(field_name => {'$nin' => [nil, '', []]}) : obj.where(field_name => {'$in' => [nil, '', []]})
49
+ query_opts = if ['true', '1', 1].include?(value)
50
+ { field_name => { '$nin' => [nil, '', []] } }
51
+ else
52
+ { field_name => { '$in' => [nil, '', []] } }
53
+ end
54
+
55
+ obj.where(query_opts)
50
56
  end
51
57
  end
52
58
  end
53
- end
59
+ end
@@ -6,8 +6,8 @@ module FilterFactory
6
6
  FilterFactory::Mongoid::Condition.new(field.name, field.value).method(field.condition)
7
7
  end
8
8
 
9
- conditions.inject(self) do |res,condition|
10
- res = res.instance_eval(&condition)
9
+ conditions.inject(self) do |res, condition|
10
+ res.instance_eval(&condition)
11
11
  end
12
12
  end
13
13
  end
@@ -20,4 +20,4 @@ if defined?(Mongoid::Document)
20
20
  base.extend FilterFactory::Mongoid::Filter
21
21
  end
22
22
  end
23
- end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module FilterFactory
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -1,17 +1,17 @@
1
- require "filter_factory/version"
1
+ require 'filter_factory/version'
2
2
 
3
- require "filter_factory/condition"
4
- require "filter_factory/field"
5
- require "filter_factory/filter"
3
+ require 'filter_factory/condition'
4
+ require 'filter_factory/field'
5
+ require 'filter_factory/filter'
6
6
 
7
- require "filter_factory/active_record/condition"
8
- require "filter_factory/active_record/filter"
7
+ require 'filter_factory/active_record/condition'
8
+ require 'filter_factory/active_record/filter'
9
9
 
10
- require "filter_factory/mongoid/condition"
11
- require "filter_factory/mongoid/filter"
10
+ require 'filter_factory/mongoid/condition'
11
+ require 'filter_factory/mongoid/filter'
12
12
 
13
13
  module FilterFactory
14
- def self.create &block
15
- FilterFactory::Filter.create &block
14
+ def self.create(&block)
15
+ FilterFactory::Filter.create(&block)
16
16
  end
17
- end
17
+ end
@@ -3,13 +3,11 @@ FactoryGirl.define do
3
3
  sequence(:title) {|n| "post_#{n}"}
4
4
  sequence(:author) {|n| "author_#{n}"}
5
5
  sequence(:views) {|n| n}
6
- #views {rand(0..1000)}
7
6
  end
8
7
 
9
8
  factory :active_record_post, class: ARPost do
10
9
  sequence(:title) {|n| "post_#{n}"}
11
10
  sequence(:author) {|n| "author_#{n}"}
12
11
  sequence(:views) {|n| n}
13
- #views {rand(0..1000)}
14
12
  end
15
- end
13
+ end
@@ -1,157 +1,143 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
- describe ARPost do
4
- before(:each) do
5
- @posts = FactoryGirl.create_list(:active_record_post, 10)
6
- end
3
+ RSpec.describe ARPost do
4
+ let!(:posts) { posts = FactoryGirl.create_list(:active_record_post, 5) }
7
5
 
8
- it "should respond to ::filter method" do
9
- described_class.should respond_to(:filter)
6
+ it 'responds to ::filter method' do
7
+ expect(described_class).to respond_to(:filter)
10
8
  end
11
9
 
12
- it "should execute filter methods chain" do
10
+ it 'executes filter methods chain' do
11
+ sample = posts.sample
12
+
13
13
  filter = FilterFactory.create do
14
- field :title, :eq
15
- field :author, :eq, alias: :user
16
- field :views, :gte
14
+ eq :title
15
+ eq :author, alias: :user
16
+ gte :views
17
17
  end
18
18
 
19
- sample = @posts.sample
20
-
21
19
  filter.title = sample.title
22
20
  filter.user = sample.author
23
21
 
24
- described_class.filter(filter).to_a.should == [sample]
22
+ expect(described_class.filter(filter).to_a).to eq([sample])
25
23
  end
26
24
 
27
- it "should return records with column' values equal to specified value" do
28
- sample = @posts.sample
25
+ it 'returns records with column values equal to specified value' do
26
+ sample = posts.sample
29
27
 
30
- filter = FilterFactory.create do
31
- field :id, :eq
32
- end
28
+ filter = FilterFactory.create { eq :id }
33
29
  filter.id = sample.id
34
30
 
35
- described_class.filter(filter).to_a.should == [sample]
31
+ expect(described_class.filter(filter).to_a).to eq([sample])
36
32
  end
37
33
 
38
- it "should return records with column' values not equal specified value" do
39
- sample = @posts.sample
34
+ it 'returns records with column values not equal specified value' do
35
+ sample = posts.sample
40
36
 
41
- filter = FilterFactory.create do
42
- field :id, :ne
43
- end
37
+ filter = FilterFactory.create { ne :id }
44
38
  filter.id = sample.id
45
39
 
46
- described_class.filter(filter).to_a.sort.should == @posts.reject{|p| p.id == sample.id}
40
+ expected_result = posts.reject { |p| p.id == sample.id }
41
+ expect(described_class.filter(filter).to_a.sort).to eq(expected_result)
47
42
  end
48
43
 
49
- it "should return records with column' values less than specified value" do
50
- sample = @posts.sample
44
+ it 'returns records with column values less than specified value' do
45
+ sample = posts.sample
51
46
 
52
- filter = FilterFactory.create do
53
- field :views, :lt
54
- end
47
+ filter = FilterFactory.create { lt :views }
55
48
  filter.views = sample.views
56
49
 
57
- described_class.filter(filter).map(&:id).sort.should == @posts.select{|p| p.views < sample.views}.map(&:id).sort
50
+ expected_result = posts.select { |p| p.views < sample.views }.map(&:id).sort
51
+ expect(described_class.filter(filter).map(&:id).sort).to eq(expected_result)
58
52
  end
59
53
 
60
- it "should return records with column' values less than or equal to specified value" do
61
- sample = @posts.sample
54
+ it 'returns records with column values less than or equal to specified value' do
55
+ sample = posts.sample
62
56
 
63
- filter = FilterFactory.create do
64
- field :views, :lte
65
- end
57
+ filter = FilterFactory.create { lte :views }
66
58
  filter.views = sample.views
67
59
 
68
- described_class.filter(filter).map(&:id).sort.should == @posts.select{|p| p.views <= sample.views}.map(&:id).sort
60
+ expected_result = posts.select { |p| p.views <= sample.views }.map(&:id).sort
61
+ expect(described_class.filter(filter).map(&:id).sort).to eq(expected_result)
69
62
  end
70
63
 
71
- it "should return records with column' values greater than specified value" do
72
- sample = @posts.sample
64
+ it 'returns records with column values greater than specified value' do
65
+ sample = posts.sample
73
66
 
74
- filter = FilterFactory.create do
75
- field :views, :gt
76
- end
67
+ filter = FilterFactory.create { gt :views }
77
68
  filter.views = sample.views
78
69
 
79
- described_class.filter(filter).map(&:id).sort.should == @posts.select{|p| p.views > sample.views}.map(&:id).sort
70
+ expected_result = posts.select { |p| p.views > sample.views }.map(&:id).sort
71
+ expect(described_class.filter(filter).map(&:id).sort).to eq(expected_result)
80
72
  end
81
73
 
82
- it "should return records with column' values greater than or equal to specified value" do
83
- sample = @posts.sample
74
+ it 'returns records with column values greater than or equal to specified value' do
75
+ sample = posts.sample
84
76
 
85
- filter = FilterFactory.create do
86
- field :views, :gte
87
- end
77
+ filter = FilterFactory.create { gte :views }
88
78
  filter.views = sample.views
89
79
 
90
- described_class.filter(filter).map(&:id).sort.should == @posts.select{|p| p.views >= sample.views}.map(&:id).sort
80
+ expected_result = posts.select { |p| p.views >= sample.views }.map(&:id).sort
81
+ expect(described_class.filter(filter).map(&:id).sort).to eq(expected_result)
91
82
  end
92
83
 
93
- it "should raise NotImplementedError if using 'all' condition" do
84
+ it 'raises NotImplementedError if using \'all\' condition' do
94
85
  filter = FilterFactory.create do
95
- field :opts, :all
86
+ field :opts, :all
96
87
  end
97
88
  filter.opts = [1, 2, 3, 4]
98
89
 
99
- expect {described_class.filter(filter)}.to raise_error(NotImplementedError)
90
+ expect { described_class.filter(filter) }.to raise_error(NotImplementedError)
100
91
  end
101
92
 
102
- it "should return records with column' values in specified values" do
103
- sample = @posts.sample(3)
93
+ it 'returns records with column values in specified values' do
94
+ sample = posts.sample(3)
104
95
 
105
96
  filter = FilterFactory.create do
106
- field :id, :in
97
+ field :id, :in
107
98
  end
108
99
  filter.id = sample.map(&:id)
109
100
 
110
- described_class.filter(filter).map(&:id).sort.should == sample.map(&:id).sort
101
+ expected_result = sample.map(&:id).sort
102
+ expect(described_class.filter(filter).map(&:id).sort).to eq(expected_result)
111
103
  end
112
104
 
113
- it "should return records with column' values not in specified values" do
114
- sample = @posts.sample(3)
105
+ it 'returns records with column values not in specified values' do
106
+ sample = posts.sample(3)
115
107
 
116
- filter = FilterFactory.create do
117
- field :id, :nin
118
- end
108
+ filter = FilterFactory.create { nin :id }
119
109
  filter.id = sample.map(&:id)
120
110
 
121
- described_class.filter(filter).map(&:id).sort.should == (@posts.map(&:id) - sample.map(&:id)).sort
111
+ expected_result = (posts.map(&:id) - sample.map(&:id)).sort
112
+ expect(described_class.filter(filter).map(&:id).sort).to eq(expected_result)
122
113
  end
123
114
 
124
- it "should return records with column' values which match the specified regexp" do
125
- sample = @posts.sample(3)
126
- sample.each_with_index{|r,i| r.update_attribute(:title, "my_title_#{i}")}
127
-
128
- filter = FilterFactory.create do
129
- field :title, :regex
130
- end
115
+ it 'returns records with column values which match the specified regexp' do
116
+ sample = posts.sample(3)
117
+ sample.each_with_index { |r, i| r.update_attribute(:title, "my_title_#{i}") }
131
118
 
119
+ filter = FilterFactory.create { regex :title }
132
120
  filter.title = '_title_'
133
121
 
134
- described_class.filter(filter).map(&:id).sort.should == sample.map(&:id).sort
122
+ expected_result = sample.map(&:id).sort
123
+ expect(described_class.filter(filter).map(&:id).sort).to eq(expected_result)
135
124
  end
136
125
 
137
- it "should raise NotImplementedError if using 'exists' condition" do
138
- filter = FilterFactory.create do
139
- field :not_exists, :exists
140
- end
126
+ it 'raises NotImplementedError if using \'exists\' condition' do
127
+ filter = FilterFactory.create { exists :not_exists }
141
128
  filter.not_exists = true
142
129
 
143
- expect {described_class.filter(filter)}.to raise_error(NotImplementedError)
130
+ expect { described_class.filter(filter) }.to raise_error(NotImplementedError)
144
131
  end
145
132
 
146
- it "should return records with column' values not nil equal to specified value" do
147
- sample = @posts.sample(3)
148
- sample.each{|r| r.update_attribute(:title, nil)}
133
+ it 'returns records with column values not nil equal to specified value' do
134
+ sample = posts.sample(3)
135
+ sample.each { |r| r.update_attribute(:title, nil) }
149
136
 
150
- filter = FilterFactory.create do
151
- field :title, :presents
152
- end
137
+ filter = FilterFactory.create { presents :title }
153
138
  filter.title = false
154
139
 
155
- described_class.filter(filter).map(&:id).sort.should == sample.map(&:id).sort
140
+ expected_result = sample.map(&:id).sort
141
+ expect(described_class.filter(filter).map(&:id).sort).to eq(expected_result)
156
142
  end
157
- end
143
+ end