Skip to content

Commit 6dd7f91

Browse files
author
Steven Allen
committed
Deterministic callback counters in specs
1 parent 069a66f commit 6dd7f91

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

spec/controllers/scim_rails/scim_resource_controller_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
end
7171

7272
it "successfully calls before_scim_response" do
73-
expect{ get :resource_user }.to change{ counter.count }.from(0).to(1)
73+
expect{ get :resource_user }.to change{ counter.before_called }.from(0).to(1)
7474
end
7575
end
7676

@@ -85,8 +85,8 @@
8585
ScimRails.config.after_scim_response = nil
8686
end
8787

88-
it "successfully calls before_scim_response" do
89-
expect{ get :resource_user }.to change{ counter.count }.from(0).to(2)
88+
it "successfully calls after_scim_response" do
89+
expect{ get :resource_user }.to change{ counter.after_called }.from(0).to(1)
9090
end
9191
end
9292
end
@@ -154,7 +154,7 @@
154154
end
155155

156156
it "successfully calls before_scim_response" do
157-
expect{ get :resource_group }.to change{ counter.count }.from(0).to(1)
157+
expect{ get :resource_group }.to change{ counter.before_called }.from(0).to(1)
158158
end
159159
end
160160

@@ -170,7 +170,7 @@
170170
end
171171

172172
it "successfully calls before_scim_response" do
173-
expect{ get :resource_group }.to change{ counter.count }.from(0).to(2)
173+
expect{ get :resource_group }.to change{ counter.after_called }.from(0).to(1)
174174
end
175175
end
176176
end

spec/controllers/scim_rails/scim_schema_controller_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ module ScimRails
7777
end
7878

7979
it "successfully calls before_scim_response" do
80-
expect{ get :get_schema, params: { id: 1 } }.to change{ counter.count }.from(0).to(1)
80+
expect{ get :get_schema, params: { id: 1 } }.to change{ counter.before_called }.from(0).to(1)
8181
end
8282
end
8383

@@ -93,7 +93,7 @@ module ScimRails
9393
end
9494

9595
it "successfully calls after_scim_response" do
96-
expect{ get :get_schema, params: { id: 1 } }.to change{ counter.count }.from(0).to(2)
96+
expect{ get :get_schema, params: { id: 1 } }.to change{ counter.after_called }.from(0).to(1)
9797
end
9898
end
9999
end

spec/controllers/scim_rails/scim_service_controller_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
end
7171

7272
it "successfully calls before_scim_response" do
73-
expect{ get :configuration }.to change{ counter.count }.from(0).to(1)
73+
expect{ get :configuration }.to change{ counter.before_called }.from(0).to(1)
7474
end
7575
end
7676

@@ -86,7 +86,7 @@
8686
end
8787

8888
it "successfully calls after_scim_response" do
89-
expect{ get :configuration }.to change{ counter.count }.from(0).to(2)
89+
expect{ get :configuration }.to change{ counter.after_called }.from(0).to(1)
9090
end
9191
end
9292
end

spec/support/callback_helper.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
module CallbackHelper
22
class CallbackCounter
3-
attr_reader :count
3+
attr_reader :before_called, :after_called
44
attr_accessor :before, :after
55

66
def initialize
7-
@count = 0
7+
@before_called = 0
8+
@after_called = 0
89

910
@before = lambda do
10-
@count += 1
11+
@before_called += 1
1112
end
1213

1314
@after = lambda do
14-
@count += 2
15+
@after_called += 1
1516
end
1617
end
1718
end

0 commit comments

Comments
 (0)