microscope 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42926873b4c35009b176d9ee2bf2928bddf7ef35
4
- data.tar.gz: d3b1659915412d6429b51565a5665e52f7b8eed3
3
+ metadata.gz: 4d0dca4213a2ae5d3f283756406aed55a4d28e55
4
+ data.tar.gz: 10c15290f3784a35e3273954fa5451cf91dd5ea5
5
5
  SHA512:
6
- metadata.gz: 729e7481c9b34ec14105f8a1128a8ab925fb677e6388940ba43c9ba264f76d289b20404e7ec332a894a8dcb0bfab1d6c8fa394441e4b24072ee9bd20ba45ce9d
7
- data.tar.gz: 20203298794289b9ccc8abd500bd8f719d5b60448c288c4572571238ff29611d6fb1302099dce1cd8340a0718c60233fc574d47e18916b0aca9afde3b4e2776c
6
+ metadata.gz: f567999f9639db99ed40340ce3f46260e81733f7fcdf753a09f8d133e7c8cd25dcee76c1be31c7ecf29d40a3e40e414c695f78dcaeb8121eb7564e92e140edd5
7
+ data.tar.gz: f4f8caa7fd050625cdaf7b1505808fa045c3df34e79017083a488829ecee460c44ef18c319f56b42f2268067db199fc630ef47cac9b72876487a3bc7149384e3
@@ -5,6 +5,7 @@ module Microscope
5
5
  model.class_eval <<-RUBY, __FILE__, __LINE__ + 1
6
6
  scope "#{@field_name}", lambda { where("#{@field_name}" => true) }
7
7
  scope "not_#{@field_name}", lambda { where("#{@field_name}" => false) }
8
+ scope "un#{@field_name}", lambda { not_#{@field_name} }
8
9
  RUBY
9
10
  end
10
11
  end
@@ -48,6 +48,7 @@ module Microscope
48
48
  <<-RUBY
49
49
  scope "#{cropped_field}", lambda { where('#{quoted_field} IS NOT NULL AND #{quoted_field} <= ?', #{@now}) }
50
50
  scope "not_#{cropped_field}", lambda { where('#{quoted_field} IS NULL OR #{quoted_field} > ?', #{@now}) }
51
+ scope "un#{cropped_field}", lambda { not_#{cropped_field} }
51
52
  RUBY
52
53
  end
53
54
  end
@@ -1,3 +1,3 @@
1
1
  module Microscope
2
- VERSION = '0.5.7'
2
+ VERSION = '0.5.8'
3
3
  end
@@ -20,55 +20,55 @@ describe Microscope::InstanceMethod::DateInstanceMethod do
20
20
 
21
21
  describe '#started?' do
22
22
  context 'with positive result' do
23
- subject { Event.create(started_on: 2.months.ago) }
24
- it { should be_started }
25
- it { should_not be_not_started }
23
+ let(:event) { Event.create(started_on: 2.months.ago) }
24
+ it { expect(event).to be_started }
25
+ it { expect(event).to_not be_not_started }
26
26
  end
27
27
 
28
28
  context 'with negative result' do
29
- subject { Event.create(started_on: 1.month.from_now) }
30
- it { should_not be_started }
31
- it { should be_not_started }
29
+ let(:event) { Event.create(started_on: 1.month.from_now) }
30
+ it { expect(event).to_not be_started }
31
+ it { expect(event).to be_not_started }
32
32
  end
33
33
  end
34
34
 
35
35
  describe '#started=' do
36
- before { subject.started = value }
36
+ before { event.started = value }
37
37
 
38
38
  context 'with blank argument' do
39
- subject { Event.create(started_on: 2.months.ago) }
39
+ let(:event) { Event.create(started_on: 2.months.ago) }
40
40
  let(:value) { '0' }
41
41
 
42
- it { should_not be_started }
42
+ it { expect(event).to_not be_started }
43
43
  end
44
44
 
45
45
  context 'with present argument' do
46
- subject { Event.create }
46
+ let(:event) { Event.create }
47
47
  let(:value) { '1' }
48
48
 
49
- it { should be_started }
49
+ it { expect(event).to be_started }
50
50
  end
51
51
 
52
52
  context 'with present argument, twice' do
53
- subject { Event.create(started_on: time) }
53
+ let(:event) { Event.create(started_on: time) }
54
54
  let(:time) { 2.months.ago }
55
55
  let(:value) { '1' }
56
56
 
57
- it { expect(subject.started_on.day).to eql time.day }
58
- it { expect(subject.started_on.month).to eql time.month }
59
- it { expect(subject.started_on.year).to eql time.year }
57
+ it { expect(event.started_on.day).to eql time.day }
58
+ it { expect(event.started_on.month).to eql time.month }
59
+ it { expect(event.started_on.year).to eql time.year }
60
60
  end
61
61
  end
62
62
 
63
63
  describe '#not_started?' do
64
64
  context 'with negative result' do
65
- subject { Event.create(started_on: 2.months.ago) }
66
- it { should_not be_not_started }
65
+ let(:event) { Event.create(started_on: 2.months.ago) }
66
+ it { expect(event).to_not be_not_started }
67
67
  end
68
68
 
69
69
  context 'with positive result' do
70
- subject { Event.create(started_on: 1.month.from_now) }
71
- it { should be_not_started }
70
+ let(:event) { Event.create(started_on: 1.month.from_now) }
71
+ it { expect(event).to be_not_started }
72
72
  end
73
73
  end
74
74
 
@@ -13,51 +13,51 @@ describe Microscope::InstanceMethod::DatetimeInstanceMethod do
13
13
 
14
14
  describe '#started?' do
15
15
  context 'with positive result' do
16
- subject { Event.create(started_at: 2.months.ago) }
17
- it { should be_started }
16
+ let(:event) { Event.create(started_at: 2.months.ago) }
17
+ it { expect(event).to be_started }
18
18
  end
19
19
 
20
20
  context 'with negative result' do
21
- subject { Event.create(started_at: 1.month.from_now) }
22
- it { should_not be_started }
21
+ let(:event) { Event.create(started_at: 1.month.from_now) }
22
+ it { expect(event).to_not be_started }
23
23
  end
24
24
  end
25
25
 
26
26
  describe '#started=' do
27
- before { subject.started = value }
27
+ before { event.started = value }
28
28
 
29
29
  context 'with blank argument' do
30
- subject { Event.create(started_at: 2.months.ago) }
30
+ let(:event) { Event.create(started_at: 2.months.ago) }
31
31
  let(:value) { '0' }
32
32
 
33
- it { should_not be_started }
33
+ it { expect(event).to_not be_started }
34
34
  end
35
35
 
36
36
  context 'with present argument' do
37
- subject { Event.create }
37
+ let(:event) { Event.create }
38
38
  let(:value) { '1' }
39
39
 
40
- it { should be_started }
40
+ it { expect(event).to be_started }
41
41
  end
42
42
 
43
43
  context 'with present argument, twice' do
44
- subject { Event.create(started_at: time) }
44
+ let(:event) { Event.create(started_at: time) }
45
45
  let(:time) { 2.months.ago }
46
46
  let(:value) { '1' }
47
47
 
48
- it { expect(subject.started_at).to eql time }
48
+ it { expect(event.started_at).to eql time }
49
49
  end
50
50
  end
51
51
 
52
52
  describe '#not_started?' do
53
53
  context 'with negative result' do
54
- subject { Event.create(started_at: 2.months.ago) }
55
- it { should_not be_not_started }
54
+ let(:event) { Event.create(started_at: 2.months.ago) }
55
+ it { expect(event).to_not be_not_started }
56
56
  end
57
57
 
58
58
  context 'with positive result' do
59
- subject { Event.create(started_at: 1.month.from_now) }
60
- it { should be_not_started }
59
+ let(:event) { Event.create(started_at: 1.month.from_now) }
60
+ it { expect(event).to be_not_started }
61
61
  end
62
62
  end
63
63
 
@@ -1,8 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Microscope::Scope::BooleanScope do
4
- subject { User }
5
-
6
4
  before do
7
5
  run_migration do
8
6
  create_table(:users, force: true) do |t|
@@ -19,8 +17,8 @@ describe Microscope::Scope::BooleanScope do
19
17
  @user2 = User.create(active: false)
20
18
  end
21
19
 
22
- its(:active) { should have(1).items }
23
- its(:active) { should include(@user1) }
20
+ it { expect(User.active).to have(1).items }
21
+ it { expect(User.active).to include(@user1) }
24
22
  end
25
23
 
26
24
  describe 'negative scope' do
@@ -29,7 +27,8 @@ describe Microscope::Scope::BooleanScope do
29
27
  @user2 = User.create(active: true)
30
28
  end
31
29
 
32
- its(:not_active) { should have(1).items }
33
- its(:not_active) { should include(@user1) }
30
+ it { expect(User.not_active).to have(1).items }
31
+ it { expect(User.not_active).to include(@user1) }
32
+ it { expect(User.unactive.to_a).to eql User.not_active.to_a }
34
33
  end
35
34
  end
@@ -1,8 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Microscope::Scope::DateScope do
4
- subject { Event }
5
-
6
4
  before do
7
5
  run_migration do
8
6
  create_table(:events, force: true) do |t|
@@ -80,24 +78,23 @@ describe Microscope::Scope::DateScope do
80
78
  end
81
79
 
82
80
  it { expect(Event.not_started.to_a).to eql [@event1, @event2] }
81
+ it { expect(Event.unstarted.to_a).to eql Event.not_started.to_a }
83
82
  end
84
83
 
85
84
  describe 'boolean instance method' do
86
85
  context 'for positive record' do
87
- subject { Event.create(started_on: 3.months.ago) }
88
- it { should be_started }
86
+ let(:event) { Event.create(started_on: 3.months.ago) }
87
+ it { expect(event).to be_started }
89
88
  end
90
89
 
91
90
  context 'for negative record' do
92
- subject { Event.create(started_on: 2.months.from_now) }
93
- it { should_not be_started }
91
+ let(:event) { Event.create(started_on: 2.months.from_now) }
92
+ it { expect(event).to_not be_started }
94
93
  end
95
94
  end
96
95
 
97
96
  context 'for field that does not match the pattern' do
98
- subject { Event }
99
-
100
- it { should_not respond_to(:published_date) }
101
- it { should_not respond_to(:not_published_date) }
97
+ it { expect(Event).to_not respond_to(:published_date) }
98
+ it { expect(Event).to_not respond_to(:not_published_date) }
102
99
  end
103
100
  end
@@ -1,8 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Microscope::Scope::DatetimeScope do
4
- subject { Event }
5
-
6
4
  before do
7
5
  run_migration do
8
6
  create_table(:events, force: true) do |t|
@@ -80,24 +78,23 @@ describe Microscope::Scope::DatetimeScope do
80
78
  end
81
79
 
82
80
  it { expect(Event.not_started.to_a).to eql [@event1, @event2] }
81
+ it { expect(Event.unstarted.to_a).to eql Event.not_started.to_a }
83
82
  end
84
83
 
85
84
  describe 'boolean instance method' do
86
85
  context 'for positive record' do
87
- subject { Event.create(started_at: 3.months.ago) }
88
- it { should be_started }
86
+ let(:event) { Event.create(started_at: 3.months.ago) }
87
+ it { expect(event).to be_started }
89
88
  end
90
89
 
91
90
  context 'for negative record' do
92
- subject { Event.create(started_at: 2.months.from_now) }
93
- it { should_not be_started }
91
+ let(:event) { Event.create(started_at: 2.months.from_now) }
92
+ it { expect(event).to_not be_started }
94
93
  end
95
94
  end
96
95
 
97
96
  context 'for field that does not match the pattern' do
98
- subject { Event }
99
-
100
- it { should_not respond_to(:published_date) }
101
- it { should_not respond_to(:not_published_date) }
97
+ it { expect(Event).to_not respond_to(:published_date) }
98
+ it { expect(Event).to_not respond_to(:not_published_date) }
102
99
  end
103
100
  end
@@ -2,8 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  describe Microscope do
4
4
  describe :acts_as_microscope do
5
- subject { User }
6
-
7
5
  before do
8
6
  run_migration do
9
7
  create_table(:users, force: true) do |t|
@@ -28,32 +26,32 @@ describe Microscope do
28
26
  microscope 'User', except: [:admin, :removed_at, :ended_on]
29
27
  end
30
28
 
31
- it { should respond_to :active }
32
- it { should respond_to :not_active }
33
- it { should respond_to :moderator }
34
- it { should respond_to :not_moderator }
35
- it { should_not respond_to :admin }
36
- it { should_not respond_to :not_admin }
37
- it { should respond_to :published }
38
- it { should respond_to :not_published }
39
- it { should_not respond_to :removed }
40
- it { should_not respond_to :not_removed }
41
- it { should respond_to :started }
42
- it { should respond_to :not_started }
43
- it { should_not respond_to :ended }
44
- it { should_not respond_to :not_ended }
29
+ it { expect(User).to respond_to :active }
30
+ it { expect(User).to respond_to :not_active }
31
+ it { expect(User).to respond_to :moderator }
32
+ it { expect(User).to respond_to :not_moderator }
33
+ it { expect(User).to_not respond_to :admin }
34
+ it { expect(User).to_not respond_to :not_admin }
35
+ it { expect(User).to respond_to :published }
36
+ it { expect(User).to respond_to :not_published }
37
+ it { expect(User).to_not respond_to :removed }
38
+ it { expect(User).to_not respond_to :not_removed }
39
+ it { expect(User).to respond_to :started }
40
+ it { expect(User).to respond_to :not_started }
41
+ it { expect(User).to_not respond_to :ended }
42
+ it { expect(User).to_not respond_to :not_ended }
45
43
 
46
44
  context 'for single instance' do
47
- subject { User.new }
48
-
49
- it { should respond_to :published? }
50
- it { should respond_to :not_published? }
51
- it { should_not respond_to :removed? }
52
- it { should_not respond_to :not_removed? }
53
- it { should respond_to :started? }
54
- it { should respond_to :not_started? }
55
- it { should_not respond_to :ended? }
56
- it { should_not respond_to :not_ended? }
45
+ let(:user) { User.new }
46
+
47
+ it { expect(user).to respond_to :published? }
48
+ it { expect(user).to respond_to :not_published? }
49
+ it { expect(user).to_not respond_to :removed? }
50
+ it { expect(user).to_not respond_to :not_removed? }
51
+ it { expect(user).to respond_to :started? }
52
+ it { expect(user).to respond_to :not_started? }
53
+ it { expect(user).to_not respond_to :ended? }
54
+ it { expect(user).to_not respond_to :not_ended? }
57
55
  end
58
56
  end
59
57
 
@@ -62,32 +60,32 @@ describe Microscope do
62
60
  microscope 'User', only: [:admin, :removed_at, :ended_on]
63
61
  end
64
62
 
65
- it { should_not respond_to :active }
66
- it { should_not respond_to :not_active }
67
- it { should_not respond_to :moderator }
68
- it { should_not respond_to :not_moderator }
69
- it { should respond_to :admin }
70
- it { should respond_to :not_admin }
71
- it { should_not respond_to :published }
72
- it { should_not respond_to :not_published }
73
- it { should respond_to :removed }
74
- it { should respond_to :not_removed }
75
- it { should_not respond_to :started }
76
- it { should_not respond_to :not_started }
77
- it { should respond_to :ended }
78
- it { should respond_to :not_ended }
63
+ it { expect(User).to_not respond_to :active }
64
+ it { expect(User).to_not respond_to :not_active }
65
+ it { expect(User).to_not respond_to :moderator }
66
+ it { expect(User).to_not respond_to :not_moderator }
67
+ it { expect(User).to respond_to :admin }
68
+ it { expect(User).to respond_to :not_admin }
69
+ it { expect(User).to_not respond_to :published }
70
+ it { expect(User).to_not respond_to :not_published }
71
+ it { expect(User).to respond_to :removed }
72
+ it { expect(User).to respond_to :not_removed }
73
+ it { expect(User).to_not respond_to :started }
74
+ it { expect(User).to_not respond_to :not_started }
75
+ it { expect(User).to respond_to :ended }
76
+ it { expect(User).to respond_to :not_ended }
79
77
 
80
78
  context 'for single instance' do
81
- subject { User.new }
82
-
83
- it { should respond_to :removed? }
84
- it { should respond_to :not_removed? }
85
- it { should_not respond_to :published? }
86
- it { should_not respond_to :not_published? }
87
- it { should respond_to :ended? }
88
- it { should respond_to :not_ended? }
89
- it { should_not respond_to :started? }
90
- it { should_not respond_to :not_started? }
79
+ let(:user) { User.new }
80
+
81
+ it { expect(user).to respond_to :removed? }
82
+ it { expect(user).to respond_to :not_removed? }
83
+ it { expect(user).to_not respond_to :published? }
84
+ it { expect(user).to_not respond_to :not_published? }
85
+ it { expect(user).to respond_to :ended? }
86
+ it { expect(user).to respond_to :not_ended? }
87
+ it { expect(user).to_not respond_to :started? }
88
+ it { expect(user).to_not respond_to :not_started? }
91
89
  end
92
90
  end
93
91
 
@@ -96,32 +94,32 @@ describe Microscope do
96
94
  microscope 'User', only: [:admin, :started_on], except: [:active]
97
95
  end
98
96
 
99
- it { should_not respond_to :active }
100
- it { should_not respond_to :not_active }
101
- it { should_not respond_to :moderator }
102
- it { should_not respond_to :not_moderator }
103
- it { should respond_to :admin }
104
- it { should respond_to :not_admin }
105
- it { should respond_to :started }
106
- it { should respond_to :not_started }
107
- it { should_not respond_to :published }
108
- it { should_not respond_to :not_published }
109
- it { should_not respond_to :removed }
110
- it { should_not respond_to :not_removed }
111
- it { should_not respond_to :ended }
112
- it { should_not respond_to :not_ended }
97
+ it { expect(User).to_not respond_to :active }
98
+ it { expect(User).to_not respond_to :not_active }
99
+ it { expect(User).to_not respond_to :moderator }
100
+ it { expect(User).to_not respond_to :not_moderator }
101
+ it { expect(User).to respond_to :admin }
102
+ it { expect(User).to respond_to :not_admin }
103
+ it { expect(User).to respond_to :started }
104
+ it { expect(User).to respond_to :not_started }
105
+ it { expect(User).to_not respond_to :published }
106
+ it { expect(User).to_not respond_to :not_published }
107
+ it { expect(User).to_not respond_to :removed }
108
+ it { expect(User).to_not respond_to :not_removed }
109
+ it { expect(User).to_not respond_to :ended }
110
+ it { expect(User).to_not respond_to :not_ended }
113
111
 
114
112
  context 'for single instance' do
115
- subject { User.new }
116
-
117
- it { should respond_to :started? }
118
- it { should respond_to :not_started? }
119
- it { should_not respond_to :removed? }
120
- it { should_not respond_to :not_removed? }
121
- it { should_not respond_to :published? }
122
- it { should_not respond_to :not_published? }
123
- it { should_not respond_to :ended? }
124
- it { should_not respond_to :not_ended? }
113
+ let(:user) { User.new }
114
+
115
+ it { expect(user).to respond_to :started? }
116
+ it { expect(user).to respond_to :not_started? }
117
+ it { expect(user).to_not respond_to :removed? }
118
+ it { expect(user).to_not respond_to :not_removed? }
119
+ it { expect(user).to_not respond_to :published? }
120
+ it { expect(user).to_not respond_to :not_published? }
121
+ it { expect(user).to_not respond_to :ended? }
122
+ it { expect(user).to_not respond_to :not_ended? }
125
123
  end
126
124
  end
127
125
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: microscope
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7
4
+ version: 0.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Prévost
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-20 00:00:00.000000000 Z
12
+ date: 2014-03-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport