@@ -10,12 +10,12 @@ describe InheritanceTracking do |
||
10 | 10 |
class Class3 < Class1; end |
11 | 11 |
|
12 | 12 |
it "tracks subclasses" do |
13 |
- Class1.subclasses.should == [Class2, Class3] |
|
13 |
+ expect(Class1.subclasses).to eq([Class2, Class3]) |
|
14 | 14 |
end |
15 | 15 |
|
16 | 16 |
it "can be temporarily overridden with #with_subclasses" do |
17 | 17 |
Class1.with_subclasses(Class2) do |
18 |
- Class1.subclasses.should == [Class2] |
|
18 |
+ expect(Class1.subclasses).to eq([Class2]) |
|
19 | 19 |
end |
20 | 20 |
end |
21 | 21 |
end |
@@ -26,9 +26,9 @@ describe LiquidDroppable do |
||
26 | 26 |
describe 'test class' do |
27 | 27 |
it 'should be droppable' do |
28 | 28 |
five = DroppableTest.new(5) |
29 |
- five.to_liquid.class.should == DroppableTestDrop |
|
30 |
- Liquid::Template.parse('{{ x.value | plus:3 }}').render('x' => five).should == '8' |
|
31 |
- Liquid::Template.parse('{{ x }}').render('x' => five).should == '[value:5]' |
|
29 |
+ expect(five.to_liquid.class).to eq(DroppableTestDrop) |
|
30 |
+ expect(Liquid::Template.parse('{{ x.value | plus:3 }}').render('x' => five)).to eq('8') |
|
31 |
+ expect(Liquid::Template.parse('{{ x }}').render('x' => five)).to eq('[value:5]') |
|
32 | 32 |
end |
33 | 33 |
end |
34 | 34 |
end |
@@ -10,11 +10,11 @@ describe LiquidInterpolatable::Filters do |
||
10 | 10 |
|
11 | 11 |
describe 'uri_escape' do |
12 | 12 |
it 'should escape a string for use in URI' do |
13 |
- @filter.uri_escape('abc:/?=').should == 'abc%3A%2F%3F%3D' |
|
13 |
+ expect(@filter.uri_escape('abc:/?=')).to eq('abc%3A%2F%3F%3D') |
|
14 | 14 |
end |
15 | 15 |
|
16 | 16 |
it 'should not raise an error when an operand is nil' do |
17 |
- @filter.uri_escape(nil).should be_nil |
|
17 |
+ expect(@filter.uri_escape(nil)).to be_nil |
|
18 | 18 |
end |
19 | 19 |
end |
20 | 20 |
|
@@ -33,8 +33,8 @@ describe LiquidInterpolatable::Filters do |
||
33 | 33 |
|
34 | 34 |
it "should finish without raising an exception" do |
35 | 35 |
agent = Agents::InterpolatableAgent.new(name: "test", options: { 'foo' => '{{bar}' }) |
36 |
- agent.valid?.should == false |
|
37 |
- agent.errors[:options].first.should =~ /not properly terminated/ |
|
36 |
+ expect(agent.valid?).to eq(false) |
|
37 |
+ expect(agent.errors[:options].first).to match(/not properly terminated/) |
|
38 | 38 |
end |
39 | 39 |
end |
40 | 40 |
|
@@ -50,13 +50,13 @@ describe LiquidInterpolatable::Filters do |
||
50 | 50 |
%q{abc}.freeze, |
51 | 51 |
%q{'a"bc'dfa""fds''fa}.freeze, |
52 | 52 |
].each { |string| |
53 |
- @filter.to_xpath_roundtrip(string).should == string |
|
53 |
+ expect(@filter.to_xpath_roundtrip(string)).to eq(string) |
|
54 | 54 |
} |
55 | 55 |
end |
56 | 56 |
|
57 | 57 |
it 'should stringify a non-string operand' do |
58 |
- @filter.to_xpath_roundtrip(nil).should == '' |
|
59 |
- @filter.to_xpath_roundtrip(1).should == '1' |
|
58 |
+ expect(@filter.to_xpath_roundtrip(nil)).to eq('') |
|
59 |
+ expect(@filter.to_xpath_roundtrip(1)).to eq('1') |
|
60 | 60 |
end |
61 | 61 |
end |
62 | 62 |
|
@@ -67,33 +67,33 @@ describe LiquidInterpolatable::Filters do |
||
67 | 67 |
end |
68 | 68 |
|
69 | 69 |
it 'should parse an abosule URI' do |
70 |
- @filter.to_uri('http://example.net/index.html', 'http://example.com/dir/1').should == URI('http://example.net/index.html') |
|
70 |
+ expect(@filter.to_uri('http://example.net/index.html', 'http://example.com/dir/1')).to eq(URI('http://example.net/index.html')) |
|
71 | 71 |
end |
72 | 72 |
|
73 | 73 |
it 'should parse an abosule URI with a base URI specified' do |
74 |
- @filter.to_uri('http://example.net/index.html', 'http://example.com/dir/1').should == URI('http://example.net/index.html') |
|
74 |
+ expect(@filter.to_uri('http://example.net/index.html', 'http://example.com/dir/1')).to eq(URI('http://example.net/index.html')) |
|
75 | 75 |
end |
76 | 76 |
|
77 | 77 |
it 'should parse a relative URI with a base URI specified' do |
78 |
- @filter.to_uri('foo/index.html', 'http://example.com/dir/1').should == URI('http://example.com/dir/foo/index.html') |
|
78 |
+ expect(@filter.to_uri('foo/index.html', 'http://example.com/dir/1')).to eq(URI('http://example.com/dir/foo/index.html')) |
|
79 | 79 |
end |
80 | 80 |
|
81 | 81 |
it 'should parse an abosule URI with a base URI specified' do |
82 |
- @filter.to_uri('http://example.net/index.html', 'http://example.com/dir/1').should == URI('http://example.net/index.html') |
|
82 |
+ expect(@filter.to_uri('http://example.net/index.html', 'http://example.com/dir/1')).to eq(URI('http://example.net/index.html')) |
|
83 | 83 |
end |
84 | 84 |
|
85 | 85 |
it 'should stringify a non-string operand' do |
86 |
- @filter.to_uri(123, 'http://example.com/dir/1').should == URI('http://example.com/dir/123') |
|
86 |
+ expect(@filter.to_uri(123, 'http://example.com/dir/1')).to eq(URI('http://example.com/dir/123')) |
|
87 | 87 |
end |
88 | 88 |
|
89 | 89 |
it 'should return a URI value in interpolation' do |
90 |
- @agent.interpolated['foo'].should == '/dir/1' |
|
90 |
+ expect(@agent.interpolated['foo']).to eq('/dir/1') |
|
91 | 91 |
end |
92 | 92 |
|
93 | 93 |
it 'should return a URI value resolved against a base URI in interpolation' do |
94 | 94 |
@agent.options['foo'] = '{% assign u = s | to_uri:"http://example.com/dir/1" %}{{ u.path }}' |
95 | 95 |
@agent.interpolation_context['s'] = 'foo/index.html' |
96 |
- @agent.interpolated['foo'].should == '/dir/foo/index.html' |
|
96 |
+ expect(@agent.interpolated['foo']).to eq('/dir/foo/index.html') |
|
97 | 97 |
end |
98 | 98 |
end |
99 | 99 |
end |
@@ -14,7 +14,7 @@ describe AgentsController do |
||
14 | 14 |
it "only returns Agents for the current user" do |
15 | 15 |
sign_in users(:bob) |
16 | 16 |
get :index |
17 |
- assigns(:agents).all? {|i| i.user.should == users(:bob) }.should be_truthy |
|
17 |
+ expect(assigns(:agents).all? {|i| expect(i.user).to eq(users(:bob)) }).to be_truthy |
|
18 | 18 |
end |
19 | 19 |
end |
20 | 20 |
|
@@ -22,15 +22,15 @@ describe AgentsController do |
||
22 | 22 |
it "passes control to handle_details_post on the agent" do |
23 | 23 |
sign_in users(:bob) |
24 | 24 |
post :handle_details_post, :id => agents(:bob_manual_event_agent).to_param, :payload => { :foo => "bar" } |
25 |
- JSON.parse(response.body).should == { "success" => true } |
|
26 |
- agents(:bob_manual_event_agent).events.last.payload.should == { 'foo' => "bar" } |
|
25 |
+ expect(JSON.parse(response.body)).to eq({ "success" => true }) |
|
26 |
+ expect(agents(:bob_manual_event_agent).events.last.payload).to eq({ 'foo' => "bar" }) |
|
27 | 27 |
end |
28 | 28 |
|
29 | 29 |
it "can only be accessed by the Agent's owner" do |
30 | 30 |
sign_in users(:jane) |
31 |
- lambda { |
|
31 |
+ expect { |
|
32 | 32 |
post :handle_details_post, :id => agents(:bob_manual_event_agent).to_param, :payload => { :foo => :bar } |
33 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
33 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
34 | 34 |
end |
35 | 35 |
end |
36 | 36 |
|
@@ -43,9 +43,9 @@ describe AgentsController do |
||
43 | 43 |
|
44 | 44 |
it "can only be accessed by the Agent's owner" do |
45 | 45 |
sign_in users(:jane) |
46 |
- lambda { |
|
46 |
+ expect { |
|
47 | 47 |
post :run, :id => agents(:bob_manual_event_agent).to_param |
48 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
48 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
49 | 49 |
end |
50 | 50 |
end |
51 | 51 |
|
@@ -55,15 +55,15 @@ describe AgentsController do |
||
55 | 55 |
agent_event = events(:bob_website_agent_event).id |
56 | 56 |
other_event = events(:jane_website_agent_event).id |
57 | 57 |
post :remove_events, :id => agents(:bob_website_agent).to_param |
58 |
- Event.where(:id => agent_event).count.should == 0 |
|
59 |
- Event.where(:id => other_event).count.should == 1 |
|
58 |
+ expect(Event.where(:id => agent_event).count).to eq(0) |
|
59 |
+ expect(Event.where(:id => other_event).count).to eq(1) |
|
60 | 60 |
end |
61 | 61 |
|
62 | 62 |
it "can only be accessed by the Agent's owner" do |
63 | 63 |
sign_in users(:jane) |
64 |
- lambda { |
|
64 |
+ expect { |
|
65 | 65 |
post :remove_events, :id => agents(:bob_website_agent).to_param |
66 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
66 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
67 | 67 |
end |
68 | 68 |
end |
69 | 69 |
|
@@ -79,11 +79,11 @@ describe AgentsController do |
||
79 | 79 |
it "only shows Agents for the current user" do |
80 | 80 |
sign_in users(:bob) |
81 | 81 |
get :show, :id => agents(:bob_website_agent).to_param |
82 |
- assigns(:agent).should eq(agents(:bob_website_agent)) |
|
82 |
+ expect(assigns(:agent)).to eq(agents(:bob_website_agent)) |
|
83 | 83 |
|
84 |
- lambda { |
|
84 |
+ expect { |
|
85 | 85 |
get :show, :id => agents(:jane_website_agent).to_param |
86 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
86 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
87 | 87 |
end |
88 | 88 |
end |
89 | 89 |
|
@@ -91,15 +91,15 @@ describe AgentsController do |
||
91 | 91 |
it "opens a clone of a given Agent" do |
92 | 92 |
sign_in users(:bob) |
93 | 93 |
get :new, :id => agents(:bob_website_agent).to_param |
94 |
- assigns(:agent).attributes.should eq(users(:bob).agents.build_clone(agents(:bob_website_agent)).attributes) |
|
94 |
+ expect(assigns(:agent).attributes).to eq(users(:bob).agents.build_clone(agents(:bob_website_agent)).attributes) |
|
95 | 95 |
end |
96 | 96 |
|
97 | 97 |
it "only allows the current user to clone his own Agent" do |
98 | 98 |
sign_in users(:bob) |
99 | 99 |
|
100 |
- lambda { |
|
100 |
+ expect { |
|
101 | 101 |
get :new, :id => agents(:jane_website_agent).to_param |
102 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
102 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
103 | 103 |
end |
104 | 104 |
end |
105 | 105 |
|
@@ -107,11 +107,11 @@ describe AgentsController do |
||
107 | 107 |
it "only shows Agents for the current user" do |
108 | 108 |
sign_in users(:bob) |
109 | 109 |
get :edit, :id => agents(:bob_website_agent).to_param |
110 |
- assigns(:agent).should eq(agents(:bob_website_agent)) |
|
110 |
+ expect(assigns(:agent)).to eq(agents(:bob_website_agent)) |
|
111 | 111 |
|
112 |
- lambda { |
|
112 |
+ expect { |
|
113 | 113 |
get :edit, :id => agents(:jane_website_agent).to_param |
114 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
114 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
115 | 115 |
end |
116 | 116 |
end |
117 | 117 |
|
@@ -121,28 +121,28 @@ describe AgentsController do |
||
121 | 121 |
expect { |
122 | 122 |
post :create, :agent => valid_attributes(:type => "Agents::ThisIsFake") |
123 | 123 |
}.not_to change { users(:bob).agents.count } |
124 |
- assigns(:agent).should be_a(Agent) |
|
125 |
- assigns(:agent).should have(1).error_on(:type) |
|
124 |
+ expect(assigns(:agent)).to be_a(Agent) |
|
125 |
+ expect(assigns(:agent)).to have(1).error_on(:type) |
|
126 | 126 |
|
127 | 127 |
sign_in users(:bob) |
128 | 128 |
expect { |
129 | 129 |
post :create, :agent => valid_attributes(:type => "Object") |
130 | 130 |
}.not_to change { users(:bob).agents.count } |
131 |
- assigns(:agent).should be_a(Agent) |
|
132 |
- assigns(:agent).should have(1).error_on(:type) |
|
131 |
+ expect(assigns(:agent)).to be_a(Agent) |
|
132 |
+ expect(assigns(:agent)).to have(1).error_on(:type) |
|
133 | 133 |
sign_in users(:bob) |
134 | 134 |
|
135 | 135 |
expect { |
136 | 136 |
post :create, :agent => valid_attributes(:type => "Agent") |
137 | 137 |
}.not_to change { users(:bob).agents.count } |
138 |
- assigns(:agent).should be_a(Agent) |
|
139 |
- assigns(:agent).should have(1).error_on(:type) |
|
138 |
+ expect(assigns(:agent)).to be_a(Agent) |
|
139 |
+ expect(assigns(:agent)).to have(1).error_on(:type) |
|
140 | 140 |
|
141 | 141 |
expect { |
142 | 142 |
post :create, :agent => valid_attributes(:type => "User") |
143 | 143 |
}.not_to change { users(:bob).agents.count } |
144 |
- assigns(:agent).should be_a(Agent) |
|
145 |
- assigns(:agent).should have(1).error_on(:type) |
|
144 |
+ expect(assigns(:agent)).to be_a(Agent) |
|
145 |
+ expect(assigns(:agent)).to have(1).error_on(:type) |
|
146 | 146 |
end |
147 | 147 |
|
148 | 148 |
it "creates Agents for the current user" do |
@@ -152,7 +152,7 @@ describe AgentsController do |
||
152 | 152 |
post :create, :agent => valid_attributes |
153 | 153 |
}.to change { users(:bob).agents.count }.by(1) |
154 | 154 |
}.to change { Link.count }.by(1) |
155 |
- assigns(:agent).should be_a(Agents::WebsiteAgent) |
|
155 |
+ expect(assigns(:agent)).to be_a(Agents::WebsiteAgent) |
|
156 | 156 |
end |
157 | 157 |
|
158 | 158 |
it "shows errors" do |
@@ -160,8 +160,8 @@ describe AgentsController do |
||
160 | 160 |
expect { |
161 | 161 |
post :create, :agent => valid_attributes(:name => "") |
162 | 162 |
}.not_to change { users(:bob).agents.count } |
163 |
- assigns(:agent).should have(1).errors_on(:name) |
|
164 |
- response.should render_template("new") |
|
163 |
+ expect(assigns(:agent)).to have(1).errors_on(:name) |
|
164 |
+ expect(response).to render_template("new") |
|
165 | 165 |
end |
166 | 166 |
|
167 | 167 |
it "will not accept Agent sources owned by other users" do |
@@ -178,46 +178,46 @@ describe AgentsController do |
||
178 | 178 |
it "does not allow changing types" do |
179 | 179 |
sign_in users(:bob) |
180 | 180 |
post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:type => "Agents::WeatherAgent") |
181 |
- assigns(:agent).should have(1).errors_on(:type) |
|
182 |
- response.should render_template("edit") |
|
181 |
+ expect(assigns(:agent)).to have(1).errors_on(:type) |
|
182 |
+ expect(response).to render_template("edit") |
|
183 | 183 |
end |
184 | 184 |
|
185 | 185 |
it "updates attributes on Agents for the current user" do |
186 | 186 |
sign_in users(:bob) |
187 | 187 |
post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name") |
188 |
- response.should redirect_to(agents_path) |
|
189 |
- agents(:bob_website_agent).reload.name.should == "New name" |
|
188 |
+ expect(response).to redirect_to(agents_path) |
|
189 |
+ expect(agents(:bob_website_agent).reload.name).to eq("New name") |
|
190 | 190 |
|
191 |
- lambda { |
|
191 |
+ expect { |
|
192 | 192 |
post :update, :id => agents(:jane_website_agent).to_param, :agent => valid_attributes(:name => "New name") |
193 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
193 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
194 | 194 |
end |
195 | 195 |
|
196 | 196 |
it "accepts JSON requests" do |
197 | 197 |
sign_in users(:bob) |
198 | 198 |
post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name"), :format => :json |
199 |
- agents(:bob_website_agent).reload.name.should == "New name" |
|
200 |
- JSON.parse(response.body)['name'].should == "New name" |
|
201 |
- response.should be_success |
|
199 |
+ expect(agents(:bob_website_agent).reload.name).to eq("New name") |
|
200 |
+ expect(JSON.parse(response.body)['name']).to eq("New name") |
|
201 |
+ expect(response).to be_success |
|
202 | 202 |
end |
203 | 203 |
|
204 | 204 |
it "will not accept Agent sources owned by other users" do |
205 | 205 |
sign_in users(:bob) |
206 | 206 |
post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:source_ids => [agents(:jane_weather_agent).id]) |
207 |
- assigns(:agent).should have(1).errors_on(:sources) |
|
207 |
+ expect(assigns(:agent)).to have(1).errors_on(:sources) |
|
208 | 208 |
end |
209 | 209 |
|
210 | 210 |
it "will not accept Scenarios owned by other users" do |
211 | 211 |
sign_in users(:bob) |
212 | 212 |
post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:scenario_ids => [scenarios(:jane_weather).id]) |
213 |
- assigns(:agent).should have(1).errors_on(:scenarios) |
|
213 |
+ expect(assigns(:agent)).to have(1).errors_on(:scenarios) |
|
214 | 214 |
end |
215 | 215 |
|
216 | 216 |
it "shows errors" do |
217 | 217 |
sign_in users(:bob) |
218 | 218 |
post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "") |
219 |
- assigns(:agent).should have(1).errors_on(:name) |
|
220 |
- response.should render_template("edit") |
|
219 |
+ expect(assigns(:agent)).to have(1).errors_on(:name) |
|
220 |
+ expect(response).to render_template("edit") |
|
221 | 221 |
end |
222 | 222 |
|
223 | 223 |
describe "redirecting back" do |
@@ -227,28 +227,28 @@ describe AgentsController do |
||
227 | 227 |
|
228 | 228 |
it "can redirect back to the show path" do |
229 | 229 |
post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name"), :return => "show" |
230 |
- response.should redirect_to(agent_path(agents(:bob_website_agent))) |
|
230 |
+ expect(response).to redirect_to(agent_path(agents(:bob_website_agent))) |
|
231 | 231 |
end |
232 | 232 |
|
233 | 233 |
it "redirect back to the index path by default" do |
234 | 234 |
post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name") |
235 |
- response.should redirect_to(agents_path) |
|
235 |
+ expect(response).to redirect_to(agents_path) |
|
236 | 236 |
end |
237 | 237 |
|
238 | 238 |
it "accepts return paths to scenarios" do |
239 | 239 |
post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name"), :return => "/scenarios/2" |
240 |
- response.should redirect_to("/scenarios/2") |
|
240 |
+ expect(response).to redirect_to("/scenarios/2") |
|
241 | 241 |
end |
242 | 242 |
|
243 | 243 |
it "sanitizes return paths" do |
244 | 244 |
post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name"), :return => "/scenar" |
245 |
- response.should redirect_to(agents_path) |
|
245 |
+ expect(response).to redirect_to(agents_path) |
|
246 | 246 |
|
247 | 247 |
post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name"), :return => "http://google.com" |
248 |
- response.should redirect_to(agents_path) |
|
248 |
+ expect(response).to redirect_to(agents_path) |
|
249 | 249 |
|
250 | 250 |
post :update, :id => agents(:bob_website_agent).to_param, :agent => valid_attributes(:name => "New name"), :return => "javascript:alert(1)" |
251 |
- response.should redirect_to(agents_path) |
|
251 |
+ expect(response).to redirect_to(agents_path) |
|
252 | 252 |
end |
253 | 253 |
end |
254 | 254 |
|
@@ -260,8 +260,8 @@ describe AgentsController do |
||
260 | 260 |
agent.save! |
261 | 261 |
post :update, id: agents(:bob_website_agent).to_param, agent: { disabled: 'false', drop_pending_events: 'true' } |
262 | 262 |
agent.reload |
263 |
- agent.disabled.should == false |
|
264 |
- agent.last_checked_event_id.should == Event.maximum(:id) |
|
263 |
+ expect(agent.disabled).to eq(false) |
|
264 |
+ expect(agent.last_checked_event_id).to eq(Event.maximum(:id)) |
|
265 | 265 |
end |
266 | 266 |
end |
267 | 267 |
|
@@ -269,15 +269,15 @@ describe AgentsController do |
||
269 | 269 |
it "removes an Agent from the given Scenario for the current user" do |
270 | 270 |
sign_in users(:bob) |
271 | 271 |
|
272 |
- agents(:bob_weather_agent).scenarios.should include(scenarios(:bob_weather)) |
|
272 |
+ expect(agents(:bob_weather_agent).scenarios).to include(scenarios(:bob_weather)) |
|
273 | 273 |
put :leave_scenario, :id => agents(:bob_weather_agent).to_param, :scenario_id => scenarios(:bob_weather).to_param |
274 |
- agents(:bob_weather_agent).scenarios.should_not include(scenarios(:bob_weather)) |
|
274 |
+ expect(agents(:bob_weather_agent).scenarios).not_to include(scenarios(:bob_weather)) |
|
275 | 275 |
|
276 |
- Scenario.where(:id => scenarios(:bob_weather).id).should exist |
|
276 |
+ expect(Scenario.where(:id => scenarios(:bob_weather).id)).to exist |
|
277 | 277 |
|
278 |
- lambda { |
|
278 |
+ expect { |
|
279 | 279 |
put :leave_scenario, :id => agents(:jane_weather_agent).to_param, :scenario_id => scenarios(:jane_weather).to_param |
280 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
280 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
281 | 281 |
end |
282 | 282 |
end |
283 | 283 |
|
@@ -288,23 +288,23 @@ describe AgentsController do |
||
288 | 288 |
delete :destroy, :id => agents(:bob_website_agent).to_param |
289 | 289 |
}.to change(Agent, :count).by(-1) |
290 | 290 |
|
291 |
- lambda { |
|
291 |
+ expect { |
|
292 | 292 |
delete :destroy, :id => agents(:jane_website_agent).to_param |
293 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
293 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
294 | 294 |
end |
295 | 295 |
|
296 | 296 |
it "redirects correctly when the Agent is deleted from the Agent itself" do |
297 | 297 |
sign_in users(:bob) |
298 | 298 |
|
299 | 299 |
delete :destroy, :id => agents(:bob_website_agent).to_param |
300 |
- response.should redirect_to agents_path |
|
300 |
+ expect(response).to redirect_to agents_path |
|
301 | 301 |
end |
302 | 302 |
|
303 | 303 |
it "redirects correctly when the Agent is deleted from a Scenario" do |
304 | 304 |
sign_in users(:bob) |
305 | 305 |
|
306 | 306 |
delete :destroy, :id => agents(:bob_weather_agent).to_param, :return => scenario_path(scenarios(:bob_weather)).to_param |
307 |
- response.should redirect_to scenario_path(scenarios(:bob_weather)) |
|
307 |
+ expect(response).to redirect_to scenario_path(scenarios(:bob_weather)) |
|
308 | 308 |
end |
309 | 309 |
end |
310 | 310 |
end |
@@ -21,41 +21,41 @@ describe SortableTable do |
||
21 | 21 |
it "uses a default when no sort is given" do |
22 | 22 |
controller.params = {} |
23 | 23 |
controller.set_table_sort options |
24 |
- controller.table_sort.should == default |
|
24 |
+ expect(controller.table_sort).to eq(default) |
|
25 | 25 |
end |
26 | 26 |
|
27 | 27 |
it "applies the given sort when one is passed in" do |
28 | 28 |
controller.params = { sort: "column1.desc" } |
29 | 29 |
controller.set_table_sort options |
30 |
- controller.table_sort.should == { column1: :desc } |
|
30 |
+ expect(controller.table_sort).to eq({ column1: :desc }) |
|
31 | 31 |
|
32 | 32 |
controller.params = { sort: "column1.asc" } |
33 | 33 |
controller.set_table_sort options |
34 |
- controller.table_sort.should == { column1: :asc } |
|
34 |
+ expect(controller.table_sort).to eq({ column1: :asc }) |
|
35 | 35 |
|
36 | 36 |
controller.params = { sort: "column2.desc" } |
37 | 37 |
controller.set_table_sort options |
38 |
- controller.table_sort.should == { column2: :desc } |
|
38 |
+ expect(controller.table_sort).to eq({ column2: :desc }) |
|
39 | 39 |
end |
40 | 40 |
|
41 | 41 |
it "ignores unknown directions" do |
42 | 42 |
controller.params = { sort: "column1.foo" } |
43 | 43 |
controller.set_table_sort options |
44 |
- controller.table_sort.should == { column1: :asc } |
|
44 |
+ expect(controller.table_sort).to eq({ column1: :asc }) |
|
45 | 45 |
|
46 | 46 |
controller.params = { sort: "column1.foo drop tables" } |
47 | 47 |
controller.set_table_sort options |
48 |
- controller.table_sort.should == { column1: :asc } |
|
48 |
+ expect(controller.table_sort).to eq({ column1: :asc }) |
|
49 | 49 |
end |
50 | 50 |
|
51 | 51 |
it "ignores unknown columns" do |
52 | 52 |
controller.params = { sort: "foo.asc" } |
53 | 53 |
controller.set_table_sort options |
54 |
- controller.table_sort.should == default |
|
54 |
+ expect(controller.table_sort).to eq(default) |
|
55 | 55 |
|
56 | 56 |
controller.params = { sort: ";drop table;.asc" } |
57 | 57 |
controller.set_table_sort options |
58 |
- controller.table_sort.should == default |
|
58 |
+ expect(controller.table_sort).to eq(default) |
|
59 | 59 |
end |
60 | 60 |
end |
61 |
-end |
|
61 |
+end |
@@ -2,26 +2,26 @@ require 'spec_helper' |
||
2 | 2 |
|
3 | 3 |
describe EventsController do |
4 | 4 |
before do |
5 |
- Event.where(:user_id => users(:bob).id).count.should > 0 |
|
6 |
- Event.where(:user_id => users(:jane).id).count.should > 0 |
|
5 |
+ expect(Event.where(:user_id => users(:bob).id).count).to be > 0 |
|
6 |
+ expect(Event.where(:user_id => users(:jane).id).count).to be > 0 |
|
7 | 7 |
end |
8 | 8 |
|
9 | 9 |
describe "GET index" do |
10 | 10 |
it "only returns Events created by Agents of the current user" do |
11 | 11 |
sign_in users(:bob) |
12 | 12 |
get :index |
13 |
- assigns(:events).all? {|i| i.user.should == users(:bob) }.should be_truthy |
|
13 |
+ expect(assigns(:events).all? {|i| expect(i.user).to eq(users(:bob)) }).to be_truthy |
|
14 | 14 |
end |
15 | 15 |
|
16 | 16 |
it "can filter by Agent" do |
17 | 17 |
sign_in users(:bob) |
18 | 18 |
get :index, :agent_id => agents(:bob_website_agent) |
19 |
- assigns(:events).length.should == agents(:bob_website_agent).events.length |
|
20 |
- assigns(:events).all? {|i| i.agent.should == agents(:bob_website_agent) }.should be_truthy |
|
19 |
+ expect(assigns(:events).length).to eq(agents(:bob_website_agent).events.length) |
|
20 |
+ expect(assigns(:events).all? {|i| expect(i.agent).to eq(agents(:bob_website_agent)) }).to be_truthy |
|
21 | 21 |
|
22 |
- lambda { |
|
22 |
+ expect { |
|
23 | 23 |
get :index, :agent_id => agents(:jane_website_agent) |
24 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
24 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
25 | 25 |
end |
26 | 26 |
end |
27 | 27 |
|
@@ -29,11 +29,11 @@ describe EventsController do |
||
29 | 29 |
it "only shows Events for the current user" do |
30 | 30 |
sign_in users(:bob) |
31 | 31 |
get :show, :id => events(:bob_website_agent_event).to_param |
32 |
- assigns(:event).should eq(events(:bob_website_agent_event)) |
|
32 |
+ expect(assigns(:event)).to eq(events(:bob_website_agent_event)) |
|
33 | 33 |
|
34 |
- lambda { |
|
34 |
+ expect { |
|
35 | 35 |
get :show, :id => events(:jane_website_agent_event).to_param |
36 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
36 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
37 | 37 |
end |
38 | 38 |
end |
39 | 39 |
|
@@ -44,31 +44,31 @@ describe EventsController do |
||
44 | 44 |
end |
45 | 45 |
|
46 | 46 |
it "clones and re-emits events" do |
47 |
- lambda { |
|
47 |
+ expect { |
|
48 | 48 |
post :reemit, :id => events(:bob_website_agent_event).to_param |
49 |
- }.should change { Event.count }.by(1) |
|
50 |
- Event.last.payload.should == events(:bob_website_agent_event).payload |
|
51 |
- Event.last.agent.should == events(:bob_website_agent_event).agent |
|
52 |
- Event.last.created_at.to_i.should be_within(2).of(Time.now.to_i) |
|
49 |
+ }.to change { Event.count }.by(1) |
|
50 |
+ expect(Event.last.payload).to eq(events(:bob_website_agent_event).payload) |
|
51 |
+ expect(Event.last.agent).to eq(events(:bob_website_agent_event).agent) |
|
52 |
+ expect(Event.last.created_at.to_i).to be_within(2).of(Time.now.to_i) |
|
53 | 53 |
end |
54 | 54 |
|
55 | 55 |
it "can only re-emit Events for the current user" do |
56 |
- lambda { |
|
56 |
+ expect { |
|
57 | 57 |
post :reemit, :id => events(:jane_website_agent_event).to_param |
58 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
58 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
59 | 59 |
end |
60 | 60 |
end |
61 | 61 |
|
62 | 62 |
describe "DELETE destroy" do |
63 | 63 |
it "only deletes events for the current user" do |
64 | 64 |
sign_in users(:bob) |
65 |
- lambda { |
|
65 |
+ expect { |
|
66 | 66 |
delete :destroy, :id => events(:bob_website_agent_event).to_param |
67 |
- }.should change { Event.count }.by(-1) |
|
67 |
+ }.to change { Event.count }.by(-1) |
|
68 | 68 |
|
69 |
- lambda { |
|
69 |
+ expect { |
|
70 | 70 |
delete :destroy, :id => events(:jane_website_agent_event).to_param |
71 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
71 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
72 | 72 |
end |
73 | 73 |
end |
74 | 74 |
end |
@@ -6,20 +6,20 @@ describe JobsController do |
||
6 | 6 |
before do |
7 | 7 |
Delayed::Job.create! |
8 | 8 |
Delayed::Job.create! |
9 |
- Delayed::Job.count.should > 0 |
|
9 |
+ expect(Delayed::Job.count).to be > 0 |
|
10 | 10 |
end |
11 | 11 |
|
12 | 12 |
it "does not allow normal users" do |
13 |
- users(:bob).should_not be_admin |
|
13 |
+ expect(users(:bob)).not_to be_admin |
|
14 | 14 |
sign_in users(:bob) |
15 |
- get(:index).should redirect_to(root_path) |
|
15 |
+ expect(get(:index)).to redirect_to(root_path) |
|
16 | 16 |
end |
17 | 17 |
|
18 | 18 |
it "returns all jobs" do |
19 |
- users(:jane).should be_admin |
|
19 |
+ expect(users(:jane)).to be_admin |
|
20 | 20 |
sign_in users(:jane) |
21 | 21 |
get :index |
22 |
- assigns(:jobs).length.should == 2 |
|
22 |
+ expect(assigns(:jobs).length).to eq(2) |
|
23 | 23 |
end |
24 | 24 |
end |
25 | 25 |
|
@@ -5,15 +5,15 @@ describe LogsController do |
||
5 | 5 |
it "can filter by Agent" do |
6 | 6 |
sign_in users(:bob) |
7 | 7 |
get :index, :agent_id => agents(:bob_weather_agent).id |
8 |
- assigns(:logs).length.should == agents(:bob_weather_agent).logs.length |
|
9 |
- assigns(:logs).all? {|i| i.agent.should == agents(:bob_weather_agent) }.should be_truthy |
|
8 |
+ expect(assigns(:logs).length).to eq(agents(:bob_weather_agent).logs.length) |
|
9 |
+ expect(assigns(:logs).all? {|i| expect(i.agent).to eq(agents(:bob_weather_agent)) }).to be_truthy |
|
10 | 10 |
end |
11 | 11 |
|
12 | 12 |
it "only loads Agents owned by the current user" do |
13 | 13 |
sign_in users(:bob) |
14 |
- lambda { |
|
14 |
+ expect { |
|
15 | 15 |
get :index, :agent_id => agents(:jane_weather_agent).id |
16 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
16 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
17 | 17 |
end |
18 | 18 |
end |
19 | 19 |
|
@@ -21,19 +21,19 @@ describe LogsController do |
||
21 | 21 |
it "deletes all logs for a specific Agent" do |
22 | 22 |
agents(:bob_weather_agent).last_error_log_at = 2.hours.ago |
23 | 23 |
sign_in users(:bob) |
24 |
- lambda { |
|
24 |
+ expect { |
|
25 | 25 |
delete :clear, :agent_id => agents(:bob_weather_agent).id |
26 |
- }.should change { AgentLog.count }.by(-1 * agents(:bob_weather_agent).logs.count) |
|
27 |
- assigns(:logs).length.should == 0 |
|
28 |
- agents(:bob_weather_agent).reload.logs.count.should == 0 |
|
29 |
- agents(:bob_weather_agent).last_error_log_at.should be_nil |
|
26 |
+ }.to change { AgentLog.count }.by(-1 * agents(:bob_weather_agent).logs.count) |
|
27 |
+ expect(assigns(:logs).length).to eq(0) |
|
28 |
+ expect(agents(:bob_weather_agent).reload.logs.count).to eq(0) |
|
29 |
+ expect(agents(:bob_weather_agent).last_error_log_at).to be_nil |
|
30 | 30 |
end |
31 | 31 |
|
32 | 32 |
it "only deletes logs for an Agent owned by the current user" do |
33 | 33 |
sign_in users(:bob) |
34 |
- lambda { |
|
34 |
+ expect { |
|
35 | 35 |
delete :clear, :agent_id => agents(:jane_weather_agent).id |
36 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
36 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
37 | 37 |
end |
38 | 38 |
end |
39 | 39 |
end |
@@ -8,18 +8,18 @@ describe ScenarioImportsController do |
||
8 | 8 |
describe "GET new" do |
9 | 9 |
it "initializes a new ScenarioImport and renders new" do |
10 | 10 |
get :new |
11 |
- assigns(:scenario_import).should be_a(ScenarioImport) |
|
12 |
- response.should render_template(:new) |
|
11 |
+ expect(assigns(:scenario_import)).to be_a(ScenarioImport) |
|
12 |
+ expect(response).to render_template(:new) |
|
13 | 13 |
end |
14 | 14 |
end |
15 | 15 |
|
16 | 16 |
describe "POST create" do |
17 | 17 |
it "initializes a ScenarioImport for current_user, passing in params" do |
18 | 18 |
post :create, :scenario_import => { :url => "bad url" } |
19 |
- assigns(:scenario_import).user.should == users(:bob) |
|
20 |
- assigns(:scenario_import).url.should == "bad url" |
|
21 |
- assigns(:scenario_import).should_not be_valid |
|
22 |
- response.should render_template(:new) |
|
19 |
+ expect(assigns(:scenario_import).user).to eq(users(:bob)) |
|
20 |
+ expect(assigns(:scenario_import).url).to eq("bad url") |
|
21 |
+ expect(assigns(:scenario_import)).not_to be_valid |
|
22 |
+ expect(response).to render_template(:new) |
|
23 | 23 |
end |
24 | 24 |
end |
25 | 25 |
end |
@@ -12,59 +12,59 @@ describe ScenariosController do |
||
12 | 12 |
describe "GET index" do |
13 | 13 |
it "only returns Scenarios for the current user" do |
14 | 14 |
get :index |
15 |
- assigns(:scenarios).all? {|i| i.user.should == users(:bob) }.should be_truthy |
|
15 |
+ expect(assigns(:scenarios).all? {|i| expect(i.user).to eq(users(:bob)) }).to be_truthy |
|
16 | 16 |
end |
17 | 17 |
end |
18 | 18 |
|
19 | 19 |
describe "GET show" do |
20 | 20 |
it "only shows Scenarios for the current user" do |
21 | 21 |
get :show, :id => scenarios(:bob_weather).to_param |
22 |
- assigns(:scenario).should eq(scenarios(:bob_weather)) |
|
22 |
+ expect(assigns(:scenario)).to eq(scenarios(:bob_weather)) |
|
23 | 23 |
|
24 |
- lambda { |
|
24 |
+ expect { |
|
25 | 25 |
get :show, :id => scenarios(:jane_weather).to_param |
26 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
26 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
27 | 27 |
end |
28 | 28 |
|
29 | 29 |
it "loads Agents for the requested Scenario" do |
30 | 30 |
get :show, :id => scenarios(:bob_weather).to_param |
31 |
- assigns(:agents).pluck(:id).should eq(scenarios(:bob_weather).agents.pluck(:id)) |
|
31 |
+ expect(assigns(:agents).pluck(:id)).to eq(scenarios(:bob_weather).agents.pluck(:id)) |
|
32 | 32 |
end |
33 | 33 |
end |
34 | 34 |
|
35 | 35 |
describe "GET share" do |
36 | 36 |
it "only displays Scenario share information for the current user" do |
37 | 37 |
get :share, :id => scenarios(:bob_weather).to_param |
38 |
- assigns(:scenario).should eq(scenarios(:bob_weather)) |
|
38 |
+ expect(assigns(:scenario)).to eq(scenarios(:bob_weather)) |
|
39 | 39 |
|
40 |
- lambda { |
|
40 |
+ expect { |
|
41 | 41 |
get :share, :id => scenarios(:jane_weather).to_param |
42 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
42 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
43 | 43 |
end |
44 | 44 |
end |
45 | 45 |
|
46 | 46 |
describe "GET export" do |
47 | 47 |
it "returns a JSON file download from an instantiated AgentsExporter" do |
48 | 48 |
get :export, :id => scenarios(:bob_weather).to_param |
49 |
- assigns(:exporter).options[:name].should == scenarios(:bob_weather).name |
|
50 |
- assigns(:exporter).options[:description].should == scenarios(:bob_weather).description |
|
51 |
- assigns(:exporter).options[:agents].should == scenarios(:bob_weather).agents |
|
52 |
- assigns(:exporter).options[:guid].should == scenarios(:bob_weather).guid |
|
53 |
- assigns(:exporter).options[:tag_fg_color].should == scenarios(:bob_weather).tag_fg_color |
|
54 |
- assigns(:exporter).options[:tag_bg_color].should == scenarios(:bob_weather).tag_bg_color |
|
55 |
- assigns(:exporter).options[:source_url].should be_falsey |
|
56 |
- response.headers['Content-Disposition'].should == 'attachment; filename="bob-s-weather-alert-scenario.json"' |
|
57 |
- response.headers['Content-Type'].should == 'application/json; charset=utf-8' |
|
58 |
- JSON.parse(response.body)["name"].should == scenarios(:bob_weather).name |
|
49 |
+ expect(assigns(:exporter).options[:name]).to eq(scenarios(:bob_weather).name) |
|
50 |
+ expect(assigns(:exporter).options[:description]).to eq(scenarios(:bob_weather).description) |
|
51 |
+ expect(assigns(:exporter).options[:agents]).to eq(scenarios(:bob_weather).agents) |
|
52 |
+ expect(assigns(:exporter).options[:guid]).to eq(scenarios(:bob_weather).guid) |
|
53 |
+ expect(assigns(:exporter).options[:tag_fg_color]).to eq(scenarios(:bob_weather).tag_fg_color) |
|
54 |
+ expect(assigns(:exporter).options[:tag_bg_color]).to eq(scenarios(:bob_weather).tag_bg_color) |
|
55 |
+ expect(assigns(:exporter).options[:source_url]).to be_falsey |
|
56 |
+ expect(response.headers['Content-Disposition']).to eq('attachment; filename="bob-s-weather-alert-scenario.json"') |
|
57 |
+ expect(response.headers['Content-Type']).to eq('application/json; charset=utf-8') |
|
58 |
+ expect(JSON.parse(response.body)["name"]).to eq(scenarios(:bob_weather).name) |
|
59 | 59 |
end |
60 | 60 |
|
61 | 61 |
it "only exports private Scenarios for the current user" do |
62 | 62 |
get :export, :id => scenarios(:bob_weather).to_param |
63 |
- assigns(:scenario).should eq(scenarios(:bob_weather)) |
|
63 |
+ expect(assigns(:scenario)).to eq(scenarios(:bob_weather)) |
|
64 | 64 |
|
65 |
- lambda { |
|
65 |
+ expect { |
|
66 | 66 |
get :export, :id => scenarios(:jane_weather).to_param |
67 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
67 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
68 | 68 |
end |
69 | 69 |
|
70 | 70 |
describe "public exports" do |
@@ -74,15 +74,15 @@ describe ScenariosController do |
||
74 | 74 |
|
75 | 75 |
it "exports public scenarios for other users when logged in" do |
76 | 76 |
get :export, :id => scenarios(:jane_weather).to_param |
77 |
- assigns(:scenario).should eq(scenarios(:jane_weather)) |
|
78 |
- assigns(:exporter).options[:source_url].should == export_scenario_url(scenarios(:jane_weather)) |
|
77 |
+ expect(assigns(:scenario)).to eq(scenarios(:jane_weather)) |
|
78 |
+ expect(assigns(:exporter).options[:source_url]).to eq(export_scenario_url(scenarios(:jane_weather))) |
|
79 | 79 |
end |
80 | 80 |
|
81 | 81 |
it "exports public scenarios for other users when logged out" do |
82 | 82 |
sign_out :user |
83 | 83 |
get :export, :id => scenarios(:jane_weather).to_param |
84 |
- assigns(:scenario).should eq(scenarios(:jane_weather)) |
|
85 |
- assigns(:exporter).options[:source_url].should == export_scenario_url(scenarios(:jane_weather)) |
|
84 |
+ expect(assigns(:scenario)).to eq(scenarios(:jane_weather)) |
|
85 |
+ expect(assigns(:exporter).options[:source_url]).to eq(export_scenario_url(scenarios(:jane_weather))) |
|
86 | 86 |
end |
87 | 87 |
end |
88 | 88 |
end |
@@ -90,11 +90,11 @@ describe ScenariosController do |
||
90 | 90 |
describe "GET edit" do |
91 | 91 |
it "only shows Scenarios for the current user" do |
92 | 92 |
get :edit, :id => scenarios(:bob_weather).to_param |
93 |
- assigns(:scenario).should eq(scenarios(:bob_weather)) |
|
93 |
+ expect(assigns(:scenario)).to eq(scenarios(:bob_weather)) |
|
94 | 94 |
|
95 |
- lambda { |
|
95 |
+ expect { |
|
96 | 96 |
get :edit, :id => scenarios(:jane_weather).to_param |
97 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
97 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
98 | 98 |
end |
99 | 99 |
end |
100 | 100 |
|
@@ -109,8 +109,8 @@ describe ScenariosController do |
||
109 | 109 |
expect { |
110 | 110 |
post :create, :scenario => valid_attributes(:name => "") |
111 | 111 |
}.not_to change { users(:bob).scenarios.count } |
112 |
- assigns(:scenario).should have(1).errors_on(:name) |
|
113 |
- response.should render_template("new") |
|
112 |
+ expect(assigns(:scenario)).to have(1).errors_on(:name) |
|
113 |
+ expect(response).to render_template("new") |
|
114 | 114 |
end |
115 | 115 |
|
116 | 116 |
it "will not create Scenarios for other users" do |
@@ -123,20 +123,20 @@ describe ScenariosController do |
||
123 | 123 |
describe "PUT update" do |
124 | 124 |
it "updates attributes on Scenarios for the current user" do |
125 | 125 |
post :update, :id => scenarios(:bob_weather).to_param, :scenario => { :name => "new_name", :public => "1" } |
126 |
- response.should redirect_to(scenario_path(scenarios(:bob_weather))) |
|
127 |
- scenarios(:bob_weather).reload.name.should == "new_name" |
|
128 |
- scenarios(:bob_weather).should be_public |
|
126 |
+ expect(response).to redirect_to(scenario_path(scenarios(:bob_weather))) |
|
127 |
+ expect(scenarios(:bob_weather).reload.name).to eq("new_name") |
|
128 |
+ expect(scenarios(:bob_weather)).to be_public |
|
129 | 129 |
|
130 |
- lambda { |
|
130 |
+ expect { |
|
131 | 131 |
post :update, :id => scenarios(:jane_weather).to_param, :scenario => { :name => "new_name" } |
132 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
133 |
- scenarios(:jane_weather).reload.name.should_not == "new_name" |
|
132 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
133 |
+ expect(scenarios(:jane_weather).reload.name).not_to eq("new_name") |
|
134 | 134 |
end |
135 | 135 |
|
136 | 136 |
it "shows errors" do |
137 | 137 |
post :update, :id => scenarios(:bob_weather).to_param, :scenario => { :name => "" } |
138 |
- assigns(:scenario).should have(1).errors_on(:name) |
|
139 |
- response.should render_template("edit") |
|
138 |
+ expect(assigns(:scenario)).to have(1).errors_on(:name) |
|
139 |
+ expect(response).to render_template("edit") |
|
140 | 140 |
end |
141 | 141 |
end |
142 | 142 |
|
@@ -146,9 +146,9 @@ describe ScenariosController do |
||
146 | 146 |
delete :destroy, :id => scenarios(:bob_weather).to_param |
147 | 147 |
}.to change(Scenario, :count).by(-1) |
148 | 148 |
|
149 |
- lambda { |
|
149 |
+ expect { |
|
150 | 150 |
delete :destroy, :id => scenarios(:jane_weather).to_param |
151 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
151 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
152 | 152 |
end |
153 | 153 |
end |
154 | 154 |
end |
@@ -10,21 +10,21 @@ describe ServicesController do |
||
10 | 10 |
describe "GET index" do |
11 | 11 |
it "only returns sevices of the current user" do |
12 | 12 |
get :index |
13 |
- assigns(:services).all? {|i| i.user.should == users(:bob) }.should == true |
|
13 |
+ expect(assigns(:services).all? {|i| expect(i.user).to eq(users(:bob)) }).to eq(true) |
|
14 | 14 |
end |
15 | 15 |
end |
16 | 16 |
|
17 | 17 |
describe "POST toggle_availability" do |
18 | 18 |
it "should work for service of the user" do |
19 | 19 |
post :toggle_availability, :id => services(:generic).to_param |
20 |
- assigns(:service).should eq(services(:generic)) |
|
20 |
+ expect(assigns(:service)).to eq(services(:generic)) |
|
21 | 21 |
redirect_to(services_path) |
22 | 22 |
end |
23 | 23 |
|
24 | 24 |
it "should not work for a service of another user" do |
25 |
- lambda { |
|
25 |
+ expect { |
|
26 | 26 |
post :toggle_availability, :id => services(:global).to_param |
27 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
27 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
28 | 28 |
end |
29 | 29 |
end |
30 | 30 |
|
@@ -34,9 +34,9 @@ describe ServicesController do |
||
34 | 34 |
delete :destroy, :id => services(:generic).to_param |
35 | 35 |
}.to change(Service, :count).by(-1) |
36 | 36 |
|
37 |
- lambda { |
|
37 |
+ expect { |
|
38 | 38 |
delete :destroy, :id => services(:global).to_param |
39 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
39 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
40 | 40 |
end |
41 | 41 |
end |
42 | 42 |
|
@@ -52,7 +52,7 @@ describe ServicesController do |
||
52 | 52 |
expect { |
53 | 53 |
get :callback, provider: 'unknown' |
54 | 54 |
}.to change { users(:bob).services.count }.by(1) |
55 |
- users(:bob).services.first.provider.should == 'unknown' |
|
55 |
+ expect(users(:bob).services.first.provider).to eq('unknown') |
|
56 | 56 |
end |
57 | 57 |
end |
58 | 58 |
end |
@@ -15,18 +15,18 @@ describe UserCredentialsController do |
||
15 | 15 |
describe "GET index" do |
16 | 16 |
it "only returns UserCredentials for the current user" do |
17 | 17 |
get :index |
18 |
- assigns(:user_credentials).all? {|i| i.user.should == users(:bob) }.should be_truthy |
|
18 |
+ expect(assigns(:user_credentials).all? {|i| expect(i.user).to eq(users(:bob)) }).to be_truthy |
|
19 | 19 |
end |
20 | 20 |
end |
21 | 21 |
|
22 | 22 |
describe "GET edit" do |
23 | 23 |
it "only shows UserCredentials for the current user" do |
24 | 24 |
get :edit, :id => user_credentials(:bob_aws_secret).to_param |
25 |
- assigns(:user_credential).should eq(user_credentials(:bob_aws_secret)) |
|
25 |
+ expect(assigns(:user_credential)).to eq(user_credentials(:bob_aws_secret)) |
|
26 | 26 |
|
27 |
- lambda { |
|
27 |
+ expect { |
|
28 | 28 |
get :edit, :id => user_credentials(:jane_aws_secret).to_param |
29 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
29 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
30 | 30 |
end |
31 | 31 |
end |
32 | 32 |
|
@@ -41,8 +41,8 @@ describe UserCredentialsController do |
||
41 | 41 |
expect { |
42 | 42 |
post :create, :user_credential => valid_attributes(:credential_name => "") |
43 | 43 |
}.not_to change { users(:bob).user_credentials.count } |
44 |
- assigns(:user_credential).should have(1).errors_on(:credential_name) |
|
45 |
- response.should render_template("new") |
|
44 |
+ expect(assigns(:user_credential)).to have(1).errors_on(:credential_name) |
|
45 |
+ expect(response).to render_template("new") |
|
46 | 46 |
end |
47 | 47 |
|
48 | 48 |
it "will not create UserCredentials for other users" do |
@@ -55,19 +55,19 @@ describe UserCredentialsController do |
||
55 | 55 |
describe "PUT update" do |
56 | 56 |
it "updates attributes on UserCredentials for the current user" do |
57 | 57 |
post :update, :id => user_credentials(:bob_aws_key).to_param, :user_credential => { :credential_name => "new_name" } |
58 |
- response.should redirect_to(user_credentials_path) |
|
59 |
- user_credentials(:bob_aws_key).reload.credential_name.should == "new_name" |
|
58 |
+ expect(response).to redirect_to(user_credentials_path) |
|
59 |
+ expect(user_credentials(:bob_aws_key).reload.credential_name).to eq("new_name") |
|
60 | 60 |
|
61 |
- lambda { |
|
61 |
+ expect { |
|
62 | 62 |
post :update, :id => user_credentials(:jane_aws_key).to_param, :user_credential => { :credential_name => "new_name" } |
63 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
64 |
- user_credentials(:jane_aws_key).reload.credential_name.should_not == "new_name" |
|
63 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
64 |
+ expect(user_credentials(:jane_aws_key).reload.credential_name).not_to eq("new_name") |
|
65 | 65 |
end |
66 | 66 |
|
67 | 67 |
it "shows errors" do |
68 | 68 |
post :update, :id => user_credentials(:bob_aws_key).to_param, :user_credential => { :credential_name => "" } |
69 |
- assigns(:user_credential).should have(1).errors_on(:credential_name) |
|
70 |
- response.should render_template("edit") |
|
69 |
+ expect(assigns(:user_credential)).to have(1).errors_on(:credential_name) |
|
70 |
+ expect(response).to render_template("edit") |
|
71 | 71 |
end |
72 | 72 |
end |
73 | 73 |
|
@@ -77,9 +77,9 @@ describe UserCredentialsController do |
||
77 | 77 |
delete :destroy, :id => user_credentials(:bob_aws_key).to_param |
78 | 78 |
}.to change(UserCredential, :count).by(-1) |
79 | 79 |
|
80 |
- lambda { |
|
80 |
+ expect { |
|
81 | 81 |
delete :destroy, :id => user_credentials(:jane_aws_key).to_param |
82 |
- }.should raise_error(ActiveRecord::RecordNotFound) |
|
82 |
+ }.to raise_error(ActiveRecord::RecordNotFound) |
|
83 | 83 |
end |
84 | 84 |
end |
85 | 85 |
end |
@@ -25,74 +25,74 @@ describe WebRequestsController do |
||
25 | 25 |
end |
26 | 26 |
|
27 | 27 |
it "should not require login to receive a web request" do |
28 |
- @agent.last_web_request_at.should be_nil |
|
28 |
+ expect(@agent.last_web_request_at).to be_nil |
|
29 | 29 |
post :handle_request, :user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5" |
30 |
- @agent.reload.last_web_request_at.should be_within(2).of(Time.now) |
|
31 |
- response.body.should == "success" |
|
32 |
- response.should be_success |
|
30 |
+ expect(@agent.reload.last_web_request_at).to be_within(2).of(Time.now) |
|
31 |
+ expect(response.body).to eq("success") |
|
32 |
+ expect(response).to be_success |
|
33 | 33 |
end |
34 | 34 |
|
35 | 35 |
it "should call receive_web_request" do |
36 | 36 |
post :handle_request, :user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5" |
37 | 37 |
@agent.reload |
38 |
- @agent.memory[:web_request_values].should == { 'key' => "value", 'another_key' => "5" } |
|
39 |
- @agent.memory[:web_request_format].should == "text/html" |
|
40 |
- @agent.memory[:web_request_method].should == "post" |
|
41 |
- response.body.should == "success" |
|
42 |
- response.headers['Content-Type'].should == 'text/plain; charset=utf-8' |
|
43 |
- response.should be_success |
|
38 |
+ expect(@agent.memory[:web_request_values]).to eq({ 'key' => "value", 'another_key' => "5" }) |
|
39 |
+ expect(@agent.memory[:web_request_format]).to eq("text/html") |
|
40 |
+ expect(@agent.memory[:web_request_method]).to eq("post") |
|
41 |
+ expect(response.body).to eq("success") |
|
42 |
+ expect(response.headers['Content-Type']).to eq('text/plain; charset=utf-8') |
|
43 |
+ expect(response).to be_success |
|
44 | 44 |
|
45 | 45 |
post :handle_request, :user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "not_my_secret", :no => "go" |
46 |
- @agent.reload.memory[:web_request_values].should_not == { 'no' => "go" } |
|
47 |
- response.body.should == "failure" |
|
48 |
- response.should be_missing |
|
46 |
+ expect(@agent.reload.memory[:web_request_values]).not_to eq({ 'no' => "go" }) |
|
47 |
+ expect(response.body).to eq("failure") |
|
48 |
+ expect(response).to be_missing |
|
49 | 49 |
end |
50 | 50 |
|
51 | 51 |
it "should accept gets" do |
52 | 52 |
get :handle_request, :user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5" |
53 | 53 |
@agent.reload |
54 |
- @agent.memory[:web_request_values].should == { 'key' => "value", 'another_key' => "5" } |
|
55 |
- @agent.memory[:web_request_format].should == "text/html" |
|
56 |
- @agent.memory[:web_request_method].should == "get" |
|
57 |
- response.body.should == "success" |
|
58 |
- response.should be_success |
|
54 |
+ expect(@agent.memory[:web_request_values]).to eq({ 'key' => "value", 'another_key' => "5" }) |
|
55 |
+ expect(@agent.memory[:web_request_format]).to eq("text/html") |
|
56 |
+ expect(@agent.memory[:web_request_method]).to eq("get") |
|
57 |
+ expect(response.body).to eq("success") |
|
58 |
+ expect(response).to be_success |
|
59 | 59 |
end |
60 | 60 |
|
61 | 61 |
it "should pass through the received format" do |
62 | 62 |
get :handle_request, :user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5", :format => :json |
63 | 63 |
@agent.reload |
64 |
- @agent.memory[:web_request_values].should == { 'key' => "value", 'another_key' => "5" } |
|
65 |
- @agent.memory[:web_request_format].should == "application/json" |
|
66 |
- @agent.memory[:web_request_method].should == "get" |
|
64 |
+ expect(@agent.memory[:web_request_values]).to eq({ 'key' => "value", 'another_key' => "5" }) |
|
65 |
+ expect(@agent.memory[:web_request_format]).to eq("application/json") |
|
66 |
+ expect(@agent.memory[:web_request_method]).to eq("get") |
|
67 | 67 |
|
68 | 68 |
post :handle_request, :user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5", :format => :xml |
69 | 69 |
@agent.reload |
70 |
- @agent.memory[:web_request_values].should == { 'key' => "value", 'another_key' => "5" } |
|
71 |
- @agent.memory[:web_request_format].should == "application/xml" |
|
72 |
- @agent.memory[:web_request_method].should == "post" |
|
70 |
+ expect(@agent.memory[:web_request_values]).to eq({ 'key' => "value", 'another_key' => "5" }) |
|
71 |
+ expect(@agent.memory[:web_request_format]).to eq("application/xml") |
|
72 |
+ expect(@agent.memory[:web_request_method]).to eq("post") |
|
73 | 73 |
|
74 | 74 |
put :handle_request, :user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5", :format => :atom |
75 | 75 |
@agent.reload |
76 |
- @agent.memory[:web_request_values].should == { 'key' => "value", 'another_key' => "5" } |
|
77 |
- @agent.memory[:web_request_format].should == "application/atom+xml" |
|
78 |
- @agent.memory[:web_request_method].should == "put" |
|
76 |
+ expect(@agent.memory[:web_request_values]).to eq({ 'key' => "value", 'another_key' => "5" }) |
|
77 |
+ expect(@agent.memory[:web_request_format]).to eq("application/atom+xml") |
|
78 |
+ expect(@agent.memory[:web_request_method]).to eq("put") |
|
79 | 79 |
end |
80 | 80 |
|
81 | 81 |
it "can accept a content-type to return" do |
82 | 82 |
@agent.memory['content_type'] = 'application/json' |
83 | 83 |
@agent.save! |
84 | 84 |
get :handle_request, :user_id => users(:bob).to_param, :agent_id => @agent.id, :secret => "my_secret", :key => "value", :another_key => "5" |
85 |
- response.headers['Content-Type'].should == 'application/json; charset=utf-8' |
|
85 |
+ expect(response.headers['Content-Type']).to eq('application/json; charset=utf-8') |
|
86 | 86 |
end |
87 | 87 |
|
88 | 88 |
it "should fail on incorrect users" do |
89 | 89 |
post :handle_request, :user_id => users(:jane).to_param, :agent_id => @agent.id, :secret => "my_secret", :no => "go" |
90 |
- response.should be_missing |
|
90 |
+ expect(response).to be_missing |
|
91 | 91 |
end |
92 | 92 |
|
93 | 93 |
it "should fail on incorrect agents" do |
94 | 94 |
post :handle_request, :user_id => users(:bob).to_param, :agent_id => 454545, :secret => "my_secret", :no => "go" |
95 |
- response.should be_missing |
|
95 |
+ expect(response).to be_missing |
|
96 | 96 |
end |
97 | 97 |
|
98 | 98 |
describe "legacy update_location endpoint" do |
@@ -103,9 +103,9 @@ describe WebRequestsController do |
||
103 | 103 |
|
104 | 104 |
it "should create events without requiring login" do |
105 | 105 |
post :update_location, user_id: users(:bob).to_param, secret: "my_secret", longitude: 123, latitude: 45, something: "else" |
106 |
- @agent.events.last.payload.should == { 'longitude' => "123", 'latitude' => "45", 'something' => "else" } |
|
107 |
- @agent.events.last.lat.should == 45 |
|
108 |
- @agent.events.last.lng.should == 123 |
|
106 |
+ expect(@agent.events.last.payload).to eq({ 'longitude' => "123", 'latitude' => "45", 'something' => "else" }) |
|
107 |
+ expect(@agent.events.last.lat).to eq(45) |
|
108 |
+ expect(@agent.events.last.lng).to eq(123) |
|
109 | 109 |
end |
110 | 110 |
|
111 | 111 |
it "should only consider Agents::UserLocationAgents for the given user" do |
@@ -113,23 +113,23 @@ describe WebRequestsController do |
||
113 | 113 |
@jane_agent.save! |
114 | 114 |
|
115 | 115 |
post :update_location, user_id: users(:bob).to_param, secret: "my_secret", longitude: 123, latitude: 45, something: "else" |
116 |
- @agent.events.last.payload.should == { 'longitude' => "123", 'latitude' => "45", 'something' => "else" } |
|
117 |
- @jane_agent.events.should be_empty |
|
116 |
+ expect(@agent.events.last.payload).to eq({ 'longitude' => "123", 'latitude' => "45", 'something' => "else" }) |
|
117 |
+ expect(@jane_agent.events).to be_empty |
|
118 | 118 |
end |
119 | 119 |
|
120 | 120 |
it "should raise a 404 error when given an invalid user id" do |
121 | 121 |
post :update_location, user_id: "123", secret: "not_my_secret", longitude: 123, latitude: 45, something: "else" |
122 |
- response.should be_missing |
|
122 |
+ expect(response).to be_missing |
|
123 | 123 |
end |
124 | 124 |
|
125 | 125 |
it "should only look at agents with the given secret" do |
126 | 126 |
@agent2 = Agent.build_for_type("Agents::UserLocationAgent", users(:bob), name: "something", options: { secret: "my_secret2" }) |
127 | 127 |
@agent2.save! |
128 | 128 |
|
129 |
- lambda { |
|
129 |
+ expect { |
|
130 | 130 |
post :update_location, user_id: users(:bob).to_param, secret: "my_secret2", longitude: 123, latitude: 45, something: "else" |
131 |
- @agent2.events.last.payload.should == { 'longitude' => "123", 'latitude' => "45", 'something' => "else" } |
|
132 |
- }.should_not change { @agent.events.count } |
|
131 |
+ expect(@agent2.events.last.payload).to eq({ 'longitude' => "123", 'latitude' => "45", 'something' => "else" }) |
|
132 |
+ }.not_to change { @agent.events.count } |
|
133 | 133 |
end |
134 | 134 |
end |
135 | 135 |
end |
@@ -54,7 +54,7 @@ describe DotHelper do |
||
54 | 54 |
end |
55 | 55 |
|
56 | 56 |
it "generates a DOT script" do |
57 |
- agents_dot(@agents).should =~ %r{ |
|
57 |
+ expect(agents_dot(@agents)).to match(%r{ |
|
58 | 58 |
\A |
59 | 59 |
digraph \x20 "Agent \x20 Event \x20 Flow" \{ |
60 | 60 |
node \[ [^\]]+ \]; |
@@ -68,11 +68,11 @@ describe DotHelper do |
||
68 | 68 |
\k<bar3> \[label=bar3\]; |
69 | 69 |
\} |
70 | 70 |
\z |
71 |
- }x |
|
71 |
+ }x) |
|
72 | 72 |
end |
73 | 73 |
|
74 | 74 |
it "generates a richer DOT script" do |
75 |
- agents_dot(@agents, true).should =~ %r{ |
|
75 |
+ expect(agents_dot(@agents, true)).to match(%r{ |
|
76 | 76 |
\A |
77 | 77 |
digraph \x20 "Agent \x20 Event \x20 Flow" \{ |
78 | 78 |
node \[ [^\]]+ \]; |
@@ -86,7 +86,7 @@ describe DotHelper do |
||
86 | 86 |
\k<bar3> \[label=bar3,tooltip="Dot \x20 Bar",URL="#{Regexp.quote(agent_path(@bar3))}"\]; |
87 | 87 |
\} |
88 | 88 |
\z |
89 |
- }x |
|
89 |
+ }x) |
|
90 | 90 |
end |
91 | 91 |
end |
92 | 92 |
end |
@@ -94,9 +94,9 @@ describe DotHelper do |
||
94 | 94 |
describe "DotHelper::DotDrawer" do |
95 | 95 |
describe "#id" do |
96 | 96 |
it "properly escapes double quotaion and backslash" do |
97 |
- DotHelper::DotDrawer.draw(foo: "") { |
|
97 |
+ expect(DotHelper::DotDrawer.draw(foo: "") { |
|
98 | 98 |
id('hello\\"') |
99 |
- }.should == '"hello\\\\\\""' |
|
99 |
+ }).to eq('"hello\\\\\\""') |
|
100 | 100 |
end |
101 | 101 |
end |
102 | 102 |
end |
@@ -6,27 +6,27 @@ describe JobsHelper do |
||
6 | 6 |
describe '#status' do |
7 | 7 |
it "works for failed jobs" do |
8 | 8 |
job.failed_at = Time.now |
9 |
- status(job).should == '<span class="label label-danger">failed</span>' |
|
9 |
+ expect(status(job)).to eq('<span class="label label-danger">failed</span>') |
|
10 | 10 |
end |
11 | 11 |
|
12 | 12 |
it "works for running jobs" do |
13 | 13 |
job.locked_at = Time.now |
14 | 14 |
job.locked_by = 'test' |
15 |
- status(job).should == '<span class="label label-info">running</span>' |
|
15 |
+ expect(status(job)).to eq('<span class="label label-info">running</span>') |
|
16 | 16 |
end |
17 | 17 |
|
18 | 18 |
it "works for queued jobs" do |
19 |
- status(job).should == '<span class="label label-warning">queued</span>' |
|
19 |
+ expect(status(job)).to eq('<span class="label label-warning">queued</span>') |
|
20 | 20 |
end |
21 | 21 |
end |
22 | 22 |
|
23 | 23 |
describe '#relative_distance_of_time_in_words' do |
24 | 24 |
it "in the past" do |
25 |
- relative_distance_of_time_in_words(Time.now-5.minutes).should == '5m ago' |
|
25 |
+ expect(relative_distance_of_time_in_words(Time.now-5.minutes)).to eq('5m ago') |
|
26 | 26 |
end |
27 | 27 |
|
28 | 28 |
it "in the future" do |
29 |
- relative_distance_of_time_in_words(Time.now+5.minutes).should == 'in 5m' |
|
29 |
+ expect(relative_distance_of_time_in_words(Time.now+5.minutes)).to eq('in 5m') |
|
30 | 30 |
end |
31 | 31 |
end |
32 | 32 |
end |
@@ -5,8 +5,8 @@ describe MarkdownHelper do |
||
5 | 5 |
describe '#markdown' do |
6 | 6 |
|
7 | 7 |
it 'renders HTML from a markdown text' do |
8 |
- markdown('# Header').should =~ /<h1>Header<\/h1>/ |
|
9 |
- markdown('## Header 2').should =~ /<h2>Header 2<\/h2>/ |
|
8 |
+ expect(markdown('# Header')).to match(/<h1>Header<\/h1>/) |
|
9 |
+ expect(markdown('## Header 2')).to match(/<h2>Header 2<\/h2>/) |
|
10 | 10 |
end |
11 | 11 |
|
12 | 12 |
end |
@@ -5,25 +5,27 @@ describe ScenarioHelper do |
||
5 | 5 |
|
6 | 6 |
describe '#style_colors' do |
7 | 7 |
it 'returns a css style-formated version of the scenario foreground and background colors' do |
8 |
- style_colors(scenario).should == "color:#AAAAAA;background-color:#000000" |
|
8 |
+ expect(style_colors(scenario)).to eq("color:#AAAAAA;background-color:#000000") |
|
9 | 9 |
end |
10 | 10 |
|
11 | 11 |
it 'defauls foreground and background colors' do |
12 | 12 |
scenario.tag_fg_color = nil |
13 | 13 |
scenario.tag_bg_color = nil |
14 |
- style_colors(scenario).should == "color:#FFFFFF;background-color:#5BC0DE" |
|
14 |
+ expect(style_colors(scenario)).to eq("color:#FFFFFF;background-color:#5BC0DE") |
|
15 | 15 |
end |
16 | 16 |
end |
17 | 17 |
|
18 | 18 |
describe '#scenario_label' do |
19 | 19 |
it 'creates a scenario label with the scenario name' do |
20 |
- scenario_label(scenario).should == |
|
20 |
+ expect(scenario_label(scenario)).to eq( |
|
21 | 21 |
'<span class="label scenario" style="color:#AAAAAA;background-color:#000000">Scene</span>' |
22 |
+ ) |
|
22 | 23 |
end |
23 | 24 |
|
24 | 25 |
it 'creates a scenario label with the given text' do |
25 |
- scenario_label(scenario, 'Other').should == |
|
26 |
+ expect(scenario_label(scenario, 'Other')).to eq( |
|
26 | 27 |
'<span class="label scenario" style="color:#AAAAAA;background-color:#000000">Other</span>' |
28 |
+ ) |
|
27 | 29 |
end |
28 | 30 |
end |
29 | 31 |
|
@@ -17,51 +17,51 @@ describe AgentsExporter do |
||
17 | 17 |
|
18 | 18 |
it "outputs a structure containing name, description, the date, all agents & their links" do |
19 | 19 |
data = exporter.as_json |
20 |
- data[:name].should == name |
|
21 |
- data[:description].should == description |
|
22 |
- data[:source_url].should == source_url |
|
23 |
- data[:guid].should == guid |
|
24 |
- data[:tag_fg_color].should == tag_fg_color |
|
25 |
- data[:tag_bg_color].should == tag_bg_color |
|
26 |
- Time.parse(data[:exported_at]).should be_within(2).of(Time.now.utc) |
|
27 |
- data[:links].should == [{ :source => 0, :receiver => 1 }] |
|
28 |
- data[:agents].should == agent_list.map { |agent| exporter.agent_as_json(agent) } |
|
29 |
- data[:agents].all? { |agent_json| agent_json[:guid].present? && agent_json[:type].present? && agent_json[:name].present? }.should be_truthy |
|
20 |
+ expect(data[:name]).to eq(name) |
|
21 |
+ expect(data[:description]).to eq(description) |
|
22 |
+ expect(data[:source_url]).to eq(source_url) |
|
23 |
+ expect(data[:guid]).to eq(guid) |
|
24 |
+ expect(data[:tag_fg_color]).to eq(tag_fg_color) |
|
25 |
+ expect(data[:tag_bg_color]).to eq(tag_bg_color) |
|
26 |
+ expect(Time.parse(data[:exported_at])).to be_within(2).of(Time.now.utc) |
|
27 |
+ expect(data[:links]).to eq([{ :source => 0, :receiver => 1 }]) |
|
28 |
+ expect(data[:agents]).to eq(agent_list.map { |agent| exporter.agent_as_json(agent) }) |
|
29 |
+ expect(data[:agents].all? { |agent_json| agent_json[:guid].present? && agent_json[:type].present? && agent_json[:name].present? }).to be_truthy |
|
30 | 30 |
|
31 |
- data[:agents][0].should_not have_key(:propagate_immediately) # can't receive events |
|
32 |
- data[:agents][1].should_not have_key(:schedule) # can't be scheduled |
|
31 |
+ expect(data[:agents][0]).not_to have_key(:propagate_immediately) # can't receive events |
|
32 |
+ expect(data[:agents][1]).not_to have_key(:schedule) # can't be scheduled |
|
33 | 33 |
end |
34 | 34 |
|
35 | 35 |
it "does not output links to other agents outside of the incoming set" do |
36 | 36 |
Link.create!(:source_id => agents(:jane_weather_agent).id, :receiver_id => agents(:jane_website_agent).id) |
37 | 37 |
Link.create!(:source_id => agents(:jane_website_agent).id, :receiver_id => agents(:jane_rain_notifier_agent).id) |
38 | 38 |
|
39 |
- exporter.as_json[:links].should == [{ :source => 0, :receiver => 1 }] |
|
39 |
+ expect(exporter.as_json[:links]).to eq([{ :source => 0, :receiver => 1 }]) |
|
40 | 40 |
end |
41 | 41 |
end |
42 | 42 |
|
43 | 43 |
describe "#filename" do |
44 | 44 |
it "strips special characters" do |
45 |
- AgentsExporter.new(:name => "ƏfooƐƕƺbar").filename.should == "foo-bar.json" |
|
45 |
+ expect(AgentsExporter.new(:name => "ƏfooƐƕƺbar").filename).to eq("foo-bar.json") |
|
46 | 46 |
end |
47 | 47 |
|
48 | 48 |
it "strips punctuation" do |
49 |
- AgentsExporter.new(:name => "foo,bar").filename.should == "foo-bar.json" |
|
49 |
+ expect(AgentsExporter.new(:name => "foo,bar").filename).to eq("foo-bar.json") |
|
50 | 50 |
end |
51 | 51 |
|
52 | 52 |
it "strips leading and trailing dashes" do |
53 |
- AgentsExporter.new(:name => ",foo,").filename.should == "foo.json" |
|
53 |
+ expect(AgentsExporter.new(:name => ",foo,").filename).to eq("foo.json") |
|
54 | 54 |
end |
55 | 55 |
|
56 | 56 |
it "has a default when options[:name] is nil" do |
57 |
- AgentsExporter.new(:name => nil).filename.should == "exported-agents.json" |
|
57 |
+ expect(AgentsExporter.new(:name => nil).filename).to eq("exported-agents.json") |
|
58 | 58 |
end |
59 | 59 |
|
60 | 60 |
it "has a default when the result is empty" do |
61 |
- AgentsExporter.new(:name => "").filename.should == "exported-agents.json" |
|
62 |
- AgentsExporter.new(:name => "Ə").filename.should == "exported-agents.json" |
|
63 |
- AgentsExporter.new(:name => "-").filename.should == "exported-agents.json" |
|
64 |
- AgentsExporter.new(:name => ",,").filename.should == "exported-agents.json" |
|
61 |
+ expect(AgentsExporter.new(:name => "").filename).to eq("exported-agents.json") |
|
62 |
+ expect(AgentsExporter.new(:name => "Ə").filename).to eq("exported-agents.json") |
|
63 |
+ expect(AgentsExporter.new(:name => "-").filename).to eq("exported-agents.json") |
|
64 |
+ expect(AgentsExporter.new(:name => ",,").filename).to eq("exported-agents.json") |
|
65 | 65 |
end |
66 | 66 |
end |
67 | 67 |
end |
@@ -37,19 +37,19 @@ describe HuginnScheduler do |
||
37 | 37 |
|
38 | 38 |
describe "#hour_to_schedule_name" do |
39 | 39 |
it "for 0h" do |
40 |
- @scheduler.send(:hour_to_schedule_name, 0).should == 'midnight' |
|
40 |
+ expect(@scheduler.send(:hour_to_schedule_name, 0)).to eq('midnight') |
|
41 | 41 |
end |
42 | 42 |
|
43 | 43 |
it "for the forenoon" do |
44 |
- @scheduler.send(:hour_to_schedule_name, 6).should == '6am' |
|
44 |
+ expect(@scheduler.send(:hour_to_schedule_name, 6)).to eq('6am') |
|
45 | 45 |
end |
46 | 46 |
|
47 | 47 |
it "for 12h" do |
48 |
- @scheduler.send(:hour_to_schedule_name, 12).should == 'noon' |
|
48 |
+ expect(@scheduler.send(:hour_to_schedule_name, 12)).to eq('noon') |
|
49 | 49 |
end |
50 | 50 |
|
51 | 51 |
it "for the afternoon" do |
52 |
- @scheduler.send(:hour_to_schedule_name, 17).should == '5pm' |
|
52 |
+ expect(@scheduler.send(:hour_to_schedule_name, 17)).to eq('5pm') |
|
53 | 53 |
end |
54 | 54 |
end |
55 | 55 |
|
@@ -64,7 +64,7 @@ describe HuginnScheduler do |
||
64 | 64 |
it "work with set FAILED_JOBS_TO_KEEP env variable", focus: true do |
65 | 65 |
expect { @scheduler.send(:cleanup_failed_jobs!) }.to change(Delayed::Job, :count).by(-1) |
66 | 66 |
expect { @scheduler.send(:cleanup_failed_jobs!) }.to change(Delayed::Job, :count).by(0) |
67 |
- @keep.id.should == Delayed::Job.order(:failed_at)[0].id |
|
67 |
+ expect(@keep.id).to eq(Delayed::Job.order(:failed_at)[0].id) |
|
68 | 68 |
end |
69 | 69 |
|
70 | 70 |
|
@@ -3,16 +3,16 @@ require 'spec_helper' |
||
3 | 3 |
describe LiquidMigrator do |
4 | 4 |
describe "converting JSONPath strings" do |
5 | 5 |
it "should work" do |
6 |
- LiquidMigrator.convert_string("$.data", true).should == "{{data}}" |
|
7 |
- LiquidMigrator.convert_string("$.data.test", true).should == "{{data.test}}" |
|
8 |
- LiquidMigrator.convert_string("$first_title", true).should == "{{first_title}}" |
|
6 |
+ expect(LiquidMigrator.convert_string("$.data", true)).to eq("{{data}}") |
|
7 |
+ expect(LiquidMigrator.convert_string("$.data.test", true)).to eq("{{data.test}}") |
|
8 |
+ expect(LiquidMigrator.convert_string("$first_title", true)).to eq("{{first_title}}") |
|
9 | 9 |
end |
10 | 10 |
|
11 | 11 |
it "should ignore strings which just contain a JSONPath" do |
12 |
- LiquidMigrator.convert_string("$.data").should == "$.data" |
|
13 |
- LiquidMigrator.convert_string("$first_title").should == "$first_title" |
|
14 |
- LiquidMigrator.convert_string(" $.data", true).should == " $.data" |
|
15 |
- LiquidMigrator.convert_string("lorem $.data", true).should == "lorem $.data" |
|
12 |
+ expect(LiquidMigrator.convert_string("$.data")).to eq("$.data") |
|
13 |
+ expect(LiquidMigrator.convert_string("$first_title")).to eq("$first_title") |
|
14 |
+ expect(LiquidMigrator.convert_string(" $.data", true)).to eq(" $.data") |
|
15 |
+ expect(LiquidMigrator.convert_string("lorem $.data", true)).to eq("lorem $.data") |
|
16 | 16 |
end |
17 | 17 |
it "should raise an exception when encountering complex JSONPaths" do |
18 | 18 |
expect { LiquidMigrator.convert_string("$.data.test.*", true) }. |
@@ -22,13 +22,15 @@ describe LiquidMigrator do |
||
22 | 22 |
|
23 | 23 |
describe "converting escaped JSONPath strings" do |
24 | 24 |
it "should work" do |
25 |
- LiquidMigrator.convert_string("Weather looks like <$.conditions> according to the forecast at <$.pretty_date.time>").should == |
|
25 |
+ expect(LiquidMigrator.convert_string("Weather looks like <$.conditions> according to the forecast at <$.pretty_date.time>")).to eq( |
|
26 | 26 |
"Weather looks like {{conditions}} according to the forecast at {{pretty_date.time}}" |
27 |
+ ) |
|
27 | 28 |
end |
28 | 29 |
|
29 | 30 |
it "should convert the 'escape' method correctly" do |
30 |
- LiquidMigrator.convert_string("Escaped: <escape $.content.name>\nNot escaped: <$.content.name>").should == |
|
31 |
+ expect(LiquidMigrator.convert_string("Escaped: <escape $.content.name>\nNot escaped: <$.content.name>")).to eq( |
|
31 | 32 |
"Escaped: {{content.name | uri_escape}}\nNot escaped: {{content.name}}" |
33 |
+ ) |
|
32 | 34 |
end |
33 | 35 |
|
34 | 36 |
it "should raise an exception when encountering complex JSONPaths" do |
@@ -39,16 +41,19 @@ describe LiquidMigrator do |
||
39 | 41 |
|
40 | 42 |
describe "migrating a hash" do |
41 | 43 |
it "should convert every attribute" do |
42 |
- LiquidMigrator.convert_hash({'a' => "$.data", 'b' => "This is a <$.test>"}).should == |
|
44 |
+ expect(LiquidMigrator.convert_hash({'a' => "$.data", 'b' => "This is a <$.test>"})).to eq( |
|
43 | 45 |
{'a' => "$.data", 'b' => "This is a {{test}}"} |
46 |
+ ) |
|
44 | 47 |
end |
45 | 48 |
it "should work with leading_dollarsign_is_jsonpath" do |
46 |
- LiquidMigrator.convert_hash({'a' => "$.data", 'b' => "This is a <$.test>"}, leading_dollarsign_is_jsonpath: true).should == |
|
49 |
+ expect(LiquidMigrator.convert_hash({'a' => "$.data", 'b' => "This is a <$.test>"}, leading_dollarsign_is_jsonpath: true)).to eq( |
|
47 | 50 |
{'a' => "{{data}}", 'b' => "This is a {{test}}"} |
51 |
+ ) |
|
48 | 52 |
end |
49 | 53 |
it "should use the corresponding *_path attributes when using merge_path_attributes"do |
50 |
- LiquidMigrator.convert_hash({'a' => "default", 'a_path' => "$.data"}, {leading_dollarsign_is_jsonpath: true, merge_path_attributes: true}).should == |
|
54 |
+ expect(LiquidMigrator.convert_hash({'a' => "default", 'a_path' => "$.data"}, {leading_dollarsign_is_jsonpath: true, merge_path_attributes: true})).to eq( |
|
51 | 55 |
{'a' => "{{data}}"} |
56 |
+ ) |
|
52 | 57 |
end |
53 | 58 |
it "should raise an exception when encountering complex JSONPaths" do |
54 | 59 |
expect { LiquidMigrator.convert_hash({'b' => "This is <$.complex[2]>"}) }. |
@@ -58,9 +63,9 @@ describe LiquidMigrator do |
||
58 | 63 |
|
59 | 64 |
describe "migrating the 'make_message' format" do |
60 | 65 |
it "should work" do |
61 |
- LiquidMigrator.convert_make_message('<message>').should == '{{message}}' |
|
62 |
- LiquidMigrator.convert_make_message('<new.message>').should == '{{new.message}}' |
|
63 |
- LiquidMigrator.convert_make_message('Hello <world>. How is <nested.life>').should == 'Hello {{world}}. How is {{nested.life}}' |
|
66 |
+ expect(LiquidMigrator.convert_make_message('<message>')).to eq('{{message}}') |
|
67 |
+ expect(LiquidMigrator.convert_make_message('<new.message>')).to eq('{{new.message}}') |
|
68 |
+ expect(LiquidMigrator.convert_make_message('Hello <world>. How is <nested.life>')).to eq('Hello {{world}}. How is {{nested.life}}') |
|
64 | 69 |
end |
65 | 70 |
end |
66 | 71 |
|
@@ -87,19 +92,19 @@ describe LiquidMigrator do |
||
87 | 92 |
|
88 | 93 |
it "should work" do |
89 | 94 |
LiquidMigrator.convert_all_agent_options(@agent) |
90 |
- @agent.reload.options.should == {"auth_token" => 'token', 'color' => 'yellow', 'notify' => false, 'room_name' => 'test', 'username' => '{{username}}', 'message' => '{{message}}'} |
|
95 |
+ expect(@agent.reload.options).to eq({"auth_token" => 'token', 'color' => 'yellow', 'notify' => false, 'room_name' => 'test', 'username' => '{{username}}', 'message' => '{{message}}'}) |
|
91 | 96 |
end |
92 | 97 |
|
93 | 98 |
it "should work with nested hashes" do |
94 | 99 |
@agent.options['very'] = {'nested' => '$.value'} |
95 | 100 |
LiquidMigrator.convert_all_agent_options(@agent) |
96 |
- @agent.reload.options.should == {"auth_token" => 'token', 'color' => 'yellow', 'very' => {'nested' => '{{value}}'}, 'notify' => false, 'room_name' => 'test', 'username' => '{{username}}', 'message' => '{{message}}'} |
|
101 |
+ expect(@agent.reload.options).to eq({"auth_token" => 'token', 'color' => 'yellow', 'very' => {'nested' => '{{value}}'}, 'notify' => false, 'room_name' => 'test', 'username' => '{{username}}', 'message' => '{{message}}'}) |
|
97 | 102 |
end |
98 | 103 |
|
99 | 104 |
it "should work with nested arrays" do |
100 | 105 |
@agent.options['array'] = ["one", "$.two"] |
101 | 106 |
LiquidMigrator.convert_all_agent_options(@agent) |
102 |
- @agent.reload.options.should == {"auth_token" => 'token', 'color' => 'yellow', 'array' => ['one', '{{two}}'], 'notify' => false, 'room_name' => 'test', 'username' => '{{username}}', 'message' => '{{message}}'} |
|
107 |
+ expect(@agent.reload.options).to eq({"auth_token" => 'token', 'color' => 'yellow', 'array' => ['one', '{{two}}'], 'notify' => false, 'room_name' => 'test', 'username' => '{{username}}', 'message' => '{{message}}'}) |
|
103 | 108 |
end |
104 | 109 |
|
105 | 110 |
it "should raise an exception when encountering complex JSONPaths" do |
@@ -150,7 +155,7 @@ describe LiquidMigrator do |
||
150 | 155 |
@agent = Agents::HumanTaskAgent.new(:name => "somename", :options => valid_params) |
151 | 156 |
@agent.user = users(:jane) |
152 | 157 |
LiquidMigrator.convert_all_agent_options(@agent) |
153 |
- @agent.reload.options['hit']['description'].should == "Please rate the sentiment of this message: '{{message}}'" |
|
158 |
+ expect(@agent.reload.options['hit']['description']).to eq("Please rate the sentiment of this message: '{{message}}'") |
|
154 | 159 |
end |
155 | 160 |
end |
156 | 161 |
end |
@@ -3,27 +3,27 @@ require 'spec_helper' |
||
3 | 3 |
describe Utils do |
4 | 4 |
describe "#unindent" do |
5 | 5 |
it "unindents to the level of the greatest consistant indention" do |
6 |
- Utils.unindent(<<-MD).should == "Hello World" |
|
6 |
+ expect(Utils.unindent(<<-MD)).to eq("Hello World") |
|
7 | 7 |
Hello World |
8 | 8 |
MD |
9 | 9 |
|
10 |
- Utils.unindent(<<-MD).should == "Hello World\nThis is\nnot indented" |
|
10 |
+ expect(Utils.unindent(<<-MD)).to eq("Hello World\nThis is\nnot indented") |
|
11 | 11 |
Hello World |
12 | 12 |
This is |
13 | 13 |
not indented |
14 | 14 |
MD |
15 | 15 |
|
16 |
- Utils.unindent(<<-MD).should == "Hello World\n This is\n indented\nthough" |
|
16 |
+ expect(Utils.unindent(<<-MD)).to eq("Hello World\n This is\n indented\nthough") |
|
17 | 17 |
Hello World |
18 | 18 |
This is |
19 | 19 |
indented |
20 | 20 |
though |
21 | 21 |
MD |
22 | 22 |
|
23 |
- Utils.unindent("Hello\n I am indented").should == "Hello\n I am indented" |
|
23 |
+ expect(Utils.unindent("Hello\n I am indented")).to eq("Hello\n I am indented") |
|
24 | 24 |
|
25 | 25 |
a = " Events will have the fields you specified. Your options look like:\n\n {\n \"url\": {\n \"css\": \"#comic img\",\n \"value\": \"@src\"\n },\n \"title\": {\n \"css\": \"#comic img\",\n \"value\": \"@title\"\n }\n }\"\n" |
26 |
- Utils.unindent(a).should == "Events will have the fields you specified. Your options look like:\n\n {\n \"url\": {\n\"css\": \"#comic img\",\n\"value\": \"@src\"\n },\n \"title\": {\n\"css\": \"#comic img\",\n\"value\": \"@title\"\n }\n }\"" |
|
26 |
+ expect(Utils.unindent(a)).to eq("Events will have the fields you specified. Your options look like:\n\n {\n \"url\": {\n\"css\": \"#comic img\",\n\"value\": \"@src\"\n },\n \"title\": {\n\"css\": \"#comic img\",\n\"value\": \"@title\"\n }\n }\"") |
|
27 | 27 |
end |
28 | 28 |
end |
29 | 29 |
|
@@ -31,12 +31,12 @@ describe Utils do |
||
31 | 31 |
let(:payload) { { :there => { :world => "WORLD" }, :works => "should work" } } |
32 | 32 |
|
33 | 33 |
it "interpolates jsonpath expressions between matching <>'s" do |
34 |
- Utils.interpolate_jsonpaths("hello <$.there.world> this <escape works>", payload).should == "hello WORLD this should+work" |
|
34 |
+ expect(Utils.interpolate_jsonpaths("hello <$.there.world> this <escape works>", payload)).to eq("hello WORLD this should+work") |
|
35 | 35 |
end |
36 | 36 |
|
37 | 37 |
it "optionally supports treating values that start with '$' as raw JSONPath" do |
38 |
- Utils.interpolate_jsonpaths("$.there.world", payload).should == "$.there.world" |
|
39 |
- Utils.interpolate_jsonpaths("$.there.world", payload, :leading_dollarsign_is_jsonpath => true).should == "WORLD" |
|
38 |
+ expect(Utils.interpolate_jsonpaths("$.there.world", payload)).to eq("$.there.world") |
|
39 |
+ expect(Utils.interpolate_jsonpaths("$.there.world", payload, :leading_dollarsign_is_jsonpath => true)).to eq("WORLD") |
|
40 | 40 |
end |
41 | 41 |
end |
42 | 42 |
|
@@ -52,7 +52,7 @@ describe Utils do |
||
52 | 52 |
} |
53 | 53 |
} |
54 | 54 |
data = { :there => { :world => "WORLD" }, :works => "should work" } |
55 |
- Utils.recursively_interpolate_jsonpaths(struct, data).should == { |
|
55 |
+ expect(Utils.recursively_interpolate_jsonpaths(struct, data)).to eq({ |
|
56 | 56 |
:int => 5, |
57 | 57 |
:string => "this should+work", |
58 | 58 |
:array => ["should work", "now", "WORLD"], |
@@ -60,58 +60,58 @@ describe Utils do |
||
60 | 60 |
:string => "hello WORLD", |
61 | 61 |
:hello => :world |
62 | 62 |
} |
63 |
- } |
|
63 |
+ }) |
|
64 | 64 |
end |
65 | 65 |
end |
66 | 66 |
|
67 | 67 |
describe "#value_at" do |
68 | 68 |
it "returns the value at a JSON path" do |
69 |
- Utils.value_at({ :foo => { :bar => :baz }}.to_json, "foo.bar").should == "baz" |
|
70 |
- Utils.value_at({ :foo => { :bar => { :bing => 2 } }}, "foo.bar.bing").should == 2 |
|
69 |
+ expect(Utils.value_at({ :foo => { :bar => :baz }}.to_json, "foo.bar")).to eq("baz") |
|
70 |
+ expect(Utils.value_at({ :foo => { :bar => { :bing => 2 } }}, "foo.bar.bing")).to eq(2) |
|
71 | 71 |
end |
72 | 72 |
|
73 | 73 |
it "returns nil when the path cannot be followed" do |
74 |
- Utils.value_at({ :foo => { :bar => :baz }}, "foo.bing").should be_nil |
|
74 |
+ expect(Utils.value_at({ :foo => { :bar => :baz }}, "foo.bing")).to be_nil |
|
75 | 75 |
end |
76 | 76 |
|
77 | 77 |
it "does not eval" do |
78 |
- lambda { |
|
78 |
+ expect { |
|
79 | 79 |
Utils.value_at({ :foo => 2 }, "foo[?(@ > 1)]") |
80 |
- }.should raise_error(RuntimeError, /Cannot use .*? eval/) |
|
80 |
+ }.to raise_error(RuntimeError, /Cannot use .*? eval/) |
|
81 | 81 |
end |
82 | 82 |
end |
83 | 83 |
|
84 | 84 |
describe "#values_at" do |
85 | 85 |
it "returns arrays of matching values" do |
86 |
- Utils.values_at({ :foo => { :bar => :baz }}, "foo.bar").should == %w[baz] |
|
87 |
- Utils.values_at({ :foo => [ { :bar => :baz }, { :bar => :bing } ]}, "foo[*].bar").should == %w[baz bing] |
|
88 |
- Utils.values_at({ :foo => [ { :bar => :baz }, { :bar => :bing } ]}, "foo[*].bar").should == %w[baz bing] |
|
86 |
+ expect(Utils.values_at({ :foo => { :bar => :baz }}, "foo.bar")).to eq(%w[baz]) |
|
87 |
+ expect(Utils.values_at({ :foo => [ { :bar => :baz }, { :bar => :bing } ]}, "foo[*].bar")).to eq(%w[baz bing]) |
|
88 |
+ expect(Utils.values_at({ :foo => [ { :bar => :baz }, { :bar => :bing } ]}, "foo[*].bar")).to eq(%w[baz bing]) |
|
89 | 89 |
end |
90 | 90 |
|
91 | 91 |
it "should allow escaping" do |
92 |
- Utils.values_at({ :foo => { :bar => "escape this!?" }}, "escape $.foo.bar").should == ["escape+this%21%3F"] |
|
92 |
+ expect(Utils.values_at({ :foo => { :bar => "escape this!?" }}, "escape $.foo.bar")).to eq(["escape+this%21%3F"]) |
|
93 | 93 |
end |
94 | 94 |
end |
95 | 95 |
|
96 | 96 |
describe "#jsonify" do |
97 | 97 |
it "escapes </script> tags in the output JSON" do |
98 | 98 |
cleaned_json = Utils.jsonify(:foo => "bar", :xss => "</script><script>alert('oh no!')</script>") |
99 |
- cleaned_json.should_not include("</script>") |
|
100 |
- cleaned_json.should include('\\u003c/script\\u003e') |
|
99 |
+ expect(cleaned_json).not_to include("</script>") |
|
100 |
+ expect(cleaned_json).to include('\\u003c/script\\u003e') |
|
101 | 101 |
end |
102 | 102 |
|
103 | 103 |
it "html_safes the output unless :skip_safe is passed in" do |
104 |
- Utils.jsonify({:foo => "bar"}).should be_html_safe |
|
105 |
- Utils.jsonify({:foo => "bar"}, :skip_safe => false).should be_html_safe |
|
106 |
- Utils.jsonify({:foo => "bar"}, :skip_safe => true).should_not be_html_safe |
|
104 |
+ expect(Utils.jsonify({:foo => "bar"})).to be_html_safe |
|
105 |
+ expect(Utils.jsonify({:foo => "bar"}, :skip_safe => false)).to be_html_safe |
|
106 |
+ expect(Utils.jsonify({:foo => "bar"}, :skip_safe => true)).not_to be_html_safe |
|
107 | 107 |
end |
108 | 108 |
end |
109 | 109 |
|
110 | 110 |
describe "#pretty_jsonify" do |
111 | 111 |
it "escapes </script> tags in the output JSON" do |
112 | 112 |
cleaned_json = Utils.pretty_jsonify(:foo => "bar", :xss => "</script><script>alert('oh no!')</script>") |
113 |
- cleaned_json.should_not include("</script>") |
|
114 |
- cleaned_json.should include("<\\/script>") |
|
113 |
+ expect(cleaned_json).not_to include("</script>") |
|
114 |
+ expect(cleaned_json).to include("<\\/script>") |
|
115 | 115 |
end |
116 | 116 |
end |
117 | 117 |
end |
@@ -4,41 +4,41 @@ describe AgentLog do |
||
4 | 4 |
describe "validations" do |
5 | 5 |
before do |
6 | 6 |
@log = AgentLog.new(:agent => agents(:jane_website_agent), :message => "The agent did something", :level => 3) |
7 |
- @log.should be_valid |
|
7 |
+ expect(@log).to be_valid |
|
8 | 8 |
end |
9 | 9 |
|
10 | 10 |
it "requires an agent" do |
11 | 11 |
@log.agent = nil |
12 |
- @log.should_not be_valid |
|
13 |
- @log.should have(1).error_on(:agent) |
|
12 |
+ expect(@log).not_to be_valid |
|
13 |
+ expect(@log).to have(1).error_on(:agent) |
|
14 | 14 |
end |
15 | 15 |
|
16 | 16 |
it "requires a message" do |
17 | 17 |
@log.message = "" |
18 |
- @log.should_not be_valid |
|
18 |
+ expect(@log).not_to be_valid |
|
19 | 19 |
@log.message = nil |
20 |
- @log.should_not be_valid |
|
21 |
- @log.should have(1).error_on(:message) |
|
20 |
+ expect(@log).not_to be_valid |
|
21 |
+ expect(@log).to have(1).error_on(:message) |
|
22 | 22 |
end |
23 | 23 |
|
24 | 24 |
it "requires a valid log level" do |
25 | 25 |
@log.level = nil |
26 |
- @log.should_not be_valid |
|
27 |
- @log.should have(1).error_on(:level) |
|
26 |
+ expect(@log).not_to be_valid |
|
27 |
+ expect(@log).to have(1).error_on(:level) |
|
28 | 28 |
|
29 | 29 |
@log.level = -1 |
30 |
- @log.should_not be_valid |
|
31 |
- @log.should have(1).error_on(:level) |
|
30 |
+ expect(@log).not_to be_valid |
|
31 |
+ expect(@log).to have(1).error_on(:level) |
|
32 | 32 |
|
33 | 33 |
@log.level = 5 |
34 |
- @log.should_not be_valid |
|
35 |
- @log.should have(1).error_on(:level) |
|
34 |
+ expect(@log).not_to be_valid |
|
35 |
+ expect(@log).to have(1).error_on(:level) |
|
36 | 36 |
|
37 | 37 |
@log.level = 4 |
38 |
- @log.should be_valid |
|
38 |
+ expect(@log).to be_valid |
|
39 | 39 |
|
40 | 40 |
@log.level = 0 |
41 |
- @log.should be_valid |
|
41 |
+ expect(@log).to be_valid |
|
42 | 42 |
end |
43 | 43 |
end |
44 | 44 |
|
@@ -46,17 +46,17 @@ describe AgentLog do |
||
46 | 46 |
log = AgentLog.new(:agent => agents(:jane_website_agent), :level => 3) |
47 | 47 |
log.message = "a" * 3000 |
48 | 48 |
log.save! |
49 |
- log.message.length.should == 2048 |
|
49 |
+ expect(log.message.length).to eq(2048) |
|
50 | 50 |
end |
51 | 51 |
|
52 | 52 |
describe "#log_for_agent" do |
53 | 53 |
it "creates AgentLogs" do |
54 | 54 |
log = AgentLog.log_for_agent(agents(:jane_website_agent), "some message", :level => 4, :outbound_event => events(:jane_website_agent_event)) |
55 |
- log.should_not be_new_record |
|
56 |
- log.agent.should == agents(:jane_website_agent) |
|
57 |
- log.outbound_event.should == events(:jane_website_agent_event) |
|
58 |
- log.message.should == "some message" |
|
59 |
- log.level.should == 4 |
|
55 |
+ expect(log).not_to be_new_record |
|
56 |
+ expect(log.agent).to eq(agents(:jane_website_agent)) |
|
57 |
+ expect(log.outbound_event).to eq(events(:jane_website_agent_event)) |
|
58 |
+ expect(log.message).to eq("some message") |
|
59 |
+ expect(log.level).to eq(4) |
|
60 | 60 |
end |
61 | 61 |
|
62 | 62 |
it "cleans up old logs when there are more than log_length" do |
@@ -65,28 +65,28 @@ describe AgentLog do |
||
65 | 65 |
AgentLog.log_for_agent(agents(:jane_website_agent), "message 2") |
66 | 66 |
AgentLog.log_for_agent(agents(:jane_website_agent), "message 3") |
67 | 67 |
AgentLog.log_for_agent(agents(:jane_website_agent), "message 4") |
68 |
- agents(:jane_website_agent).logs.order("agent_logs.id desc").first.message.should == "message 4" |
|
69 |
- agents(:jane_website_agent).logs.order("agent_logs.id desc").last.message.should == "message 1" |
|
68 |
+ expect(agents(:jane_website_agent).logs.order("agent_logs.id desc").first.message).to eq("message 4") |
|
69 |
+ expect(agents(:jane_website_agent).logs.order("agent_logs.id desc").last.message).to eq("message 1") |
|
70 | 70 |
AgentLog.log_for_agent(agents(:jane_website_agent), "message 5") |
71 |
- agents(:jane_website_agent).logs.order("agent_logs.id desc").first.message.should == "message 5" |
|
72 |
- agents(:jane_website_agent).logs.order("agent_logs.id desc").last.message.should == "message 2" |
|
71 |
+ expect(agents(:jane_website_agent).logs.order("agent_logs.id desc").first.message).to eq("message 5") |
|
72 |
+ expect(agents(:jane_website_agent).logs.order("agent_logs.id desc").last.message).to eq("message 2") |
|
73 | 73 |
AgentLog.log_for_agent(agents(:jane_website_agent), "message 6") |
74 |
- agents(:jane_website_agent).logs.order("agent_logs.id desc").first.message.should == "message 6" |
|
75 |
- agents(:jane_website_agent).logs.order("agent_logs.id desc").last.message.should == "message 3" |
|
74 |
+ expect(agents(:jane_website_agent).logs.order("agent_logs.id desc").first.message).to eq("message 6") |
|
75 |
+ expect(agents(:jane_website_agent).logs.order("agent_logs.id desc").last.message).to eq("message 3") |
|
76 | 76 |
end |
77 | 77 |
|
78 | 78 |
it "updates Agents' last_error_log_at when an error is logged" do |
79 | 79 |
AgentLog.log_for_agent(agents(:jane_website_agent), "some message", :level => 3, :outbound_event => events(:jane_website_agent_event)) |
80 |
- agents(:jane_website_agent).reload.last_error_log_at.should be_nil |
|
80 |
+ expect(agents(:jane_website_agent).reload.last_error_log_at).to be_nil |
|
81 | 81 |
|
82 | 82 |
AgentLog.log_for_agent(agents(:jane_website_agent), "some message", :level => 4, :outbound_event => events(:jane_website_agent_event)) |
83 |
- agents(:jane_website_agent).reload.last_error_log_at.to_i.should be_within(2).of(Time.now.to_i) |
|
83 |
+ expect(agents(:jane_website_agent).reload.last_error_log_at.to_i).to be_within(2).of(Time.now.to_i) |
|
84 | 84 |
end |
85 | 85 |
end |
86 | 86 |
|
87 | 87 |
describe "#log_length" do |
88 | 88 |
it "defaults to 200" do |
89 |
- AgentLog.log_length.should == 200 |
|
89 |
+ expect(AgentLog.log_length).to eq(200) |
|
90 | 90 |
end |
91 | 91 |
end |
92 | 92 |
end |
@@ -22,8 +22,8 @@ describe Agent do |
||
22 | 22 |
|
23 | 23 |
describe ".run_schedule" do |
24 | 24 |
before do |
25 |
- Agents::WeatherAgent.count.should > 0 |
|
26 |
- Agents::WebsiteAgent.count.should > 0 |
|
25 |
+ expect(Agents::WeatherAgent.count).to be > 0 |
|
26 |
+ expect(Agents::WebsiteAgent.count).to be > 0 |
|
27 | 27 |
end |
28 | 28 |
|
29 | 29 |
it "runs agents with the given schedule" do |
@@ -31,7 +31,7 @@ describe Agent do |
||
31 | 31 |
stub(Agents::WeatherAgent).async_check(anything) {|agent_id| weather_agent_ids.delete(agent_id) } |
32 | 32 |
stub(Agents::WebsiteAgent).async_check(agents(:bob_website_agent).id) |
33 | 33 |
Agent.run_schedule("midnight") |
34 |
- weather_agent_ids.should be_empty |
|
34 |
+ expect(weather_agent_ids).to be_empty |
|
35 | 35 |
end |
36 | 36 |
|
37 | 37 |
it "groups agents by type" do |
@@ -54,20 +54,20 @@ describe Agent do |
||
54 | 54 |
|
55 | 55 |
describe "credential" do |
56 | 56 |
it "should return the value of the credential when credential is present" do |
57 |
- agents(:bob_weather_agent).credential("aws_secret").should == user_credentials(:bob_aws_secret).credential_value |
|
57 |
+ expect(agents(:bob_weather_agent).credential("aws_secret")).to eq(user_credentials(:bob_aws_secret).credential_value) |
|
58 | 58 |
end |
59 | 59 |
|
60 | 60 |
it "should return nil when credential is not present" do |
61 |
- agents(:bob_weather_agent).credential("non_existing_credential").should == nil |
|
61 |
+ expect(agents(:bob_weather_agent).credential("non_existing_credential")).to eq(nil) |
|
62 | 62 |
end |
63 | 63 |
|
64 | 64 |
it "should memoize the load" do |
65 | 65 |
mock.any_instance_of(UserCredential).credential_value.twice { "foo" } |
66 |
- agents(:bob_weather_agent).credential("aws_secret").should == "foo" |
|
67 |
- agents(:bob_weather_agent).credential("aws_secret").should == "foo" |
|
66 |
+ expect(agents(:bob_weather_agent).credential("aws_secret")).to eq("foo") |
|
67 |
+ expect(agents(:bob_weather_agent).credential("aws_secret")).to eq("foo") |
|
68 | 68 |
agents(:bob_weather_agent).reload |
69 |
- agents(:bob_weather_agent).credential("aws_secret").should == "foo" |
|
70 |
- agents(:bob_weather_agent).credential("aws_secret").should == "foo" |
|
69 |
+ expect(agents(:bob_weather_agent).credential("aws_secret")).to eq("foo") |
|
70 |
+ expect(agents(:bob_weather_agent).credential("aws_secret")).to eq("foo") |
|
71 | 71 |
end |
72 | 72 |
end |
73 | 73 |
|
@@ -75,21 +75,21 @@ describe Agent do |
||
75 | 75 |
it "validates types" do |
76 | 76 |
source = Agent.new |
77 | 77 |
source.type = "Agents::WeatherAgent" |
78 |
- source.should have(0).errors_on(:type) |
|
78 |
+ expect(source).to have(0).errors_on(:type) |
|
79 | 79 |
source.type = "Agents::WebsiteAgent" |
80 |
- source.should have(0).errors_on(:type) |
|
80 |
+ expect(source).to have(0).errors_on(:type) |
|
81 | 81 |
source.type = "Agents::Fake" |
82 |
- source.should have(1).error_on(:type) |
|
82 |
+ expect(source).to have(1).error_on(:type) |
|
83 | 83 |
end |
84 | 84 |
|
85 | 85 |
it "disallows changes to type once a record has been saved" do |
86 | 86 |
source = agents(:bob_website_agent) |
87 | 87 |
source.type = "Agents::WeatherAgent" |
88 |
- source.should have(1).error_on(:type) |
|
88 |
+ expect(source).to have(1).error_on(:type) |
|
89 | 89 |
end |
90 | 90 |
|
91 | 91 |
it "should know about available types" do |
92 |
- Agent.types.should include(Agents::WeatherAgent, Agents::WebsiteAgent) |
|
92 |
+ expect(Agent.types).to include(Agents::WeatherAgent, Agents::WebsiteAgent) |
|
93 | 93 |
end |
94 | 94 |
end |
95 | 95 |
|
@@ -134,44 +134,44 @@ describe Agent do |
||
134 | 134 |
|
135 | 135 |
describe ".short_type" do |
136 | 136 |
it "returns a short name without 'Agents::'" do |
137 |
- Agents::SomethingSource.new.short_type.should == "SomethingSource" |
|
138 |
- Agents::CannotBeScheduled.new.short_type.should == "CannotBeScheduled" |
|
137 |
+ expect(Agents::SomethingSource.new.short_type).to eq("SomethingSource") |
|
138 |
+ expect(Agents::CannotBeScheduled.new.short_type).to eq("CannotBeScheduled") |
|
139 | 139 |
end |
140 | 140 |
end |
141 | 141 |
|
142 | 142 |
describe ".default_schedule" do |
143 | 143 |
it "stores the default on the class" do |
144 |
- Agents::SomethingSource.default_schedule.should == "2pm" |
|
145 |
- Agents::SomethingSource.new.default_schedule.should == "2pm" |
|
144 |
+ expect(Agents::SomethingSource.default_schedule).to eq("2pm") |
|
145 |
+ expect(Agents::SomethingSource.new.default_schedule).to eq("2pm") |
|
146 | 146 |
end |
147 | 147 |
|
148 | 148 |
it "sets the default on new instances, allows setting new schedules, and prevents invalid schedules" do |
149 | 149 |
@checker = Agents::SomethingSource.new(:name => "something") |
150 | 150 |
@checker.user = users(:bob) |
151 |
- @checker.schedule.should == "2pm" |
|
151 |
+ expect(@checker.schedule).to eq("2pm") |
|
152 | 152 |
@checker.save! |
153 |
- @checker.reload.schedule.should == "2pm" |
|
153 |
+ expect(@checker.reload.schedule).to eq("2pm") |
|
154 | 154 |
@checker.update_attribute :schedule, "5pm" |
155 |
- @checker.reload.schedule.should == "5pm" |
|
155 |
+ expect(@checker.reload.schedule).to eq("5pm") |
|
156 | 156 |
|
157 |
- @checker.reload.schedule.should == "5pm" |
|
157 |
+ expect(@checker.reload.schedule).to eq("5pm") |
|
158 | 158 |
|
159 | 159 |
@checker.schedule = "this_is_not_real" |
160 |
- @checker.should have(1).errors_on(:schedule) |
|
160 |
+ expect(@checker).to have(1).errors_on(:schedule) |
|
161 | 161 |
end |
162 | 162 |
|
163 | 163 |
it "should have an empty schedule if it cannot_be_scheduled" do |
164 | 164 |
@checker = Agents::CannotBeScheduled.new(:name => "something") |
165 | 165 |
@checker.user = users(:bob) |
166 |
- @checker.schedule.should be_nil |
|
167 |
- @checker.should be_valid |
|
166 |
+ expect(@checker.schedule).to be_nil |
|
167 |
+ expect(@checker).to be_valid |
|
168 | 168 |
@checker.schedule = "5pm" |
169 | 169 |
@checker.save! |
170 |
- @checker.schedule.should be_nil |
|
170 |
+ expect(@checker.schedule).to be_nil |
|
171 | 171 |
|
172 | 172 |
@checker.schedule = "5pm" |
173 |
- @checker.should have(0).errors_on(:schedule) |
|
174 |
- @checker.schedule.should be_nil |
|
173 |
+ expect(@checker).to have(0).errors_on(:schedule) |
|
174 |
+ expect(@checker.schedule).to be_nil |
|
175 | 175 |
end |
176 | 176 |
end |
177 | 177 |
|
@@ -184,15 +184,15 @@ describe Agent do |
||
184 | 184 |
|
185 | 185 |
it "should use the checker's user" do |
186 | 186 |
@checker.check |
187 |
- Event.last.user.should == @checker.user |
|
187 |
+ expect(Event.last.user).to eq(@checker.user) |
|
188 | 188 |
end |
189 | 189 |
|
190 | 190 |
it "should log an error if the Agent has been marked with 'cannot_create_events!'" do |
191 | 191 |
mock(@checker).can_create_events? { false } |
192 |
- lambda { |
|
192 |
+ expect { |
|
193 | 193 |
@checker.check |
194 |
- }.should_not change { Event.count } |
|
195 |
- @checker.logs.first.message.should =~ /cannot create events/i |
|
194 |
+ }.not_to change { Event.count } |
|
195 |
+ expect(@checker.logs.first.message).to match(/cannot create events/i) |
|
196 | 196 |
end |
197 | 197 |
end |
198 | 198 |
|
@@ -210,10 +210,10 @@ describe Agent do |
||
210 | 210 |
|
211 | 211 |
mock(Agent).find(@checker.id) { @checker } |
212 | 212 |
|
213 |
- @checker.last_check_at.should be_nil |
|
213 |
+ expect(@checker.last_check_at).to be_nil |
|
214 | 214 |
Agents::SomethingSource.async_check(@checker.id) |
215 |
- @checker.reload.last_check_at.should be_within(2).of(Time.now) |
|
216 |
- @checker.reload.options[:new].should be_truthy # Show that we save options |
|
215 |
+ expect(@checker.reload.last_check_at).to be_within(2).of(Time.now) |
|
216 |
+ expect(@checker.reload.options[:new]).to be_truthy # Show that we save options |
|
217 | 217 |
end |
218 | 218 |
|
219 | 219 |
it "should log exceptions" do |
@@ -221,12 +221,12 @@ describe Agent do |
||
221 | 221 |
raise "foo" |
222 | 222 |
} |
223 | 223 |
mock(Agent).find(@checker.id) { @checker } |
224 |
- lambda { |
|
224 |
+ expect { |
|
225 | 225 |
Agents::SomethingSource.async_check(@checker.id) |
226 |
- }.should raise_error |
|
226 |
+ }.to raise_error |
|
227 | 227 |
log = @checker.logs.first |
228 |
- log.message.should =~ /Exception/ |
|
229 |
- log.level.should == 4 |
|
228 |
+ expect(log.message).to match(/Exception/) |
|
229 |
+ expect(log.level).to eq(4) |
|
230 | 230 |
end |
231 | 231 |
|
232 | 232 |
it "should not run disabled Agents" do |
@@ -261,24 +261,24 @@ describe Agent do |
||
261 | 261 |
raise "foo" |
262 | 262 |
} |
263 | 263 |
Agent.async_check(agents(:bob_weather_agent).id) |
264 |
- lambda { |
|
264 |
+ expect { |
|
265 | 265 |
Agent.async_receive(agents(:bob_rain_notifier_agent).id, [agents(:bob_weather_agent).events.last.id]) |
266 |
- }.should raise_error |
|
266 |
+ }.to raise_error |
|
267 | 267 |
log = agents(:bob_rain_notifier_agent).logs.first |
268 |
- log.message.should =~ /Exception/ |
|
269 |
- log.level.should == 4 |
|
268 |
+ expect(log.message).to match(/Exception/) |
|
269 |
+ expect(log.level).to eq(4) |
|
270 | 270 |
end |
271 | 271 |
|
272 | 272 |
it "should track when events have been seen and not received them again" do |
273 | 273 |
mock.any_instance_of(Agents::TriggerAgent).receive(anything).once |
274 | 274 |
Agent.async_check(agents(:bob_weather_agent).id) |
275 |
- lambda { |
|
275 |
+ expect { |
|
276 | 276 |
Agent.receive! |
277 |
- }.should change { agents(:bob_rain_notifier_agent).reload.last_checked_event_id } |
|
277 |
+ }.to change { agents(:bob_rain_notifier_agent).reload.last_checked_event_id } |
|
278 | 278 |
|
279 |
- lambda { |
|
279 |
+ expect { |
|
280 | 280 |
Agent.receive! |
281 |
- }.should_not change { agents(:bob_rain_notifier_agent).reload.last_checked_event_id } |
|
281 |
+ }.not_to change { agents(:bob_rain_notifier_agent).reload.last_checked_event_id } |
|
282 | 282 |
end |
283 | 283 |
|
284 | 284 |
it "should not run consumers that have nothing to do" do |
@@ -288,7 +288,7 @@ describe Agent do |
||
288 | 288 |
|
289 | 289 |
it "should group events" do |
290 | 290 |
mock.any_instance_of(Agents::TriggerAgent).receive(anything).twice { |events| |
291 |
- events.map(&:user).map(&:username).uniq.length.should == 1 |
|
291 |
+ expect(events.map(&:user).map(&:username).uniq.length).to eq(1) |
|
292 | 292 |
} |
293 | 293 |
Agent.async_check(agents(:bob_weather_agent).id) |
294 | 294 |
Agent.async_check(agents(:jane_weather_agent).id) |
@@ -304,9 +304,9 @@ describe Agent do |
||
304 | 304 |
mock.any_instance_of(Agents::TriggerAgent).receive(anything).twice |
305 | 305 |
agents(:bob_weather_agent).check # bob_weather_agent makes an event |
306 | 306 |
|
307 |
- lambda { |
|
307 |
+ expect { |
|
308 | 308 |
Agent.receive! # event gets propagated |
309 |
- }.should change { agents(:bob_rain_notifier_agent).reload.last_checked_event_id } |
|
309 |
+ }.to change { agents(:bob_rain_notifier_agent).reload.last_checked_event_id } |
|
310 | 310 |
|
311 | 311 |
# This agent creates a few events before we link to it, but after our last check. |
312 | 312 |
agent2.check |
@@ -314,18 +314,18 @@ describe Agent do |
||
314 | 314 |
|
315 | 315 |
# Now we link to it. |
316 | 316 |
agents(:bob_rain_notifier_agent).sources << agent2 |
317 |
- agent2.links_as_source.first.event_id_at_creation.should == agent2.events.reorder("events.id desc").first.id |
|
317 |
+ expect(agent2.links_as_source.first.event_id_at_creation).to eq(agent2.events.reorder("events.id desc").first.id) |
|
318 | 318 |
|
319 |
- lambda { |
|
319 |
+ expect { |
|
320 | 320 |
Agent.receive! # but we don't receive those events because they're too old |
321 |
- }.should_not change { agents(:bob_rain_notifier_agent).reload.last_checked_event_id } |
|
321 |
+ }.not_to change { agents(:bob_rain_notifier_agent).reload.last_checked_event_id } |
|
322 | 322 |
|
323 | 323 |
# Now a new event is created by agent2 |
324 | 324 |
agent2.check |
325 | 325 |
|
326 |
- lambda { |
|
326 |
+ expect { |
|
327 | 327 |
Agent.receive! # and we receive it |
328 |
- }.should change { agents(:bob_rain_notifier_agent).reload.last_checked_event_id } |
|
328 |
+ }.to change { agents(:bob_rain_notifier_agent).reload.last_checked_event_id } |
|
329 | 329 |
end |
330 | 330 |
end |
331 | 331 |
|
@@ -346,19 +346,19 @@ describe Agent do |
||
346 | 346 |
sender.save! |
347 | 347 |
sender.create_event :payload => {} |
348 | 348 |
sender.create_event :payload => {} |
349 |
- sender.events.count.should == 2 |
|
349 |
+ expect(sender.events.count).to eq(2) |
|
350 | 350 |
|
351 | 351 |
receiver = Agents::CannotBeScheduled.new(:name => "Receiving Agent") |
352 | 352 |
receiver.user = users(:bob) |
353 | 353 |
receiver.sources << sender |
354 | 354 |
receiver.save! |
355 | 355 |
|
356 |
- receiver.events.count.should == 0 |
|
356 |
+ expect(receiver.events.count).to eq(0) |
|
357 | 357 |
Agent.receive! |
358 |
- receiver.events.count.should == 0 |
|
358 |
+ expect(receiver.events.count).to eq(0) |
|
359 | 359 |
sender.create_event :payload => {} |
360 | 360 |
Agent.receive! |
361 |
- receiver.events.count.should == 1 |
|
361 |
+ expect(receiver.events.count).to eq(1) |
|
362 | 362 |
end |
363 | 363 |
end |
364 | 364 |
|
@@ -378,8 +378,8 @@ describe Agent do |
||
378 | 378 |
receiver.save! |
379 | 379 |
|
380 | 380 |
sender.create_event :payload => {"message" => "new payload"} |
381 |
- sender.events.count.should == 1 |
|
382 |
- receiver.events.count.should == 1 |
|
381 |
+ expect(sender.events.count).to eq(1) |
|
382 |
+ expect(receiver.events.count).to eq(1) |
|
383 | 383 |
#should be true without calling Agent.receive! |
384 | 384 |
end |
385 | 385 |
|
@@ -405,15 +405,15 @@ describe Agent do |
||
405 | 405 |
slow_receiver.save! |
406 | 406 |
|
407 | 407 |
sender.create_event :payload => {"message" => "new payload"} |
408 |
- sender.events.count.should == 1 |
|
409 |
- im_receiver.events.count.should == 1 |
|
408 |
+ expect(sender.events.count).to eq(1) |
|
409 |
+ expect(im_receiver.events.count).to eq(1) |
|
410 | 410 |
#we should get the quick one |
411 | 411 |
#but not the slow one |
412 |
- slow_receiver.events.count.should == 0 |
|
412 |
+ expect(slow_receiver.events.count).to eq(0) |
|
413 | 413 |
Agent.receive! |
414 | 414 |
#now we should have one in both |
415 |
- im_receiver.events.count.should == 1 |
|
416 |
- slow_receiver.events.count.should == 1 |
|
415 |
+ expect(im_receiver.events.count).to eq(1) |
|
416 |
+ expect(slow_receiver.events.count).to eq(1) |
|
417 | 417 |
end |
418 | 418 |
end |
419 | 419 |
|
@@ -422,18 +422,18 @@ describe Agent do |
||
422 | 422 |
agent = Agents::SomethingSource.new(:name => "something") |
423 | 423 |
agent.user = users(:bob) |
424 | 424 |
agent.options[:bad] = true |
425 |
- agent.should have(1).error_on(:base) |
|
425 |
+ expect(agent).to have(1).error_on(:base) |
|
426 | 426 |
agent.options[:bad] = false |
427 |
- agent.should have(0).errors_on(:base) |
|
427 |
+ expect(agent).to have(0).errors_on(:base) |
|
428 | 428 |
end |
429 | 429 |
|
430 | 430 |
it "makes options symbol-indifferent before validating" do |
431 | 431 |
agent = Agents::SomethingSource.new(:name => "something") |
432 | 432 |
agent.user = users(:bob) |
433 | 433 |
agent.options["bad"] = true |
434 |
- agent.should have(1).error_on(:base) |
|
434 |
+ expect(agent).to have(1).error_on(:base) |
|
435 | 435 |
agent.options["bad"] = false |
436 |
- agent.should have(0).errors_on(:base) |
|
436 |
+ expect(agent).to have(0).errors_on(:base) |
|
437 | 437 |
end |
438 | 438 |
|
439 | 439 |
it "makes memory symbol-indifferent before validating" do |
@@ -441,82 +441,82 @@ describe Agent do |
||
441 | 441 |
agent.user = users(:bob) |
442 | 442 |
agent.memory["bad"] = 2 |
443 | 443 |
agent.save |
444 |
- agent.memory[:bad].should == 2 |
|
444 |
+ expect(agent.memory[:bad]).to eq(2) |
|
445 | 445 |
end |
446 | 446 |
|
447 | 447 |
it "should work when assigned a hash or JSON string" do |
448 | 448 |
agent = Agents::SomethingSource.new(:name => "something") |
449 | 449 |
agent.memory = {} |
450 |
- agent.memory.should == {} |
|
451 |
- agent.memory["foo"].should be_nil |
|
450 |
+ expect(agent.memory).to eq({}) |
|
451 |
+ expect(agent.memory["foo"]).to be_nil |
|
452 | 452 |
|
453 | 453 |
agent.memory = "" |
454 |
- agent.memory["foo"].should be_nil |
|
455 |
- agent.memory.should == {} |
|
454 |
+ expect(agent.memory["foo"]).to be_nil |
|
455 |
+ expect(agent.memory).to eq({}) |
|
456 | 456 |
|
457 | 457 |
agent.memory = '{"hi": "there"}' |
458 |
- agent.memory.should == { "hi" => "there" } |
|
458 |
+ expect(agent.memory).to eq({ "hi" => "there" }) |
|
459 | 459 |
|
460 | 460 |
agent.memory = '{invalid}' |
461 |
- agent.memory.should == { "hi" => "there" } |
|
462 |
- agent.should have(1).errors_on(:memory) |
|
461 |
+ expect(agent.memory).to eq({ "hi" => "there" }) |
|
462 |
+ expect(agent).to have(1).errors_on(:memory) |
|
463 | 463 |
|
464 | 464 |
agent.memory = "{}" |
465 |
- agent.memory["foo"].should be_nil |
|
466 |
- agent.memory.should == {} |
|
467 |
- agent.should have(0).errors_on(:memory) |
|
465 |
+ expect(agent.memory["foo"]).to be_nil |
|
466 |
+ expect(agent.memory).to eq({}) |
|
467 |
+ expect(agent).to have(0).errors_on(:memory) |
|
468 | 468 |
|
469 | 469 |
agent.options = "{}" |
470 |
- agent.options["foo"].should be_nil |
|
471 |
- agent.options.should == {} |
|
472 |
- agent.should have(0).errors_on(:options) |
|
470 |
+ expect(agent.options["foo"]).to be_nil |
|
471 |
+ expect(agent.options).to eq({}) |
|
472 |
+ expect(agent).to have(0).errors_on(:options) |
|
473 | 473 |
|
474 | 474 |
agent.options = '{"hi": 2}' |
475 |
- agent.options["hi"].should == 2 |
|
476 |
- agent.should have(0).errors_on(:options) |
|
475 |
+ expect(agent.options["hi"]).to eq(2) |
|
476 |
+ expect(agent).to have(0).errors_on(:options) |
|
477 | 477 |
|
478 | 478 |
agent.options = '{"hi": wut}' |
479 |
- agent.options["hi"].should == 2 |
|
480 |
- agent.should have(1).errors_on(:options) |
|
481 |
- agent.errors_on(:options).should include("was assigned invalid JSON") |
|
479 |
+ expect(agent.options["hi"]).to eq(2) |
|
480 |
+ expect(agent).to have(1).errors_on(:options) |
|
481 |
+ expect(agent.errors_on(:options)).to include("was assigned invalid JSON") |
|
482 | 482 |
|
483 | 483 |
agent.options = 5 |
484 |
- agent.options["hi"].should == 2 |
|
485 |
- agent.should have(1).errors_on(:options) |
|
486 |
- agent.errors_on(:options).should include("cannot be set to an instance of Fixnum") |
|
484 |
+ expect(agent.options["hi"]).to eq(2) |
|
485 |
+ expect(agent).to have(1).errors_on(:options) |
|
486 |
+ expect(agent.errors_on(:options)).to include("cannot be set to an instance of Fixnum") |
|
487 | 487 |
end |
488 | 488 |
|
489 | 489 |
it "should not allow source agents owned by other people" do |
490 | 490 |
agent = Agents::SomethingSource.new(:name => "something") |
491 | 491 |
agent.user = users(:bob) |
492 | 492 |
agent.source_ids = [agents(:bob_weather_agent).id] |
493 |
- agent.should have(0).errors_on(:sources) |
|
493 |
+ expect(agent).to have(0).errors_on(:sources) |
|
494 | 494 |
agent.source_ids = [agents(:jane_weather_agent).id] |
495 |
- agent.should have(1).errors_on(:sources) |
|
495 |
+ expect(agent).to have(1).errors_on(:sources) |
|
496 | 496 |
agent.user = users(:jane) |
497 |
- agent.should have(0).errors_on(:sources) |
|
497 |
+ expect(agent).to have(0).errors_on(:sources) |
|
498 | 498 |
end |
499 | 499 |
|
500 | 500 |
it "should not allow controller agents owned by other people" do |
501 | 501 |
agent = Agents::SomethingSource.new(:name => "something") |
502 | 502 |
agent.user = users(:bob) |
503 | 503 |
agent.controller_ids = [agents(:bob_weather_agent).id] |
504 |
- agent.should have(0).errors_on(:controllers) |
|
504 |
+ expect(agent).to have(0).errors_on(:controllers) |
|
505 | 505 |
agent.controller_ids = [agents(:jane_weather_agent).id] |
506 |
- agent.should have(1).errors_on(:controllers) |
|
506 |
+ expect(agent).to have(1).errors_on(:controllers) |
|
507 | 507 |
agent.user = users(:jane) |
508 |
- agent.should have(0).errors_on(:controllers) |
|
508 |
+ expect(agent).to have(0).errors_on(:controllers) |
|
509 | 509 |
end |
510 | 510 |
|
511 | 511 |
it "should not allow control target agents owned by other people" do |
512 | 512 |
agent = Agents::CannotBeScheduled.new(:name => "something") |
513 | 513 |
agent.user = users(:bob) |
514 | 514 |
agent.control_target_ids = [agents(:bob_weather_agent).id] |
515 |
- agent.should have(0).errors_on(:control_targets) |
|
515 |
+ expect(agent).to have(0).errors_on(:control_targets) |
|
516 | 516 |
agent.control_target_ids = [agents(:jane_weather_agent).id] |
517 |
- agent.should have(1).errors_on(:control_targets) |
|
517 |
+ expect(agent).to have(1).errors_on(:control_targets) |
|
518 | 518 |
agent.user = users(:jane) |
519 |
- agent.should have(0).errors_on(:control_targets) |
|
519 |
+ expect(agent).to have(0).errors_on(:control_targets) |
|
520 | 520 |
end |
521 | 521 |
|
522 | 522 |
it "should not allow scenarios owned by other people" do |
@@ -524,38 +524,38 @@ describe Agent do |
||
524 | 524 |
agent.user = users(:bob) |
525 | 525 |
|
526 | 526 |
agent.scenario_ids = [scenarios(:bob_weather).id] |
527 |
- agent.should have(0).errors_on(:scenarios) |
|
527 |
+ expect(agent).to have(0).errors_on(:scenarios) |
|
528 | 528 |
|
529 | 529 |
agent.scenario_ids = [scenarios(:bob_weather).id, scenarios(:jane_weather).id] |
530 |
- agent.should have(1).errors_on(:scenarios) |
|
530 |
+ expect(agent).to have(1).errors_on(:scenarios) |
|
531 | 531 |
|
532 | 532 |
agent.scenario_ids = [scenarios(:jane_weather).id] |
533 |
- agent.should have(1).errors_on(:scenarios) |
|
533 |
+ expect(agent).to have(1).errors_on(:scenarios) |
|
534 | 534 |
|
535 | 535 |
agent.user = users(:jane) |
536 |
- agent.should have(0).errors_on(:scenarios) |
|
536 |
+ expect(agent).to have(0).errors_on(:scenarios) |
|
537 | 537 |
end |
538 | 538 |
|
539 | 539 |
it "validates keep_events_for" do |
540 | 540 |
agent = Agents::SomethingSource.new(:name => "something") |
541 | 541 |
agent.user = users(:bob) |
542 |
- agent.should be_valid |
|
542 |
+ expect(agent).to be_valid |
|
543 | 543 |
agent.keep_events_for = nil |
544 |
- agent.should have(1).errors_on(:keep_events_for) |
|
544 |
+ expect(agent).to have(1).errors_on(:keep_events_for) |
|
545 | 545 |
agent.keep_events_for = 1000 |
546 |
- agent.should have(1).errors_on(:keep_events_for) |
|
546 |
+ expect(agent).to have(1).errors_on(:keep_events_for) |
|
547 | 547 |
agent.keep_events_for = "" |
548 |
- agent.should have(1).errors_on(:keep_events_for) |
|
548 |
+ expect(agent).to have(1).errors_on(:keep_events_for) |
|
549 | 549 |
agent.keep_events_for = 5 |
550 |
- agent.should be_valid |
|
550 |
+ expect(agent).to be_valid |
|
551 | 551 |
agent.keep_events_for = 0 |
552 |
- agent.should be_valid |
|
552 |
+ expect(agent).to be_valid |
|
553 | 553 |
agent.keep_events_for = 365 |
554 |
- agent.should be_valid |
|
554 |
+ expect(agent).to be_valid |
|
555 | 555 |
|
556 | 556 |
# Rails seems to call to_i on the input. This guards against future changes to that behavior. |
557 | 557 |
agent.keep_events_for = "drop table;" |
558 |
- agent.keep_events_for.should == 0 |
|
558 |
+ expect(agent.keep_events_for).to eq(0) |
|
559 | 559 |
end |
560 | 560 |
end |
561 | 561 |
|
@@ -566,7 +566,7 @@ describe Agent do |
||
566 | 566 |
@agent.user = users(:bob) |
567 | 567 |
@agent.save! |
568 | 568 |
@event = @agent.create_event :payload => { "hello" => "world" } |
569 |
- @event.expires_at.to_i.should be_within(2).of(5.days.from_now.to_i) |
|
569 |
+ expect(@event.expires_at.to_i).to be_within(2).of(5.days.from_now.to_i) |
|
570 | 570 |
end |
571 | 571 |
|
572 | 572 |
describe "when keep_events_for has not changed" do |
@@ -584,32 +584,32 @@ describe Agent do |
||
584 | 584 |
|
585 | 585 |
describe "when keep_events_for is changed" do |
586 | 586 |
it "updates events' expires_at" do |
587 |
- lambda { |
|
587 |
+ expect { |
|
588 | 588 |
@agent.options[:foo] = "bar1" |
589 | 589 |
@agent.keep_events_for = 3 |
590 | 590 |
@agent.save! |
591 |
- }.should change { @event.reload.expires_at } |
|
592 |
- @event.expires_at.to_i.should be_within(2).of(3.days.from_now.to_i) |
|
591 |
+ }.to change { @event.reload.expires_at } |
|
592 |
+ expect(@event.expires_at.to_i).to be_within(2).of(3.days.from_now.to_i) |
|
593 | 593 |
end |
594 | 594 |
|
595 | 595 |
it "updates events relative to their created_at" do |
596 | 596 |
@event.update_attribute :created_at, 2.days.ago |
597 |
- @event.reload.created_at.to_i.should be_within(2).of(2.days.ago.to_i) |
|
597 |
+ expect(@event.reload.created_at.to_i).to be_within(2).of(2.days.ago.to_i) |
|
598 | 598 |
|
599 |
- lambda { |
|
599 |
+ expect { |
|
600 | 600 |
@agent.options[:foo] = "bar2" |
601 | 601 |
@agent.keep_events_for = 3 |
602 | 602 |
@agent.save! |
603 |
- }.should change { @event.reload.expires_at } |
|
604 |
- @event.expires_at.to_i.should be_within(60 * 61).of(1.days.from_now.to_i) # The larger time is to deal with daylight savings |
|
603 |
+ }.to change { @event.reload.expires_at } |
|
604 |
+ expect(@event.expires_at.to_i).to be_within(60 * 61).of(1.days.from_now.to_i) # The larger time is to deal with daylight savings |
|
605 | 605 |
end |
606 | 606 |
|
607 | 607 |
it "nulls out expires_at when keep_events_for is set to 0" do |
608 |
- lambda { |
|
608 |
+ expect { |
|
609 | 609 |
@agent.options[:foo] = "bar" |
610 | 610 |
@agent.keep_events_for = 0 |
611 | 611 |
@agent.save! |
612 |
- }.should change { @event.reload.expires_at }.to(nil) |
|
612 |
+ }.to change { @event.reload.expires_at }.to(nil) |
|
613 | 613 |
end |
614 | 614 |
end |
615 | 615 |
end |
@@ -625,7 +625,7 @@ describe Agent do |
||
625 | 625 |
@sender.save! |
626 | 626 |
@sender.create_event :payload => {} |
627 | 627 |
@sender.create_event :payload => {} |
628 |
- @sender.events.count.should == 2 |
|
628 |
+ expect(@sender.events.count).to eq(2) |
|
629 | 629 |
|
630 | 630 |
@receiver = Agents::CannotBeScheduled.new( |
631 | 631 |
name: 'Agent', |
@@ -641,21 +641,21 @@ describe Agent do |
||
641 | 641 |
it "should create a clone of a given agent for editing" do |
642 | 642 |
sender_clone = users(:bob).agents.build_clone(@sender) |
643 | 643 |
|
644 |
- sender_clone.attributes.should == Agent.new.attributes. |
|
644 |
+ expect(sender_clone.attributes).to eq(Agent.new.attributes. |
|
645 | 645 |
update(@sender.slice(:user_id, :type, |
646 | 646 |
:options, :schedule, :keep_events_for, :propagate_immediately)). |
647 |
- update('name' => 'Agent (2) (2)', 'options' => { 'foo' => 'bar2' }) |
|
647 |
+ update('name' => 'Agent (2) (2)', 'options' => { 'foo' => 'bar2' })) |
|
648 | 648 |
|
649 |
- sender_clone.source_ids.should == [] |
|
649 |
+ expect(sender_clone.source_ids).to eq([]) |
|
650 | 650 |
|
651 | 651 |
receiver_clone = users(:bob).agents.build_clone(@receiver) |
652 | 652 |
|
653 |
- receiver_clone.attributes.should == Agent.new.attributes. |
|
653 |
+ expect(receiver_clone.attributes).to eq(Agent.new.attributes. |
|
654 | 654 |
update(@receiver.slice(:user_id, :type, |
655 | 655 |
:options, :schedule, :keep_events_for, :propagate_immediately)). |
656 |
- update('name' => 'Agent (3)', 'options' => { 'foo' => 'bar3' }) |
|
656 |
+ update('name' => 'Agent (3)', 'options' => { 'foo' => 'bar3' })) |
|
657 | 657 |
|
658 |
- receiver_clone.source_ids.should == [@sender.id] |
|
658 |
+ expect(receiver_clone.source_ids).to eq([@sender.id]) |
|
659 | 659 |
end |
660 | 660 |
end |
661 | 661 |
end |
@@ -683,8 +683,8 @@ describe Agent do |
||
683 | 683 |
|
684 | 684 |
it "calls the .receive_web_request hook, updates last_web_request_at, and saves" do |
685 | 685 |
@agent.trigger_web_request({ :some_param => "some_value" }, "post", "text/html") |
686 |
- @agent.reload.memory['last_request'].should == [ { "some_param" => "some_value" }, "post", "text/html" ] |
|
687 |
- @agent.last_web_request_at.to_i.should be_within(1).of(Time.now.to_i) |
|
686 |
+ expect(@agent.reload.memory['last_request']).to eq([ { "some_param" => "some_value" }, "post", "text/html" ]) |
|
687 |
+ expect(@agent.last_web_request_at.to_i).to be_within(1).of(Time.now.to_i) |
|
688 | 688 |
end |
689 | 689 |
end |
690 | 690 |
|
@@ -703,8 +703,8 @@ describe Agent do |
||
703 | 703 |
it "outputs a deprecation warning and calls .receive_webhook with the params" do |
704 | 704 |
mock(Rails.logger).warn("DEPRECATED: The .receive_webhook method is deprecated, please switch your Agent to use .receive_web_request.") |
705 | 705 |
@agent.trigger_web_request({ :some_param => "some_value" }, "post", "text/html") |
706 |
- @agent.reload.memory['last_webhook_request'].should == { "some_param" => "some_value" } |
|
707 |
- @agent.last_web_request_at.to_i.should be_within(1).of(Time.now.to_i) |
|
706 |
+ expect(@agent.reload.memory['last_webhook_request']).to eq({ "some_param" => "some_value" }) |
|
707 |
+ expect(@agent.last_web_request_at.to_i).to be_within(1).of(Time.now.to_i) |
|
708 | 708 |
end |
709 | 709 |
end |
710 | 710 |
end |
@@ -713,23 +713,23 @@ describe Agent do |
||
713 | 713 |
describe "of_type" do |
714 | 714 |
it "should accept classes" do |
715 | 715 |
agents = Agent.of_type(Agents::WebsiteAgent) |
716 |
- agents.should include(agents(:bob_website_agent)) |
|
717 |
- agents.should include(agents(:jane_website_agent)) |
|
718 |
- agents.should_not include(agents(:bob_weather_agent)) |
|
716 |
+ expect(agents).to include(agents(:bob_website_agent)) |
|
717 |
+ expect(agents).to include(agents(:jane_website_agent)) |
|
718 |
+ expect(agents).not_to include(agents(:bob_weather_agent)) |
|
719 | 719 |
end |
720 | 720 |
|
721 | 721 |
it "should accept strings" do |
722 | 722 |
agents = Agent.of_type("Agents::WebsiteAgent") |
723 |
- agents.should include(agents(:bob_website_agent)) |
|
724 |
- agents.should include(agents(:jane_website_agent)) |
|
725 |
- agents.should_not include(agents(:bob_weather_agent)) |
|
723 |
+ expect(agents).to include(agents(:bob_website_agent)) |
|
724 |
+ expect(agents).to include(agents(:jane_website_agent)) |
|
725 |
+ expect(agents).not_to include(agents(:bob_weather_agent)) |
|
726 | 726 |
end |
727 | 727 |
|
728 | 728 |
it "should accept instances of an Agent" do |
729 | 729 |
agents = Agent.of_type(agents(:bob_website_agent)) |
730 |
- agents.should include(agents(:bob_website_agent)) |
|
731 |
- agents.should include(agents(:jane_website_agent)) |
|
732 |
- agents.should_not include(agents(:bob_weather_agent)) |
|
730 |
+ expect(agents).to include(agents(:bob_website_agent)) |
|
731 |
+ expect(agents).to include(agents(:jane_website_agent)) |
|
732 |
+ expect(agents).not_to include(agents(:bob_weather_agent)) |
|
733 | 733 |
end |
734 | 734 |
end |
735 | 735 |
end |
@@ -737,23 +737,23 @@ describe Agent do |
||
737 | 737 |
describe "#create_event" do |
738 | 738 |
describe "when the agent has keep_events_for set" do |
739 | 739 |
before do |
740 |
- agents(:jane_weather_agent).keep_events_for.should > 0 |
|
740 |
+ expect(agents(:jane_weather_agent).keep_events_for).to be > 0 |
|
741 | 741 |
end |
742 | 742 |
|
743 | 743 |
it "sets expires_at on created events" do |
744 | 744 |
event = agents(:jane_weather_agent).create_event :payload => { 'hi' => 'there' } |
745 |
- event.expires_at.to_i.should be_within(5).of(agents(:jane_weather_agent).keep_events_for.days.from_now.to_i) |
|
745 |
+ expect(event.expires_at.to_i).to be_within(5).of(agents(:jane_weather_agent).keep_events_for.days.from_now.to_i) |
|
746 | 746 |
end |
747 | 747 |
end |
748 | 748 |
|
749 | 749 |
describe "when the agent does not have keep_events_for set" do |
750 | 750 |
before do |
751 |
- agents(:jane_website_agent).keep_events_for.should == 0 |
|
751 |
+ expect(agents(:jane_website_agent).keep_events_for).to eq(0) |
|
752 | 752 |
end |
753 | 753 |
|
754 | 754 |
it "does not set expires_at on created events" do |
755 | 755 |
event = agents(:jane_website_agent).create_event :payload => { 'hi' => 'there' } |
756 |
- event.expires_at.should be_nil |
|
756 |
+ expect(event.expires_at).to be_nil |
|
757 | 757 |
end |
758 | 758 |
end |
759 | 759 |
end |
@@ -764,13 +764,13 @@ describe Agent do |
||
764 | 764 |
agent.last_checked_event_id = nil |
765 | 765 |
agent.save! |
766 | 766 |
agent.update!(drop_pending_events: true) |
767 |
- agent.reload.last_checked_event_id.should == Event.maximum(:id) |
|
767 |
+ expect(agent.reload.last_checked_event_id).to eq(Event.maximum(:id)) |
|
768 | 768 |
end |
769 | 769 |
|
770 | 770 |
it "should not affect a virtual attribute drop_pending_events" do |
771 | 771 |
agent = agents(:bob_rain_notifier_agent) |
772 | 772 |
agent.update!(drop_pending_events: true) |
773 |
- agent.reload.drop_pending_events.should == false |
|
773 |
+ expect(agent.reload.drop_pending_events).to eq(false) |
|
774 | 774 |
end |
775 | 775 |
end |
776 | 776 |
|
@@ -784,30 +784,30 @@ describe Agent do |
||
784 | 784 |
agent1 = agents(:bob_weather_agent) |
785 | 785 |
agent2 = agents(:bob_rain_notifier_agent) |
786 | 786 |
|
787 |
- -> { |
|
788 |
- -> { |
|
787 |
+ expect { |
|
788 |
+ expect { |
|
789 | 789 |
Agent.async_check(agent1.id) |
790 | 790 |
Agent.receive! |
791 |
- }.should change { agent1.events.count }.by(1) |
|
792 |
- }.should change { agent2.events.count }.by(1) |
|
791 |
+ }.to change { agent1.events.count }.by(1) |
|
792 |
+ }.to change { agent2.events.count }.by(1) |
|
793 | 793 |
|
794 | 794 |
agent2.disabled = true |
795 | 795 |
agent2.save! |
796 | 796 |
|
797 |
- -> { |
|
798 |
- -> { |
|
797 |
+ expect { |
|
798 |
+ expect { |
|
799 | 799 |
Agent.async_check(agent1.id) |
800 | 800 |
Agent.receive! |
801 |
- }.should change { agent1.events.count }.by(1) |
|
802 |
- }.should_not change { agent2.events.count } |
|
801 |
+ }.to change { agent1.events.count }.by(1) |
|
802 |
+ }.not_to change { agent2.events.count } |
|
803 | 803 |
|
804 | 804 |
agent2.disabled = false |
805 | 805 |
agent2.drop_pending_events = true |
806 | 806 |
agent2.save! |
807 | 807 |
|
808 |
- -> { |
|
808 |
+ expect { |
|
809 | 809 |
Agent.receive! |
810 |
- }.should_not change { agent2.events.count } |
|
810 |
+ }.not_to change { agent2.events.count } |
|
811 | 811 |
end |
812 | 812 |
end |
813 | 813 |
end |
@@ -872,37 +872,37 @@ describe AgentDrop do |
||
872 | 872 |
end |
873 | 873 |
|
874 | 874 |
it 'should be created via Agent#to_liquid' do |
875 |
- @wsa1.to_liquid.class.should be(AgentDrop) |
|
876 |
- @wsa2.to_liquid.class.should be(AgentDrop) |
|
877 |
- @efa.to_liquid.class.should be(AgentDrop) |
|
875 |
+ expect(@wsa1.to_liquid.class).to be(AgentDrop) |
|
876 |
+ expect(@wsa2.to_liquid.class).to be(AgentDrop) |
|
877 |
+ expect(@efa.to_liquid.class).to be(AgentDrop) |
|
878 | 878 |
end |
879 | 879 |
|
880 | 880 |
it 'should have .type and .name' do |
881 | 881 |
t = '{{agent.type}}: {{agent.name}}' |
882 |
- interpolate(t, @wsa1).should eq('WebsiteAgent: XKCD') |
|
883 |
- interpolate(t, @wsa2).should eq('WebsiteAgent: Dilbert') |
|
884 |
- interpolate(t, @efa).should eq('EventFormattingAgent: Formatter') |
|
882 |
+ expect(interpolate(t, @wsa1)).to eq('WebsiteAgent: XKCD') |
|
883 |
+ expect(interpolate(t, @wsa2)).to eq('WebsiteAgent: Dilbert') |
|
884 |
+ expect(interpolate(t, @efa)).to eq('EventFormattingAgent: Formatter') |
|
885 | 885 |
end |
886 | 886 |
|
887 | 887 |
it 'should have .options' do |
888 | 888 |
t = '{{agent.options.url}}' |
889 |
- interpolate(t, @wsa1).should eq('http://xkcd.com/') |
|
890 |
- interpolate(t, @wsa2).should eq('http://dilbert.com/') |
|
891 |
- interpolate('{{agent.options.instructions.message}}', |
|
892 |
- @efa).should eq('{{agent.name}}: {{title}} {{url}}') |
|
889 |
+ expect(interpolate(t, @wsa1)).to eq('http://xkcd.com/') |
|
890 |
+ expect(interpolate(t, @wsa2)).to eq('http://dilbert.com/') |
|
891 |
+ expect(interpolate('{{agent.options.instructions.message}}', |
|
892 |
+ @efa)).to eq('{{agent.name}}: {{title}} {{url}}') |
|
893 | 893 |
end |
894 | 894 |
|
895 | 895 |
it 'should have .sources' do |
896 | 896 |
t = '{{agent.sources.size}}: {{agent.sources | map:"name" | join:", "}}' |
897 |
- interpolate(t, @wsa1).should eq('0: ') |
|
898 |
- interpolate(t, @wsa2).should eq('0: ') |
|
899 |
- interpolate(t, @efa).should eq('2: XKCD, Dilbert') |
|
897 |
+ expect(interpolate(t, @wsa1)).to eq('0: ') |
|
898 |
+ expect(interpolate(t, @wsa2)).to eq('0: ') |
|
899 |
+ expect(interpolate(t, @efa)).to eq('2: XKCD, Dilbert') |
|
900 | 900 |
end |
901 | 901 |
|
902 | 902 |
it 'should have .receivers' do |
903 | 903 |
t = '{{agent.receivers.size}}: {{agent.receivers | map:"name" | join:", "}}' |
904 |
- interpolate(t, @wsa1).should eq('1: Formatter') |
|
905 |
- interpolate(t, @wsa2).should eq('1: Formatter') |
|
906 |
- interpolate(t, @efa).should eq('0: ') |
|
904 |
+ expect(interpolate(t, @wsa1)).to eq('1: Formatter') |
|
905 |
+ expect(interpolate(t, @wsa2)).to eq('1: Formatter') |
|
906 |
+ expect(interpolate(t, @efa)).to eq('0: ') |
|
907 | 907 |
end |
908 | 908 |
end |
@@ -27,12 +27,12 @@ describe Agents::AdiosoAgent do |
||
27 | 27 |
|
28 | 28 |
describe "#working?" do |
29 | 29 |
it "checks if its generating events as scheduled" do |
30 |
- @checker.should_not be_working |
|
30 |
+ expect(@checker).not_to be_working |
|
31 | 31 |
@checker.check |
32 |
- @checker.reload.should be_working |
|
32 |
+ expect(@checker.reload).to be_working |
|
33 | 33 |
three_days_from_now = 3.days.from_now |
34 | 34 |
stub(Time).now { three_days_from_now } |
35 |
- @checker.should_not be_working |
|
35 |
+ expect(@checker).not_to be_working |
|
36 | 36 |
end |
37 | 37 |
end |
38 | 38 |
end |
@@ -17,35 +17,35 @@ describe Agents::BasecampAgent do |
||
17 | 17 |
|
18 | 18 |
describe "validating" do |
19 | 19 |
before do |
20 |
- @checker.should be_valid |
|
20 |
+ expect(@checker).to be_valid |
|
21 | 21 |
end |
22 | 22 |
|
23 | 23 |
it "should require the basecamp project_id" do |
24 | 24 |
@checker.options['project_id'] = nil |
25 |
- @checker.should_not be_valid |
|
25 |
+ expect(@checker).not_to be_valid |
|
26 | 26 |
end |
27 | 27 |
|
28 | 28 |
end |
29 | 29 |
|
30 | 30 |
describe "helpers" do |
31 | 31 |
it "should generate a correct request options hash" do |
32 |
- @checker.send(:request_options).should == {:headers => {"User-Agent" => "Huginn (https://github.com/cantino/huginn)", "Authorization" => 'Bearer "1234token"'}} |
|
32 |
+ expect(@checker.send(:request_options)).to eq({:headers => {"User-Agent" => "Huginn (https://github.com/cantino/huginn)", "Authorization" => 'Bearer "1234token"'}}) |
|
33 | 33 |
end |
34 | 34 |
|
35 | 35 |
it "should generate the currect request url" do |
36 |
- @checker.send(:request_url).should == "https://basecamp.com/12345/api/v1/projects/6789/events.json" |
|
36 |
+ expect(@checker.send(:request_url)).to eq("https://basecamp.com/12345/api/v1/projects/6789/events.json") |
|
37 | 37 |
end |
38 | 38 |
|
39 | 39 |
|
40 | 40 |
it "should not provide the since attribute on first run" do |
41 |
- @checker.send(:query_parameters).should == {} |
|
41 |
+ expect(@checker.send(:query_parameters)).to eq({}) |
|
42 | 42 |
end |
43 | 43 |
|
44 | 44 |
it "should provide the since attribute after the first run" do |
45 | 45 |
time = (Time.now-1.minute).iso8601 |
46 | 46 |
@checker.memory[:last_event] = time |
47 | 47 |
@checker.save |
48 |
- @checker.reload.send(:query_parameters).should == {:query => {:since => time}} |
|
48 |
+ expect(@checker.reload.send(:query_parameters)).to eq({:query => {:since => time}}) |
|
49 | 49 |
end |
50 | 50 |
end |
51 | 51 |
describe "#check" do |
@@ -61,10 +61,10 @@ describe Agents::BasecampAgent do |
||
61 | 61 |
|
62 | 62 |
describe "#working?" do |
63 | 63 |
it "it is working when at least one event was emited" do |
64 |
- @checker.should_not be_working |
|
64 |
+ expect(@checker).not_to be_working |
|
65 | 65 |
@checker.memory[:last_event] = '2014-04-17T10:25:31.000+02:00' |
66 | 66 |
@checker.check |
67 |
- @checker.reload.should be_working |
|
67 |
+ expect(@checker.reload).to be_working |
|
68 | 68 |
end |
69 | 69 |
end |
70 | 70 |
end |
@@ -26,17 +26,17 @@ describe Agents::ChangeDetectorAgent do |
||
26 | 26 |
|
27 | 27 |
describe "validation" do |
28 | 28 |
before do |
29 |
- @checker.should be_valid |
|
29 |
+ expect(@checker).to be_valid |
|
30 | 30 |
end |
31 | 31 |
|
32 | 32 |
it "should validate presence of property" do |
33 | 33 |
@checker.options[:property] = nil |
34 |
- @checker.should_not be_valid |
|
34 |
+ expect(@checker).not_to be_valid |
|
35 | 35 |
end |
36 | 36 |
|
37 | 37 |
it "should validate presence of property" do |
38 | 38 |
@checker.options[:expected_update_period_in_days] = nil |
39 |
- @checker.should_not be_valid |
|
39 |
+ expect(@checker).not_to be_valid |
|
40 | 40 |
end |
41 | 41 |
end |
42 | 42 |
|
@@ -49,14 +49,14 @@ describe Agents::ChangeDetectorAgent do |
||
49 | 49 |
|
50 | 50 |
it "is when event created within :expected_update_period_in_days" do |
51 | 51 |
@checker.options[:expected_update_period_in_days] = 2 |
52 |
- @checker.should be_working |
|
52 |
+ expect(@checker).to be_working |
|
53 | 53 |
end |
54 | 54 |
|
55 | 55 |
it "isnt when event created outside :expected_update_period_in_days" do |
56 | 56 |
@checker.options[:expected_update_period_in_days] = 2 |
57 | 57 |
|
58 | 58 |
time_travel_to 2.days.from_now do |
59 |
- @checker.should_not be_working |
|
59 |
+ expect(@checker).not_to be_working |
|
60 | 60 |
end |
61 | 61 |
end |
62 | 62 |
end |
@@ -71,8 +71,8 @@ describe Agents::ChangeDetectorAgent do |
||
71 | 71 |
expect { |
72 | 72 |
@checker.receive([@event]) |
73 | 73 |
}.to change(Event, :count).by(1) |
74 |
- Event.last.payload[:command].should == @event.payload[:command] |
|
75 |
- Event.last.payload[:output].should == @event.payload[:output] |
|
74 |
+ expect(Event.last.payload[:command]).to eq(@event.payload[:command]) |
|
75 |
+ expect(Event.last.payload[:output]).to eq(@event.payload[:output]) |
|
76 | 76 |
end |
77 | 77 |
|
78 | 78 |
it "creates events when new event changed" do |
@@ -15,51 +15,51 @@ describe Agents::DataOutputAgent do |
||
15 | 15 |
|
16 | 16 |
describe "#working?" do |
17 | 17 |
it "checks if events have been received within expected receive period" do |
18 |
- agent.should_not be_working |
|
18 |
+ expect(agent).not_to be_working |
|
19 | 19 |
Agents::DataOutputAgent.async_receive agent.id, [events(:bob_website_agent_event).id] |
20 |
- agent.reload.should be_working |
|
20 |
+ expect(agent.reload).to be_working |
|
21 | 21 |
two_days_from_now = 2.days.from_now |
22 | 22 |
stub(Time).now { two_days_from_now } |
23 |
- agent.reload.should_not be_working |
|
23 |
+ expect(agent.reload).not_to be_working |
|
24 | 24 |
end |
25 | 25 |
end |
26 | 26 |
|
27 | 27 |
describe "validation" do |
28 | 28 |
before do |
29 |
- agent.should be_valid |
|
29 |
+ expect(agent).to be_valid |
|
30 | 30 |
end |
31 | 31 |
|
32 | 32 |
it "should validate presence and length of secrets" do |
33 | 33 |
agent.options[:secrets] = "" |
34 |
- agent.should_not be_valid |
|
34 |
+ expect(agent).not_to be_valid |
|
35 | 35 |
agent.options[:secrets] = "foo" |
36 |
- agent.should_not be_valid |
|
36 |
+ expect(agent).not_to be_valid |
|
37 | 37 |
agent.options[:secrets] = [] |
38 |
- agent.should_not be_valid |
|
38 |
+ expect(agent).not_to be_valid |
|
39 | 39 |
agent.options[:secrets] = ["hello"] |
40 |
- agent.should be_valid |
|
40 |
+ expect(agent).to be_valid |
|
41 | 41 |
agent.options[:secrets] = ["hello", "world"] |
42 |
- agent.should be_valid |
|
42 |
+ expect(agent).to be_valid |
|
43 | 43 |
end |
44 | 44 |
|
45 | 45 |
it "should validate presence of expected_receive_period_in_days" do |
46 | 46 |
agent.options[:expected_receive_period_in_days] = "" |
47 |
- agent.should_not be_valid |
|
47 |
+ expect(agent).not_to be_valid |
|
48 | 48 |
agent.options[:expected_receive_period_in_days] = 0 |
49 |
- agent.should_not be_valid |
|
49 |
+ expect(agent).not_to be_valid |
|
50 | 50 |
agent.options[:expected_receive_period_in_days] = -1 |
51 |
- agent.should_not be_valid |
|
51 |
+ expect(agent).not_to be_valid |
|
52 | 52 |
end |
53 | 53 |
|
54 | 54 |
it "should validate presence of template and template.item" do |
55 | 55 |
agent.options[:template] = "" |
56 |
- agent.should_not be_valid |
|
56 |
+ expect(agent).not_to be_valid |
|
57 | 57 |
agent.options[:template] = {} |
58 |
- agent.should_not be_valid |
|
58 |
+ expect(agent).not_to be_valid |
|
59 | 59 |
agent.options[:template] = { 'item' => 'foo' } |
60 |
- agent.should_not be_valid |
|
60 |
+ expect(agent).not_to be_valid |
|
61 | 61 |
agent.options[:template] = { 'item' => { 'title' => 'hi' } } |
62 |
- agent.should be_valid |
|
62 |
+ expect(agent).to be_valid |
|
63 | 63 |
end |
64 | 64 |
end |
65 | 65 |
|
@@ -72,15 +72,15 @@ describe Agents::DataOutputAgent do |
||
72 | 72 |
|
73 | 73 |
it "requires a valid secret" do |
74 | 74 |
content, status, content_type = agent.receive_web_request({ 'secret' => 'fake' }, 'get', 'text/xml') |
75 |
- status.should == 401 |
|
76 |
- content.should == "Not Authorized" |
|
75 |
+ expect(status).to eq(401) |
|
76 |
+ expect(content).to eq("Not Authorized") |
|
77 | 77 |
|
78 | 78 |
content, status, content_type = agent.receive_web_request({ 'secret' => 'fake' }, 'get', 'application/json') |
79 |
- status.should == 401 |
|
80 |
- content.should == { :error => "Not Authorized" } |
|
79 |
+ expect(status).to eq(401) |
|
80 |
+ expect(content).to eq({ :error => "Not Authorized" }) |
|
81 | 81 |
|
82 | 82 |
content, status, content_type = agent.receive_web_request({ 'secret' => 'secret1' }, 'get', 'application/json') |
83 |
- status.should == 200 |
|
83 |
+ expect(status).to eq(200) |
|
84 | 84 |
end |
85 | 85 |
|
86 | 86 |
describe "returning events as RSS and JSON" do |
@@ -113,9 +113,9 @@ describe Agents::DataOutputAgent do |
||
113 | 113 |
it "can output RSS" do |
114 | 114 |
stub(agent).feed_link { "https://yoursite.com" } |
115 | 115 |
content, status, content_type = agent.receive_web_request({ 'secret' => 'secret1' }, 'get', 'text/xml') |
116 |
- status.should == 200 |
|
117 |
- content_type.should == 'text/xml' |
|
118 |
- content.gsub(/\s+/, '').should == Utils.unindent(<<-XML).gsub(/\s+/, '') |
|
116 |
+ expect(status).to eq(200) |
|
117 |
+ expect(content_type).to eq('text/xml') |
|
118 |
+ expect(content.gsub(/\s+/, '')).to eq Utils.unindent(<<-XML).gsub(/\s+/, '') |
|
119 | 119 |
<?xml version="1.0" encoding="UTF-8" ?> |
120 | 120 |
<rss version="2.0"> |
121 | 121 |
<channel> |
@@ -159,9 +159,9 @@ describe Agents::DataOutputAgent do |
||
159 | 159 |
agent.options['template']['item']['foo'] = "hi" |
160 | 160 |
|
161 | 161 |
content, status, content_type = agent.receive_web_request({ 'secret' => 'secret2' }, 'get', 'application/json') |
162 |
- status.should == 200 |
|
162 |
+ expect(status).to eq(200) |
|
163 | 163 |
|
164 |
- content.should == { |
|
164 |
+ expect(content).to eq({ |
|
165 | 165 |
'title' => 'XKCD comics as a feed', |
166 | 166 |
'description' => 'This is a feed of recent XKCD comics, generated by Huginn', |
167 | 167 |
'pubDate' => Time.now, |
@@ -191,7 +191,7 @@ describe Agents::DataOutputAgent do |
||
191 | 191 |
'foo' => 'hi' |
192 | 192 |
} |
193 | 193 |
] |
194 |
- } |
|
194 |
+ }) |
|
195 | 195 |
end |
196 | 196 |
end |
197 | 197 |
end |
@@ -19,7 +19,7 @@ describe Agents::EmailAgent do |
||
19 | 19 |
|
20 | 20 |
describe "#receive" do |
21 | 21 |
it "immediately sends any payloads it receives" do |
22 |
- ActionMailer::Base.deliveries.should == [] |
|
22 |
+ expect(ActionMailer::Base.deliveries).to eq([]) |
|
23 | 23 |
|
24 | 24 |
event1 = Event.new |
25 | 25 |
event1.agent = agents(:bob_rain_notifier_agent) |
@@ -34,11 +34,11 @@ describe Agents::EmailAgent do |
||
34 | 34 |
Agents::EmailAgent.async_receive(@checker.id, [event1.id]) |
35 | 35 |
Agents::EmailAgent.async_receive(@checker.id, [event2.id]) |
36 | 36 |
|
37 |
- ActionMailer::Base.deliveries.count.should == 2 |
|
38 |
- ActionMailer::Base.deliveries.last.to.should == ["bob@example.com"] |
|
39 |
- ActionMailer::Base.deliveries.last.subject.should == "something interesting" |
|
40 |
- get_message_part(ActionMailer::Base.deliveries.last, /plain/).strip.should == "Event\n data: Something else you should know about" |
|
41 |
- get_message_part(ActionMailer::Base.deliveries.first, /plain/).strip.should == "Event\n data: Something you should know about" |
|
37 |
+ expect(ActionMailer::Base.deliveries.count).to eq(2) |
|
38 |
+ expect(ActionMailer::Base.deliveries.last.to).to eq(["bob@example.com"]) |
|
39 |
+ expect(ActionMailer::Base.deliveries.last.subject).to eq("something interesting") |
|
40 |
+ expect(get_message_part(ActionMailer::Base.deliveries.last, /plain/).strip).to eq("Event\n data: Something else you should know about") |
|
41 |
+ expect(get_message_part(ActionMailer::Base.deliveries.first, /plain/).strip).to eq("Event\n data: Something you should know about") |
|
42 | 42 |
end |
43 | 43 |
|
44 | 44 |
it "can receive complex events and send them on" do |
@@ -53,8 +53,8 @@ describe Agents::EmailAgent do |
||
53 | 53 |
plain_email_text = get_message_part(ActionMailer::Base.deliveries.last, /plain/).strip |
54 | 54 |
html_email_text = get_message_part(ActionMailer::Base.deliveries.last, /html/).strip |
55 | 55 |
|
56 |
- plain_email_text.should =~ /avehumidity/ |
|
57 |
- html_email_text.should =~ /avehumidity/ |
|
56 |
+ expect(plain_email_text).to match(/avehumidity/) |
|
57 |
+ expect(html_email_text).to match(/avehumidity/) |
|
58 | 58 |
end |
59 | 59 |
end |
60 |
-end |
|
60 |
+end |
@@ -30,14 +30,14 @@ describe Agents::EmailDigestAgent do |
||
30 | 30 |
event2.save! |
31 | 31 |
|
32 | 32 |
Agents::EmailDigestAgent.async_receive(@checker.id, [event1.id, event2.id]) |
33 |
- @checker.reload.memory[:queue].should == [{ 'data' => "Something you should know about" }, { 'data' => "Something else you should know about" }] |
|
33 |
+ expect(@checker.reload.memory[:queue]).to eq([{ 'data' => "Something you should know about" }, { 'data' => "Something else you should know about" }]) |
|
34 | 34 |
end |
35 | 35 |
end |
36 | 36 |
|
37 | 37 |
describe "#check" do |
38 | 38 |
it "should send an email" do |
39 | 39 |
Agents::EmailDigestAgent.async_check(@checker.id) |
40 |
- ActionMailer::Base.deliveries.should == [] |
|
40 |
+ expect(ActionMailer::Base.deliveries).to eq([]) |
|
41 | 41 |
|
42 | 42 |
@checker.memory[:queue] = [{ :data => "Something you should know about" }, |
43 | 43 |
{ :title => "Foo", :url => "http://google.com", :bar => 2 }, |
@@ -47,10 +47,10 @@ describe Agents::EmailDigestAgent do |
||
47 | 47 |
@checker.save! |
48 | 48 |
|
49 | 49 |
Agents::EmailDigestAgent.async_check(@checker.id) |
50 |
- ActionMailer::Base.deliveries.last.to.should == ["bob@example.com"] |
|
51 |
- ActionMailer::Base.deliveries.last.subject.should == "something interesting" |
|
52 |
- get_message_part(ActionMailer::Base.deliveries.last, /plain/).strip.should == "Event\n data: Something you should know about\n\nFoo\n bar: 2\n url: http://google.com\n\nhi\n woah: there\n\nEvent\n test: 2" |
|
53 |
- @checker.reload.memory[:queue].should be_empty |
|
50 |
+ expect(ActionMailer::Base.deliveries.last.to).to eq(["bob@example.com"]) |
|
51 |
+ expect(ActionMailer::Base.deliveries.last.subject).to eq("something interesting") |
|
52 |
+ expect(get_message_part(ActionMailer::Base.deliveries.last, /plain/).strip).to eq("Event\n data: Something you should know about\n\nFoo\n bar: 2\n url: http://google.com\n\nhi\n woah: there\n\nEvent\n test: 2") |
|
53 |
+ expect(@checker.reload.memory[:queue]).to be_empty |
|
54 | 54 |
end |
55 | 55 |
|
56 | 56 |
it "can receive complex events and send them on" do |
@@ -61,17 +61,17 @@ describe Agents::EmailDigestAgent do |
||
61 | 61 |
Agent.async_check(agents(:bob_weather_agent).id) |
62 | 62 |
|
63 | 63 |
Agent.receive! |
64 |
- @checker.reload.memory[:queue].should_not be_empty |
|
64 |
+ expect(@checker.reload.memory[:queue]).not_to be_empty |
|
65 | 65 |
|
66 | 66 |
Agents::EmailDigestAgent.async_check(@checker.id) |
67 | 67 |
|
68 | 68 |
plain_email_text = get_message_part(ActionMailer::Base.deliveries.last, /plain/).strip |
69 | 69 |
html_email_text = get_message_part(ActionMailer::Base.deliveries.last, /html/).strip |
70 | 70 |
|
71 |
- plain_email_text.should =~ /avehumidity/ |
|
72 |
- html_email_text.should =~ /avehumidity/ |
|
71 |
+ expect(plain_email_text).to match(/avehumidity/) |
|
72 |
+ expect(html_email_text).to match(/avehumidity/) |
|
73 | 73 |
|
74 |
- @checker.reload.memory[:queue].should be_empty |
|
74 |
+ expect(@checker.reload.memory[:queue]).to be_empty |
|
75 | 75 |
end |
76 | 76 |
end |
77 | 77 |
end |
@@ -45,26 +45,26 @@ describe Agents::EventFormattingAgent do |
||
45 | 45 |
describe "#receive" do |
46 | 46 |
it "should accept clean mode" do |
47 | 47 |
@checker.receive([@event]) |
48 |
- Event.last.payload[:content].should == nil |
|
48 |
+ expect(Event.last.payload[:content]).to eq(nil) |
|
49 | 49 |
end |
50 | 50 |
|
51 | 51 |
it "should accept merge mode" do |
52 | 52 |
@checker.options[:mode] = "merge" |
53 | 53 |
@checker.receive([@event]) |
54 |
- Event.last.payload[:content].should_not == nil |
|
54 |
+ expect(Event.last.payload[:content]).not_to eq(nil) |
|
55 | 55 |
end |
56 | 56 |
|
57 | 57 |
it "should handle Liquid templating in instructions" do |
58 | 58 |
@checker.receive([@event]) |
59 |
- Event.last.payload[:message].should == "Received Some Lorem Ipsum from somevalue ." |
|
60 |
- Event.last.payload[:agent].should == "WeatherAgent" |
|
61 |
- Event.last.payload[:created_at].should == @event.created_at.to_s |
|
62 |
- Event.last.payload[:created_at_iso].should == @event.created_at.iso8601 |
|
59 |
+ expect(Event.last.payload[:message]).to eq("Received Some Lorem Ipsum from somevalue .") |
|
60 |
+ expect(Event.last.payload[:agent]).to eq("WeatherAgent") |
|
61 |
+ expect(Event.last.payload[:created_at]).to eq(@event.created_at.to_s) |
|
62 |
+ expect(Event.last.payload[:created_at_iso]).to eq(@event.created_at.iso8601) |
|
63 | 63 |
end |
64 | 64 |
|
65 | 65 |
it "should handle matchers and Liquid templating in instructions" do |
66 | 66 |
@checker.receive([@event]) |
67 |
- Event.last.payload[:subject].should == "Weather looks like someothervalue according to the forecast at 10:00 PM EST" |
|
67 |
+ expect(Event.last.payload[:subject]).to eq("Weather looks like someothervalue according to the forecast at 10:00 PM EST") |
|
68 | 68 |
end |
69 | 69 |
|
70 | 70 |
it "should allow escaping" do |
@@ -73,7 +73,7 @@ describe Agents::EventFormattingAgent do |
||
73 | 73 |
@checker.options[:instructions][:message] = "Escaped: {{content.name | uri_escape}}\nNot escaped: {{content.name}}" |
74 | 74 |
@checker.save! |
75 | 75 |
@checker.receive([@event]) |
76 |
- Event.last.payload[:message].should == "Escaped: escape+this%21%3F\nNot escaped: escape this!?" |
|
76 |
+ expect(Event.last.payload[:message]).to eq("Escaped: escape+this%21%3F\nNot escaped: escape this!?") |
|
77 | 77 |
end |
78 | 78 |
|
79 | 79 |
it "should handle multiple events" do |
@@ -97,47 +97,47 @@ describe Agents::EventFormattingAgent do |
||
97 | 97 |
:conditions => "someothervalue" |
98 | 98 |
} |
99 | 99 |
|
100 |
- lambda { |
|
100 |
+ expect { |
|
101 | 101 |
@checker.receive([event2, event1]) |
102 |
- }.should change { Event.count }.by(2) |
|
102 |
+ }.to change { Event.count }.by(2) |
|
103 | 103 |
end |
104 | 104 |
end |
105 | 105 |
|
106 | 106 |
describe "validation" do |
107 | 107 |
before do |
108 |
- @checker.should be_valid |
|
108 |
+ expect(@checker).to be_valid |
|
109 | 109 |
end |
110 | 110 |
|
111 | 111 |
it "should validate presence of instructions" do |
112 | 112 |
@checker.options[:instructions] = "" |
113 |
- @checker.should_not be_valid |
|
113 |
+ expect(@checker).not_to be_valid |
|
114 | 114 |
end |
115 | 115 |
|
116 | 116 |
it "should validate type of matchers" do |
117 | 117 |
@checker.options[:matchers] = "" |
118 |
- @checker.should_not be_valid |
|
118 |
+ expect(@checker).not_to be_valid |
|
119 | 119 |
@checker.options[:matchers] = {} |
120 |
- @checker.should_not be_valid |
|
120 |
+ expect(@checker).not_to be_valid |
|
121 | 121 |
end |
122 | 122 |
|
123 | 123 |
it "should validate the contents of matchers" do |
124 | 124 |
@checker.options[:matchers] = [ |
125 | 125 |
{} |
126 | 126 |
] |
127 |
- @checker.should_not be_valid |
|
127 |
+ expect(@checker).not_to be_valid |
|
128 | 128 |
@checker.options[:matchers] = [ |
129 | 129 |
{ :regexp => "(not closed", :path => "text" } |
130 | 130 |
] |
131 |
- @checker.should_not be_valid |
|
131 |
+ expect(@checker).not_to be_valid |
|
132 | 132 |
@checker.options[:matchers] = [ |
133 | 133 |
{ :regexp => "(closed)", :path => "text", :to => "foo" } |
134 | 134 |
] |
135 |
- @checker.should be_valid |
|
135 |
+ expect(@checker).to be_valid |
|
136 | 136 |
end |
137 | 137 |
|
138 | 138 |
it "should validate presence of mode" do |
139 | 139 |
@checker.options[:mode] = "" |
140 |
- @checker.should_not be_valid |
|
140 |
+ expect(@checker).not_to be_valid |
|
141 | 141 |
end |
142 | 142 |
end |
143 | 143 |
end |
@@ -26,28 +26,28 @@ describe Agents::FtpsiteAgent do |
||
26 | 26 |
|
27 | 27 |
it "should validate the integer fields" do |
28 | 28 |
@checker.options['expected_update_period_in_days'] = "nonsense" |
29 |
- lambda { @checker.save! }.should raise_error; |
|
29 |
+ expect { @checker.save! }.to raise_error; |
|
30 | 30 |
@checker.options = @site |
31 | 31 |
end |
32 | 32 |
|
33 | 33 |
it "should check for changes and save known entries in memory" do |
34 |
- lambda { @checker.check }.should change { Event.count }.by(3) |
|
34 |
+ expect { @checker.check }.to change { Event.count }.by(3) |
|
35 | 35 |
@checker.memory['known_entries'].tap { |known_entries| |
36 |
- known_entries.size.should == 3 |
|
37 |
- known_entries.sort_by(&:last).should == [ |
|
36 |
+ expect(known_entries.size).to eq(3) |
|
37 |
+ expect(known_entries.sort_by(&:last)).to eq([ |
|
38 | 38 |
["example-1.0.tar.gz", "2013-10-01T10:00:00Z"], |
39 | 39 |
["example-1.1.tar.gz", "2014-04-01T10:00:00Z"], |
40 | 40 |
["example latest.tar.gz", "2014-04-01T10:00:01Z"], |
41 |
- ] |
|
41 |
+ ]) |
|
42 | 42 |
} |
43 | 43 |
|
44 |
- Event.last(2).first.payload.should == { |
|
44 |
+ expect(Event.last(2).first.payload).to eq({ |
|
45 | 45 |
'url' => 'ftp://ftp.example.org/pub/releases/example-1.1.tar.gz', |
46 | 46 |
'filename' => 'example-1.1.tar.gz', |
47 | 47 |
'timestamp' => '2014-04-01T10:00:00Z', |
48 |
- } |
|
48 |
+ }) |
|
49 | 49 |
|
50 |
- lambda { @checker.check }.should_not change { Event.count } |
|
50 |
+ expect { @checker.check }.not_to change { Event.count } |
|
51 | 51 |
|
52 | 52 |
stub(@checker).each_entry.returns { |block| |
53 | 53 |
block.call("example latest.tar.gz", Time.parse("2014-04-02T10:00:01Z")) |
@@ -59,30 +59,30 @@ describe Agents::FtpsiteAgent do |
||
59 | 59 |
block.call("example-1.1.tar.gz", Time.parse("2014-04-01T10:00:00Z")) |
60 | 60 |
block.call("example-1.2.tar.gz", Time.parse("2014-04-02T10:00:00Z")) |
61 | 61 |
} |
62 |
- lambda { @checker.check }.should change { Event.count }.by(2) |
|
62 |
+ expect { @checker.check }.to change { Event.count }.by(2) |
|
63 | 63 |
@checker.memory['known_entries'].tap { |known_entries| |
64 |
- known_entries.size.should == 4 |
|
65 |
- known_entries.sort_by(&:last).should == [ |
|
64 |
+ expect(known_entries.size).to eq(4) |
|
65 |
+ expect(known_entries.sort_by(&:last)).to eq([ |
|
66 | 66 |
["example-1.0.tar.gz", "2013-10-01T00:00:00Z"], |
67 | 67 |
["example-1.1.tar.gz", "2014-04-01T10:00:00Z"], |
68 | 68 |
["example-1.2.tar.gz", "2014-04-02T10:00:00Z"], |
69 | 69 |
["example latest.tar.gz", "2014-04-02T10:00:01Z"], |
70 |
- ] |
|
70 |
+ ]) |
|
71 | 71 |
} |
72 | 72 |
|
73 |
- Event.last(2).first.payload.should == { |
|
73 |
+ expect(Event.last(2).first.payload).to eq({ |
|
74 | 74 |
'url' => 'ftp://ftp.example.org/pub/releases/example-1.2.tar.gz', |
75 | 75 |
'filename' => 'example-1.2.tar.gz', |
76 | 76 |
'timestamp' => '2014-04-02T10:00:00Z', |
77 |
- } |
|
77 |
+ }) |
|
78 | 78 |
|
79 |
- Event.last.payload.should == { |
|
79 |
+ expect(Event.last.payload).to eq({ |
|
80 | 80 |
'url' => 'ftp://ftp.example.org/pub/releases/example%20latest.tar.gz', |
81 | 81 |
'filename' => 'example latest.tar.gz', |
82 | 82 |
'timestamp' => '2014-04-02T10:00:01Z', |
83 |
- } |
|
83 |
+ }) |
|
84 | 84 |
|
85 |
- lambda { @checker.check }.should_not change { Event.count } |
|
85 |
+ expect { @checker.check }.not_to change { Event.count } |
|
86 | 86 |
end |
87 | 87 |
end |
88 | 88 |
|
@@ -99,17 +99,17 @@ describe Agents::FtpsiteAgent do |
||
99 | 99 |
entries = [] |
100 | 100 |
@checker.each_entry { |a, b| entries.push [a, b] } |
101 | 101 |
|
102 |
- entries.size.should == 1 |
|
102 |
+ expect(entries.size).to eq(1) |
|
103 | 103 |
filename, mtime = entries.first |
104 |
- filename.should == 'example latest.tar.gz' |
|
105 |
- mtime.should == '2014-04-02T10:01:00Z' |
|
104 |
+ expect(filename).to eq('example latest.tar.gz') |
|
105 |
+ expect(mtime).to eq('2014-04-02T10:01:00Z') |
|
106 | 106 |
end |
107 | 107 |
|
108 | 108 |
it "filters out files that are older than the given date" do |
109 | 109 |
@checker.options['after'] = '2015-10-21' |
110 | 110 |
entries = [] |
111 | 111 |
@checker.each_entry { |a, b| entries.push [a, b] } |
112 |
- entries.size.should == 0 |
|
112 |
+ expect(entries.size).to eq(0) |
|
113 | 113 |
end |
114 | 114 |
end |
115 | 115 |
|
@@ -37,7 +37,7 @@ describe Agents::GoogleCalendarPublishAgent, :vcr do |
||
37 | 37 |
|
38 | 38 |
@checker.receive([event1]) |
39 | 39 |
|
40 |
- @checker.events.count.should eq(1) |
|
40 |
+ expect(@checker.events.count).to eq(1) |
|
41 | 41 |
end |
42 | 42 |
end |
43 | 43 |
end |
@@ -21,35 +21,35 @@ describe Agents::GrowlAgent do |
||
21 | 21 |
|
22 | 22 |
describe "#working?" do |
23 | 23 |
it "checks if events have been received within the expected receive period" do |
24 |
- @checker.should_not be_working # No events received |
|
24 |
+ expect(@checker).not_to be_working # No events received |
|
25 | 25 |
Agents::GrowlAgent.async_receive @checker.id, [@event.id] |
26 |
- @checker.reload.should be_working # Just received events |
|
26 |
+ expect(@checker.reload).to be_working # Just received events |
|
27 | 27 |
two_days_from_now = 2.days.from_now |
28 | 28 |
stub(Time).now { two_days_from_now } |
29 |
- @checker.reload.should_not be_working # More time has passed than the expected receive period without any new events |
|
29 |
+ expect(@checker.reload).not_to be_working # More time has passed than the expected receive period without any new events |
|
30 | 30 |
end |
31 | 31 |
end |
32 | 32 |
|
33 | 33 |
describe "validation" do |
34 | 34 |
before do |
35 |
- @checker.should be_valid |
|
35 |
+ expect(@checker).to be_valid |
|
36 | 36 |
end |
37 | 37 |
|
38 | 38 |
it "should validate presence of of growl_server" do |
39 | 39 |
@checker.options[:growl_server] = "" |
40 |
- @checker.should_not be_valid |
|
40 |
+ expect(@checker).not_to be_valid |
|
41 | 41 |
end |
42 | 42 |
|
43 | 43 |
it "should validate presence of expected_receive_period_in_days" do |
44 | 44 |
@checker.options[:expected_receive_period_in_days] = "" |
45 |
- @checker.should_not be_valid |
|
45 |
+ expect(@checker).not_to be_valid |
|
46 | 46 |
end |
47 | 47 |
end |
48 | 48 |
|
49 | 49 |
describe "register_growl" do |
50 | 50 |
it "should set the password for the Growl connection from the agent options" do |
51 | 51 |
@checker.register_growl |
52 |
- @checker.growler.password.should eql(@checker.options[:growl_password]) |
|
52 |
+ expect(@checker.growler.password).to eql(@checker.options[:growl_password]) |
|
53 | 53 |
end |
54 | 54 |
|
55 | 55 |
it "should add a notification to the Growl connection" do |
@@ -60,7 +60,7 @@ describe Agents::GrowlAgent do |
||
60 | 60 |
end |
61 | 61 |
|
62 | 62 |
@checker.register_growl |
63 |
- called.should be_truthy |
|
63 |
+ expect(called).to be_truthy |
|
64 | 64 |
end |
65 | 65 |
end |
66 | 66 |
|
@@ -78,7 +78,7 @@ describe Agents::GrowlAgent do |
||
78 | 78 |
mock(obj).notify(@checker.options[:growl_notification_name],subject,message) |
79 | 79 |
end |
80 | 80 |
@checker.notify_growl(subject,message) |
81 |
- called.should be_truthy |
|
81 |
+ expect(called).to be_truthy |
|
82 | 82 |
end |
83 | 83 |
end |
84 | 84 |
|
@@ -119,4 +119,4 @@ describe Agents::GrowlAgent do |
||
119 | 119 |
@checker.receive([event_without_a_subject,event_without_a_message]) |
120 | 120 |
end |
121 | 121 |
end |
122 |
-end |
|
122 |
+end |
@@ -23,30 +23,30 @@ describe Agents::HipchatAgent do |
||
23 | 23 |
|
24 | 24 |
describe "validating" do |
25 | 25 |
before do |
26 |
- @checker.should be_valid |
|
26 |
+ expect(@checker).to be_valid |
|
27 | 27 |
end |
28 | 28 |
|
29 | 29 |
it "should require the basecamp username" do |
30 | 30 |
@checker.options['auth_token'] = nil |
31 |
- @checker.should_not be_valid |
|
31 |
+ expect(@checker).not_to be_valid |
|
32 | 32 |
end |
33 | 33 |
|
34 | 34 |
it "should require the basecamp password" do |
35 | 35 |
@checker.options['room_name'] = nil |
36 |
- @checker.should_not be_valid |
|
36 |
+ expect(@checker).not_to be_valid |
|
37 | 37 |
end |
38 | 38 |
|
39 | 39 |
it "should require the basecamp user_id" do |
40 | 40 |
@checker.options['room_name'] = nil |
41 | 41 |
@checker.options['room_name_path'] = 'jsonpath' |
42 |
- @checker.should be_valid |
|
42 |
+ expect(@checker).to be_valid |
|
43 | 43 |
end |
44 | 44 |
|
45 | 45 |
it "should also allow a credential" do |
46 | 46 |
@checker.options['auth_token'] = nil |
47 |
- @checker.should_not be_valid |
|
47 |
+ expect(@checker).not_to be_valid |
|
48 | 48 |
@checker.user.user_credentials.create :credential_name => 'hipchat_auth_token', :credential_value => 'something' |
49 |
- @checker.reload.should be_valid |
|
49 |
+ expect(@checker.reload).to be_valid |
|
50 | 50 |
end |
51 | 51 |
end |
52 | 52 |
|
@@ -61,21 +61,21 @@ describe Agents::HipchatAgent do |
||
61 | 61 |
|
62 | 62 |
describe "#working?" do |
63 | 63 |
it "should not be working until the first event was received" do |
64 |
- @checker.should_not be_working |
|
64 |
+ expect(@checker).not_to be_working |
|
65 | 65 |
@checker.last_receive_at = Time.now |
66 |
- @checker.should be_working |
|
66 |
+ expect(@checker).to be_working |
|
67 | 67 |
end |
68 | 68 |
|
69 | 69 |
it "should not be working when the last error occured after the last received event" do |
70 | 70 |
@checker.last_receive_at = Time.now - 1.minute |
71 | 71 |
@checker.last_error_log_at = Time.now |
72 |
- @checker.should_not be_working |
|
72 |
+ expect(@checker).not_to be_working |
|
73 | 73 |
end |
74 | 74 |
|
75 | 75 |
it "should be working when the last received event occured after the last error" do |
76 | 76 |
@checker.last_receive_at = Time.now |
77 | 77 |
@checker.last_error_log_at = Time.now - 1.minute |
78 |
- @checker.should be_working |
|
78 |
+ expect(@checker).to be_working |
|
79 | 79 |
end |
80 | 80 |
end |
81 | 81 |
end |
@@ -13,143 +13,143 @@ describe Agents::HumanTaskAgent do |
||
13 | 13 |
'name' => "Joe" } |
14 | 14 |
@event.id = 345 |
15 | 15 |
|
16 |
- @checker.should be_valid |
|
16 |
+ expect(@checker).to be_valid |
|
17 | 17 |
end |
18 | 18 |
|
19 | 19 |
describe "validations" do |
20 | 20 |
it "validates that trigger_on is 'schedule' or 'event'" do |
21 | 21 |
@checker.options['trigger_on'] = "foo" |
22 |
- @checker.should_not be_valid |
|
22 |
+ expect(@checker).not_to be_valid |
|
23 | 23 |
end |
24 | 24 |
|
25 | 25 |
it "requires expected_receive_period_in_days when trigger_on is set to 'event'" do |
26 | 26 |
@checker.options['trigger_on'] = "event" |
27 | 27 |
@checker.options['expected_receive_period_in_days'] = nil |
28 |
- @checker.should_not be_valid |
|
28 |
+ expect(@checker).not_to be_valid |
|
29 | 29 |
@checker.options['expected_receive_period_in_days'] = 2 |
30 |
- @checker.should be_valid |
|
30 |
+ expect(@checker).to be_valid |
|
31 | 31 |
end |
32 | 32 |
|
33 | 33 |
it "requires a positive submission_period when trigger_on is set to 'schedule'" do |
34 | 34 |
@checker.options['trigger_on'] = "schedule" |
35 | 35 |
@checker.options['submission_period'] = nil |
36 |
- @checker.should_not be_valid |
|
36 |
+ expect(@checker).not_to be_valid |
|
37 | 37 |
@checker.options['submission_period'] = 2 |
38 |
- @checker.should be_valid |
|
38 |
+ expect(@checker).to be_valid |
|
39 | 39 |
end |
40 | 40 |
|
41 | 41 |
it "requires a hit.title" do |
42 | 42 |
@checker.options['hit']['title'] = "" |
43 |
- @checker.should_not be_valid |
|
43 |
+ expect(@checker).not_to be_valid |
|
44 | 44 |
end |
45 | 45 |
|
46 | 46 |
it "requires a hit.description" do |
47 | 47 |
@checker.options['hit']['description'] = "" |
48 |
- @checker.should_not be_valid |
|
48 |
+ expect(@checker).not_to be_valid |
|
49 | 49 |
end |
50 | 50 |
|
51 | 51 |
it "requires hit.assignments" do |
52 | 52 |
@checker.options['hit']['assignments'] = "" |
53 |
- @checker.should_not be_valid |
|
53 |
+ expect(@checker).not_to be_valid |
|
54 | 54 |
@checker.options['hit']['assignments'] = 0 |
55 |
- @checker.should_not be_valid |
|
55 |
+ expect(@checker).not_to be_valid |
|
56 | 56 |
@checker.options['hit']['assignments'] = "moose" |
57 |
- @checker.should_not be_valid |
|
57 |
+ expect(@checker).not_to be_valid |
|
58 | 58 |
@checker.options['hit']['assignments'] = "2" |
59 |
- @checker.should be_valid |
|
59 |
+ expect(@checker).to be_valid |
|
60 | 60 |
end |
61 | 61 |
|
62 | 62 |
it "requires hit.questions" do |
63 | 63 |
old_questions = @checker.options['hit']['questions'] |
64 | 64 |
@checker.options['hit']['questions'] = nil |
65 |
- @checker.should_not be_valid |
|
65 |
+ expect(@checker).not_to be_valid |
|
66 | 66 |
@checker.options['hit']['questions'] = [] |
67 |
- @checker.should_not be_valid |
|
67 |
+ expect(@checker).not_to be_valid |
|
68 | 68 |
@checker.options['hit']['questions'] = [old_questions[0]] |
69 |
- @checker.should be_valid |
|
69 |
+ expect(@checker).to be_valid |
|
70 | 70 |
end |
71 | 71 |
|
72 | 72 |
it "requires that all questions have key, name, required, type, and question" do |
73 | 73 |
old_questions = @checker.options['hit']['questions'] |
74 | 74 |
@checker.options['hit']['questions'].first['key'] = "" |
75 |
- @checker.should_not be_valid |
|
75 |
+ expect(@checker).not_to be_valid |
|
76 | 76 |
|
77 | 77 |
@checker.options['hit']['questions'] = old_questions |
78 | 78 |
@checker.options['hit']['questions'].first['name'] = "" |
79 |
- @checker.should_not be_valid |
|
79 |
+ expect(@checker).not_to be_valid |
|
80 | 80 |
|
81 | 81 |
@checker.options['hit']['questions'] = old_questions |
82 | 82 |
@checker.options['hit']['questions'].first['required'] = nil |
83 |
- @checker.should_not be_valid |
|
83 |
+ expect(@checker).not_to be_valid |
|
84 | 84 |
|
85 | 85 |
@checker.options['hit']['questions'] = old_questions |
86 | 86 |
@checker.options['hit']['questions'].first['type'] = "" |
87 |
- @checker.should_not be_valid |
|
87 |
+ expect(@checker).not_to be_valid |
|
88 | 88 |
|
89 | 89 |
@checker.options['hit']['questions'] = old_questions |
90 | 90 |
@checker.options['hit']['questions'].first['question'] = "" |
91 |
- @checker.should_not be_valid |
|
91 |
+ expect(@checker).not_to be_valid |
|
92 | 92 |
end |
93 | 93 |
|
94 | 94 |
it "requires that all questions of type 'selection' have a selections array with keys and text" do |
95 | 95 |
@checker.options['hit']['questions'][0]['selections'] = [] |
96 |
- @checker.should_not be_valid |
|
96 |
+ expect(@checker).not_to be_valid |
|
97 | 97 |
@checker.options['hit']['questions'][0]['selections'] = [{}] |
98 |
- @checker.should_not be_valid |
|
98 |
+ expect(@checker).not_to be_valid |
|
99 | 99 |
@checker.options['hit']['questions'][0]['selections'] = [{ 'key' => "", 'text' => "" }] |
100 |
- @checker.should_not be_valid |
|
100 |
+ expect(@checker).not_to be_valid |
|
101 | 101 |
@checker.options['hit']['questions'][0]['selections'] = [{ 'key' => "", 'text' => "hi" }] |
102 |
- @checker.should_not be_valid |
|
102 |
+ expect(@checker).not_to be_valid |
|
103 | 103 |
@checker.options['hit']['questions'][0]['selections'] = [{ 'key' => "hi", 'text' => "" }] |
104 |
- @checker.should_not be_valid |
|
104 |
+ expect(@checker).not_to be_valid |
|
105 | 105 |
@checker.options['hit']['questions'][0]['selections'] = [{ 'key' => "hi", 'text' => "hi" }] |
106 |
- @checker.should be_valid |
|
106 |
+ expect(@checker).to be_valid |
|
107 | 107 |
@checker.options['hit']['questions'][0]['selections'] = [{ 'key' => "hi", 'text' => "hi" }, {}] |
108 |
- @checker.should_not be_valid |
|
108 |
+ expect(@checker).not_to be_valid |
|
109 | 109 |
end |
110 | 110 |
|
111 | 111 |
it "requires that 'poll_options' be present and populated when 'combination_mode' is set to 'poll'" do |
112 | 112 |
@checker.options['combination_mode'] = "poll" |
113 |
- @checker.should_not be_valid |
|
113 |
+ expect(@checker).not_to be_valid |
|
114 | 114 |
@checker.options['poll_options'] = {} |
115 |
- @checker.should_not be_valid |
|
115 |
+ expect(@checker).not_to be_valid |
|
116 | 116 |
@checker.options['poll_options'] = { 'title' => "Take a poll about jokes", |
117 | 117 |
'instructions' => "Rank these by how funny they are", |
118 | 118 |
'assignments' => 3, |
119 | 119 |
'row_template' => "{{joke}}" } |
120 |
- @checker.should be_valid |
|
120 |
+ expect(@checker).to be_valid |
|
121 | 121 |
@checker.options['poll_options'] = { 'instructions' => "Rank these by how funny they are", |
122 | 122 |
'assignments' => 3, |
123 | 123 |
'row_template' => "{{joke}}" } |
124 |
- @checker.should_not be_valid |
|
124 |
+ expect(@checker).not_to be_valid |
|
125 | 125 |
@checker.options['poll_options'] = { 'title' => "Take a poll about jokes", |
126 | 126 |
'assignments' => 3, |
127 | 127 |
'row_template' => "{{joke}}" } |
128 |
- @checker.should_not be_valid |
|
128 |
+ expect(@checker).not_to be_valid |
|
129 | 129 |
@checker.options['poll_options'] = { 'title' => "Take a poll about jokes", |
130 | 130 |
'instructions' => "Rank these by how funny they are", |
131 | 131 |
'row_template' => "{{joke}}" } |
132 |
- @checker.should_not be_valid |
|
132 |
+ expect(@checker).not_to be_valid |
|
133 | 133 |
@checker.options['poll_options'] = { 'title' => "Take a poll about jokes", |
134 | 134 |
'instructions' => "Rank these by how funny they are", |
135 | 135 |
'assignments' => 3} |
136 |
- @checker.should_not be_valid |
|
136 |
+ expect(@checker).not_to be_valid |
|
137 | 137 |
end |
138 | 138 |
|
139 | 139 |
it "requires that all questions be of type 'selection' when 'combination_mode' is 'take_majority'" do |
140 | 140 |
@checker.options['combination_mode'] = "take_majority" |
141 |
- @checker.should_not be_valid |
|
141 |
+ expect(@checker).not_to be_valid |
|
142 | 142 |
@checker.options['hit']['questions'][1]['type'] = "selection" |
143 | 143 |
@checker.options['hit']['questions'][1]['selections'] = @checker.options['hit']['questions'][0]['selections'] |
144 |
- @checker.should be_valid |
|
144 |
+ expect(@checker).to be_valid |
|
145 | 145 |
end |
146 | 146 |
|
147 | 147 |
it "accepts 'take_majority': 'true' for legacy support" do |
148 | 148 |
@checker.options['take_majority'] = "true" |
149 |
- @checker.should_not be_valid |
|
149 |
+ expect(@checker).not_to be_valid |
|
150 | 150 |
@checker.options['hit']['questions'][1]['type'] = "selection" |
151 | 151 |
@checker.options['hit']['questions'][1]['selections'] = @checker.options['hit']['questions'][0]['selections'] |
152 |
- @checker.should be_valid |
|
152 |
+ expect(@checker).to be_valid |
|
153 | 153 |
end |
154 | 154 |
end |
155 | 155 |
|
@@ -219,16 +219,16 @@ describe Agents::HumanTaskAgent do |
||
219 | 219 |
|
220 | 220 |
@checker.send :create_basic_hit, @event |
221 | 221 |
|
222 |
- hitInterface.max_assignments.should == @checker.options['hit']['assignments'] |
|
223 |
- hitInterface.reward.should == @checker.options['hit']['reward'] |
|
224 |
- hitInterface.description.should == "Make something for Joe" |
|
222 |
+ expect(hitInterface.max_assignments).to eq(@checker.options['hit']['assignments']) |
|
223 |
+ expect(hitInterface.reward).to eq(@checker.options['hit']['reward']) |
|
224 |
+ expect(hitInterface.description).to eq("Make something for Joe") |
|
225 | 225 |
|
226 | 226 |
xml = question_form.to_xml |
227 |
- xml.should include("<Title>Hi Joe</Title>") |
|
228 |
- xml.should include("<Text>Make something for Joe</Text>") |
|
229 |
- xml.should include("<DisplayName>Joe Question 1</DisplayName>") |
|
227 |
+ expect(xml).to include("<Title>Hi Joe</Title>") |
|
228 |
+ expect(xml).to include("<Text>Make something for Joe</Text>") |
|
229 |
+ expect(xml).to include("<DisplayName>Joe Question 1</DisplayName>") |
|
230 | 230 |
|
231 |
- @checker.memory['hits'][123]['event_id'].should == @event.id |
|
231 |
+ expect(@checker.memory['hits'][123]['event_id']).to eq(@event.id) |
|
232 | 232 |
end |
233 | 233 |
|
234 | 234 |
it "works without an event too" do |
@@ -238,8 +238,8 @@ describe Agents::HumanTaskAgent do |
||
238 | 238 |
mock(hitInterface).question_form(instance_of Agents::HumanTaskAgent::AgentQuestionForm) |
239 | 239 |
mock(RTurk::Hit).create(:title => "Hi").yields(hitInterface) { hitInterface } |
240 | 240 |
@checker.send :create_basic_hit |
241 |
- hitInterface.max_assignments.should == @checker.options['hit']['assignments'] |
|
242 |
- hitInterface.reward.should == @checker.options['hit']['reward'] |
|
241 |
+ expect(hitInterface.max_assignments).to eq(@checker.options['hit']['assignments']) |
|
242 |
+ expect(hitInterface.reward).to eq(@checker.options['hit']['reward']) |
|
243 | 243 |
end |
244 | 244 |
end |
245 | 245 |
|
@@ -323,8 +323,8 @@ describe Agents::HumanTaskAgent do |
||
323 | 323 |
|
324 | 324 |
@checker.send :review_hits |
325 | 325 |
|
326 |
- assignments.all? {|a| a.approved == true }.should be_falsey |
|
327 |
- @checker.memory['hits'].should == { "JH3132836336DHG" => { 'event_id' => @event.id } } |
|
326 |
+ expect(assignments.all? {|a| a.approved == true }).to be_falsey |
|
327 |
+ expect(@checker.memory['hits']).to eq({ "JH3132836336DHG" => { 'event_id' => @event.id } }) |
|
328 | 328 |
end |
329 | 329 |
|
330 | 330 |
it "shouldn't do anything if an assignment is missing" do |
@@ -341,8 +341,8 @@ describe Agents::HumanTaskAgent do |
||
341 | 341 |
|
342 | 342 |
@checker.send :review_hits |
343 | 343 |
|
344 |
- assignments.all? {|a| a.approved == true }.should be_falsey |
|
345 |
- @checker.memory['hits'].should == { "JH3132836336DHG" => { 'event_id' => @event.id } } |
|
344 |
+ expect(assignments.all? {|a| a.approved == true }).to be_falsey |
|
345 |
+ expect(@checker.memory['hits']).to eq({ "JH3132836336DHG" => { 'event_id' => @event.id } }) |
|
346 | 346 |
end |
347 | 347 |
|
348 | 348 |
context "emitting events" do |
@@ -354,43 +354,43 @@ describe Agents::HumanTaskAgent do |
||
354 | 354 |
FakeAssignment.new(:status => "Submitted", :answers => {"sentiment"=>"happy", "feedback"=>"Take 2"}) |
355 | 355 |
] |
356 | 356 |
@hit = FakeHit.new(:max_assignments => 2, :assignments => @assignments) |
357 |
- @hit.should_not be_disposed |
|
357 |
+ expect(@hit).not_to be_disposed |
|
358 | 358 |
mock(RTurk::Hit).new("JH3132836336DHG") { @hit } |
359 | 359 |
end |
360 | 360 |
|
361 | 361 |
it "should create events when all assignments are ready" do |
362 |
- lambda { |
|
362 |
+ expect { |
|
363 | 363 |
@checker.send :review_hits |
364 |
- }.should change { Event.count }.by(1) |
|
364 |
+ }.to change { Event.count }.by(1) |
|
365 | 365 |
|
366 |
- @assignments.all? {|a| a.approved == true }.should be_truthy |
|
367 |
- @hit.should be_disposed |
|
366 |
+ expect(@assignments.all? {|a| a.approved == true }).to be_truthy |
|
367 |
+ expect(@hit).to be_disposed |
|
368 | 368 |
|
369 |
- @checker.events.last.payload['answers'].should == [ |
|
369 |
+ expect(@checker.events.last.payload['answers']).to eq([ |
|
370 | 370 |
{'sentiment' => "neutral", 'feedback' => ""}, |
371 | 371 |
{'sentiment' => "happy", 'feedback' => "Take 2"} |
372 |
- ] |
|
372 |
+ ]) |
|
373 | 373 |
|
374 |
- @checker.memory['hits'].should == {} |
|
374 |
+ expect(@checker.memory['hits']).to eq({}) |
|
375 | 375 |
end |
376 | 376 |
|
377 | 377 |
it "should emit separate answers when options[:separate_answers] is true" do |
378 | 378 |
@checker.options[:separate_answers] = true |
379 | 379 |
|
380 |
- lambda { |
|
380 |
+ expect { |
|
381 | 381 |
@checker.send :review_hits |
382 |
- }.should change { Event.count }.by(2) |
|
382 |
+ }.to change { Event.count }.by(2) |
|
383 | 383 |
|
384 |
- @assignments.all? {|a| a.approved == true }.should be_truthy |
|
385 |
- @hit.should be_disposed |
|
384 |
+ expect(@assignments.all? {|a| a.approved == true }).to be_truthy |
|
385 |
+ expect(@hit).to be_disposed |
|
386 | 386 |
|
387 | 387 |
event1, event2 = @checker.events.last(2) |
388 |
- event1.payload.should_not have_key('answers') |
|
389 |
- event2.payload.should_not have_key('answers') |
|
390 |
- event1.payload['answer'].should == { 'sentiment' => "happy", 'feedback' => "Take 2" } |
|
391 |
- event2.payload['answer'].should == { 'sentiment' => "neutral", 'feedback' => "" } |
|
388 |
+ expect(event1.payload).not_to have_key('answers') |
|
389 |
+ expect(event2.payload).not_to have_key('answers') |
|
390 |
+ expect(event1.payload['answer']).to eq({ 'sentiment' => "happy", 'feedback' => "Take 2" }) |
|
391 |
+ expect(event2.payload['answer']).to eq({ 'sentiment' => "neutral", 'feedback' => "" }) |
|
392 | 392 |
|
393 |
- @checker.memory['hits'].should == {} |
|
393 |
+ expect(@checker.memory['hits']).to eq({}) |
|
394 | 394 |
end |
395 | 395 |
end |
396 | 396 |
|
@@ -424,24 +424,24 @@ describe Agents::HumanTaskAgent do |
||
424 | 424 |
hit = FakeHit.new(:max_assignments => 4, :assignments => assignments) |
425 | 425 |
mock(RTurk::Hit).new("JH3132836336DHG") { hit } |
426 | 426 |
|
427 |
- lambda { |
|
427 |
+ expect { |
|
428 | 428 |
@checker.send :review_hits |
429 |
- }.should change { Event.count }.by(1) |
|
429 |
+ }.to change { Event.count }.by(1) |
|
430 | 430 |
|
431 |
- assignments.all? {|a| a.approved == true }.should be_truthy |
|
431 |
+ expect(assignments.all? {|a| a.approved == true }).to be_truthy |
|
432 | 432 |
|
433 |
- @checker.events.last.payload['answers'].should == [ |
|
433 |
+ expect(@checker.events.last.payload['answers']).to eq([ |
|
434 | 434 |
{ 'sentiment' => "sad", 'age_range' => "<50" }, |
435 | 435 |
{ 'sentiment' => "neutral", 'age_range' => ">50" }, |
436 | 436 |
{ 'sentiment' => "happy", 'age_range' => ">50" }, |
437 | 437 |
{ 'sentiment' => "happy", 'age_range' => ">50" } |
438 |
- ] |
|
438 |
+ ]) |
|
439 | 439 |
|
440 |
- @checker.events.last.payload['counts'].should == { 'sentiment' => { 'happy' => 2, 'sad' => 1, 'neutral' => 1 }, 'age_range' => { ">50" => 3, "<50" => 1 } } |
|
441 |
- @checker.events.last.payload['majority_answer'].should == { 'sentiment' => "happy", 'age_range' => ">50" } |
|
442 |
- @checker.events.last.payload.should_not have_key('average_answer') |
|
440 |
+ expect(@checker.events.last.payload['counts']).to eq({ 'sentiment' => { 'happy' => 2, 'sad' => 1, 'neutral' => 1 }, 'age_range' => { ">50" => 3, "<50" => 1 } }) |
|
441 |
+ expect(@checker.events.last.payload['majority_answer']).to eq({ 'sentiment' => "happy", 'age_range' => ">50" }) |
|
442 |
+ expect(@checker.events.last.payload).not_to have_key('average_answer') |
|
443 | 443 |
|
444 |
- @checker.memory['hits'].should == {} |
|
444 |
+ expect(@checker.memory['hits']).to eq({}) |
|
445 | 445 |
end |
446 | 446 |
|
447 | 447 |
it "should also provide an average answer when all questions are numeric" do |
@@ -477,25 +477,25 @@ describe Agents::HumanTaskAgent do |
||
477 | 477 |
hit = FakeHit.new(:max_assignments => 5, :assignments => assignments) |
478 | 478 |
mock(RTurk::Hit).new("JH3132836336DHG") { hit } |
479 | 479 |
|
480 |
- lambda { |
|
480 |
+ expect { |
|
481 | 481 |
@checker.send :review_hits |
482 |
- }.should change { Event.count }.by(1) |
|
482 |
+ }.to change { Event.count }.by(1) |
|
483 | 483 |
|
484 |
- assignments.all? {|a| a.approved == true }.should be_truthy |
|
484 |
+ expect(assignments.all? {|a| a.approved == true }).to be_truthy |
|
485 | 485 |
|
486 |
- @checker.events.last.payload['answers'].should == [ |
|
486 |
+ expect(@checker.events.last.payload['answers']).to eq([ |
|
487 | 487 |
{ 'rating' => "1" }, |
488 | 488 |
{ 'rating' => "3" }, |
489 | 489 |
{ 'rating' => "5.1" }, |
490 | 490 |
{ 'rating' => "2" }, |
491 | 491 |
{ 'rating' => "2" } |
492 |
- ] |
|
492 |
+ ]) |
|
493 | 493 |
|
494 |
- @checker.events.last.payload['counts'].should == { 'rating' => { "1" => 1, "2" => 2, "3" => 1, "4" => 0, "5.1" => 1 } } |
|
495 |
- @checker.events.last.payload['majority_answer'].should == { 'rating' => "2" } |
|
496 |
- @checker.events.last.payload['average_answer'].should == { 'rating' => (1 + 2 + 2 + 3 + 5.1) / 5.0 } |
|
494 |
+ expect(@checker.events.last.payload['counts']).to eq({ 'rating' => { "1" => 1, "2" => 2, "3" => 1, "4" => 0, "5.1" => 1 } }) |
|
495 |
+ expect(@checker.events.last.payload['majority_answer']).to eq({ 'rating' => "2" }) |
|
496 |
+ expect(@checker.events.last.payload['average_answer']).to eq({ 'rating' => (1 + 2 + 2 + 3 + 5.1) / 5.0 }) |
|
497 | 497 |
|
498 |
- @checker.memory['hits'].should == {} |
|
498 |
+ expect(@checker.memory['hits']).to eq({}) |
|
499 | 499 |
end |
500 | 500 |
end |
501 | 501 |
|
@@ -525,7 +525,7 @@ describe Agents::HumanTaskAgent do |
||
525 | 525 |
hit = FakeHit.new(:max_assignments => 4, :assignments => assignments) |
526 | 526 |
mock(RTurk::Hit).new("JH3132836336DHG") { hit } |
527 | 527 |
|
528 |
- @checker.memory['hits']["JH3132836336DHG"].should be_present |
|
528 |
+ expect(@checker.memory['hits']["JH3132836336DHG"]).to be_present |
|
529 | 529 |
|
530 | 530 |
# Setup mocks for HIT creation |
531 | 531 |
|
@@ -537,33 +537,33 @@ describe Agents::HumanTaskAgent do |
||
537 | 537 |
|
538 | 538 |
# And finally, the test. |
539 | 539 |
|
540 |
- lambda { |
|
540 |
+ expect { |
|
541 | 541 |
@checker.send :review_hits |
542 |
- }.should change { Event.count }.by(0) # it does not emit an event until all poll results are in |
|
542 |
+ }.to change { Event.count }.by(0) # it does not emit an event until all poll results are in |
|
543 | 543 |
|
544 | 544 |
# it approves the existing assignments |
545 | 545 |
|
546 |
- assignments.all? {|a| a.approved == true }.should be_truthy |
|
547 |
- hit.should be_disposed |
|
546 |
+ expect(assignments.all? {|a| a.approved == true }).to be_truthy |
|
547 |
+ expect(hit).to be_disposed |
|
548 | 548 |
|
549 | 549 |
# it creates a new HIT for the poll |
550 | 550 |
|
551 |
- hitInterface.max_assignments.should == @checker.options['poll_options']['assignments'] |
|
552 |
- hitInterface.description.should == @checker.options['poll_options']['instructions'] |
|
551 |
+ expect(hitInterface.max_assignments).to eq(@checker.options['poll_options']['assignments']) |
|
552 |
+ expect(hitInterface.description).to eq(@checker.options['poll_options']['instructions']) |
|
553 | 553 |
|
554 | 554 |
xml = question_form.to_xml |
555 |
- xml.should include("<Text>This is happy</Text>") |
|
556 |
- xml.should include("<Text>This is neutral</Text>") |
|
557 |
- xml.should include("<Text>This is sad</Text>") |
|
555 |
+ expect(xml).to include("<Text>This is happy</Text>") |
|
556 |
+ expect(xml).to include("<Text>This is neutral</Text>") |
|
557 |
+ expect(xml).to include("<Text>This is sad</Text>") |
|
558 | 558 |
|
559 | 559 |
@checker.save |
560 | 560 |
@checker.reload |
561 |
- @checker.memory['hits']["JH3132836336DHG"].should_not be_present |
|
562 |
- @checker.memory['hits']["JH39AA63836DH12345"].should be_present |
|
563 |
- @checker.memory['hits']["JH39AA63836DH12345"]['event_id'].should == @event.id |
|
564 |
- @checker.memory['hits']["JH39AA63836DH12345"]['type'].should == "poll" |
|
565 |
- @checker.memory['hits']["JH39AA63836DH12345"]['original_hit'].should == "JH3132836336DHG" |
|
566 |
- @checker.memory['hits']["JH39AA63836DH12345"]['answers'].length.should == 4 |
|
561 |
+ expect(@checker.memory['hits']["JH3132836336DHG"]).not_to be_present |
|
562 |
+ expect(@checker.memory['hits']["JH39AA63836DH12345"]).to be_present |
|
563 |
+ expect(@checker.memory['hits']["JH39AA63836DH12345"]['event_id']).to eq(@event.id) |
|
564 |
+ expect(@checker.memory['hits']["JH39AA63836DH12345"]['type']).to eq("poll") |
|
565 |
+ expect(@checker.memory['hits']["JH39AA63836DH12345"]['original_hit']).to eq("JH3132836336DHG") |
|
566 |
+ expect(@checker.memory['hits']["JH39AA63836DH12345"]['answers'].length).to eq(4) |
|
567 | 567 |
end |
568 | 568 |
|
569 | 569 |
it "emits an event when all poll results are in, containing the data from the best answer, plus all others" do |
@@ -591,24 +591,24 @@ describe Agents::HumanTaskAgent do |
||
591 | 591 |
hit = FakeHit.new(:max_assignments => 2, :assignments => assignments) |
592 | 592 |
mock(RTurk::Hit).new("JH39AA63836DH12345") { hit } |
593 | 593 |
|
594 |
- @checker.memory['hits']["JH39AA63836DH12345"].should be_present |
|
594 |
+ expect(@checker.memory['hits']["JH39AA63836DH12345"]).to be_present |
|
595 | 595 |
|
596 |
- lambda { |
|
596 |
+ expect { |
|
597 | 597 |
@checker.send :review_hits |
598 |
- }.should change { Event.count }.by(1) |
|
598 |
+ }.to change { Event.count }.by(1) |
|
599 | 599 |
|
600 | 600 |
# It emits an event |
601 | 601 |
|
602 |
- @checker.events.last.payload['answers'].should == original_answers |
|
603 |
- @checker.events.last.payload['poll'].should == [{"1" => "2", "2" => "5", "3" => "3", "4" => "2"}, {"1" => "3", "2" => "4", "3" => "1", "4" => "4"}] |
|
604 |
- @checker.events.last.payload['best_answer'].should == {'sentiment' => "neutral", 'feedback' => "This is my feedback 2"} |
|
602 |
+ expect(@checker.events.last.payload['answers']).to eq(original_answers) |
|
603 |
+ expect(@checker.events.last.payload['poll']).to eq([{"1" => "2", "2" => "5", "3" => "3", "4" => "2"}, {"1" => "3", "2" => "4", "3" => "1", "4" => "4"}]) |
|
604 |
+ expect(@checker.events.last.payload['best_answer']).to eq({'sentiment' => "neutral", 'feedback' => "This is my feedback 2"}) |
|
605 | 605 |
|
606 | 606 |
# it approves the existing assignments |
607 | 607 |
|
608 |
- assignments.all? {|a| a.approved == true }.should be_truthy |
|
609 |
- hit.should be_disposed |
|
608 |
+ expect(assignments.all? {|a| a.approved == true }).to be_truthy |
|
609 |
+ expect(hit).to be_disposed |
|
610 | 610 |
|
611 |
- @checker.memory['hits'].should be_empty |
|
611 |
+ expect(@checker.memory['hits']).to be_empty |
|
612 | 612 |
end |
613 | 613 |
end |
614 | 614 |
end |
@@ -94,42 +94,42 @@ describe Agents::ImapFolderAgent do |
||
94 | 94 |
|
95 | 95 |
describe 'validations' do |
96 | 96 |
before do |
97 |
- @checker.should be_valid |
|
97 |
+ expect(@checker).to be_valid |
|
98 | 98 |
end |
99 | 99 |
|
100 | 100 |
it 'should validate the integer fields' do |
101 | 101 |
@checker.options['expected_update_period_in_days'] = 'nonsense' |
102 |
- @checker.should_not be_valid |
|
102 |
+ expect(@checker).not_to be_valid |
|
103 | 103 |
|
104 | 104 |
@checker.options['expected_update_period_in_days'] = '2' |
105 |
- @checker.should be_valid |
|
105 |
+ expect(@checker).to be_valid |
|
106 | 106 |
|
107 | 107 |
@checker.options['port'] = -1 |
108 |
- @checker.should_not be_valid |
|
108 |
+ expect(@checker).not_to be_valid |
|
109 | 109 |
|
110 | 110 |
@checker.options['port'] = 'imap' |
111 |
- @checker.should_not be_valid |
|
111 |
+ expect(@checker).not_to be_valid |
|
112 | 112 |
|
113 | 113 |
@checker.options['port'] = '143' |
114 |
- @checker.should be_valid |
|
114 |
+ expect(@checker).to be_valid |
|
115 | 115 |
|
116 | 116 |
@checker.options['port'] = 993 |
117 |
- @checker.should be_valid |
|
117 |
+ expect(@checker).to be_valid |
|
118 | 118 |
end |
119 | 119 |
|
120 | 120 |
it 'should validate the boolean fields' do |
121 | 121 |
%w[ssl mark_as_read].each do |key| |
122 | 122 |
@checker.options[key] = 1 |
123 |
- @checker.should_not be_valid |
|
123 |
+ expect(@checker).not_to be_valid |
|
124 | 124 |
|
125 | 125 |
@checker.options[key] = false |
126 |
- @checker.should be_valid |
|
126 |
+ expect(@checker).to be_valid |
|
127 | 127 |
|
128 | 128 |
@checker.options[key] = 'true' |
129 |
- @checker.should be_valid |
|
129 |
+ expect(@checker).to be_valid |
|
130 | 130 |
|
131 | 131 |
@checker.options[key] = '' |
132 |
- @checker.should be_valid |
|
132 |
+ expect(@checker).to be_valid |
|
133 | 133 |
end |
134 | 134 |
end |
135 | 135 |
|
@@ -137,46 +137,46 @@ describe Agents::ImapFolderAgent do |
||
137 | 137 |
@checker.options['conditions'] = { |
138 | 138 |
'subject' => '(foo' |
139 | 139 |
} |
140 |
- @checker.should_not be_valid |
|
140 |
+ expect(@checker).not_to be_valid |
|
141 | 141 |
|
142 | 142 |
@checker.options['conditions'] = { |
143 | 143 |
'body' => '***' |
144 | 144 |
} |
145 |
- @checker.should_not be_valid |
|
145 |
+ expect(@checker).not_to be_valid |
|
146 | 146 |
|
147 | 147 |
@checker.options['conditions'] = { |
148 | 148 |
'subject' => '\ARe:', |
149 | 149 |
'body' => '(?<foo>http://\S+)' |
150 | 150 |
} |
151 |
- @checker.should be_valid |
|
151 |
+ expect(@checker).to be_valid |
|
152 | 152 |
end |
153 | 153 |
end |
154 | 154 |
|
155 | 155 |
describe '#check' do |
156 | 156 |
it 'should check for mails and save memory' do |
157 |
- lambda { @checker.check }.should change { Event.count }.by(2) |
|
158 |
- @checker.notified.sort.should == @mails.map(&:message_id).sort |
|
159 |
- @checker.lastseen.should == @mails.each_with_object(@checker.make_seen) { |mail, seen| |
|
157 |
+ expect { @checker.check }.to change { Event.count }.by(2) |
|
158 |
+ expect(@checker.notified.sort).to eq(@mails.map(&:message_id).sort) |
|
159 |
+ expect(@checker.lastseen).to eq(@mails.each_with_object(@checker.make_seen) { |mail, seen| |
|
160 | 160 |
seen[mail.uidvalidity] = mail.uid |
161 |
- } |
|
161 |
+ }) |
|
162 | 162 |
|
163 | 163 |
Event.last(2).map(&:payload) == @payloads |
164 | 164 |
|
165 |
- lambda { @checker.check }.should_not change { Event.count } |
|
165 |
+ expect { @checker.check }.not_to change { Event.count } |
|
166 | 166 |
end |
167 | 167 |
|
168 | 168 |
it 'should narrow mails by To' do |
169 | 169 |
@checker.options['conditions']['to'] = 'John.Doe@*' |
170 | 170 |
|
171 |
- lambda { @checker.check }.should change { Event.count }.by(1) |
|
172 |
- @checker.notified.sort.should == [@mails.first.message_id] |
|
173 |
- @checker.lastseen.should == @mails.each_with_object(@checker.make_seen) { |mail, seen| |
|
171 |
+ expect { @checker.check }.to change { Event.count }.by(1) |
|
172 |
+ expect(@checker.notified.sort).to eq([@mails.first.message_id]) |
|
173 |
+ expect(@checker.lastseen).to eq(@mails.each_with_object(@checker.make_seen) { |mail, seen| |
|
174 | 174 |
seen[mail.uidvalidity] = mail.uid |
175 |
- } |
|
175 |
+ }) |
|
176 | 176 |
|
177 |
- Event.last.payload.should == @payloads.first |
|
177 |
+ expect(Event.last.payload).to eq(@payloads.first) |
|
178 | 178 |
|
179 |
- lambda { @checker.check }.should_not change { Event.count } |
|
179 |
+ expect { @checker.check }.not_to change { Event.count } |
|
180 | 180 |
end |
181 | 181 |
|
182 | 182 |
it 'should perform regexp matching and save named captures' do |
@@ -185,35 +185,35 @@ describe Agents::ImapFolderAgent do |
||
185 | 185 |
'body' => 'Some (?<b>.+) reply', |
186 | 186 |
) |
187 | 187 |
|
188 |
- lambda { @checker.check }.should change { Event.count }.by(1) |
|
189 |
- @checker.notified.sort.should == [@mails.last.message_id] |
|
190 |
- @checker.lastseen.should == @mails.each_with_object(@checker.make_seen) { |mail, seen| |
|
188 |
+ expect { @checker.check }.to change { Event.count }.by(1) |
|
189 |
+ expect(@checker.notified.sort).to eq([@mails.last.message_id]) |
|
190 |
+ expect(@checker.lastseen).to eq(@mails.each_with_object(@checker.make_seen) { |mail, seen| |
|
191 | 191 |
seen[mail.uidvalidity] = mail.uid |
192 |
- } |
|
192 |
+ }) |
|
193 | 193 |
|
194 |
- Event.last.payload.should == @payloads.last.update( |
|
194 |
+ expect(Event.last.payload).to eq(@payloads.last.update( |
|
195 | 195 |
'body' => "<div dir=\"ltr\">Some HTML reply<br></div>\n", |
196 | 196 |
'matches' => { 'a' => 'some subject', 'b' => 'HTML' }, |
197 | 197 |
'mime_type' => 'text/html', |
198 |
- ) |
|
198 |
+ )) |
|
199 | 199 |
|
200 |
- lambda { @checker.check }.should_not change { Event.count } |
|
200 |
+ expect { @checker.check }.not_to change { Event.count } |
|
201 | 201 |
end |
202 | 202 |
|
203 | 203 |
it 'should narrow mails by has_attachment (true)' do |
204 | 204 |
@checker.options['conditions']['has_attachment'] = true |
205 | 205 |
|
206 |
- lambda { @checker.check }.should change { Event.count }.by(1) |
|
206 |
+ expect { @checker.check }.to change { Event.count }.by(1) |
|
207 | 207 |
|
208 |
- Event.last.payload['subject'].should == 'Re: some subject' |
|
208 |
+ expect(Event.last.payload['subject']).to eq('Re: some subject') |
|
209 | 209 |
end |
210 | 210 |
|
211 | 211 |
it 'should narrow mails by has_attachment (false)' do |
212 | 212 |
@checker.options['conditions']['has_attachment'] = false |
213 | 213 |
|
214 |
- lambda { @checker.check }.should change { Event.count }.by(1) |
|
214 |
+ expect { @checker.check }.to change { Event.count }.by(1) |
|
215 | 215 |
|
216 |
- Event.last.payload['subject'].should == 'some subject' |
|
216 |
+ expect(Event.last.payload['subject']).to eq('some subject') |
|
217 | 217 |
end |
218 | 218 |
|
219 | 219 |
it 'should narrow mail parts by MIME types' do |
@@ -223,18 +223,18 @@ describe Agents::ImapFolderAgent do |
||
223 | 223 |
'body' => 'Some (?<b>.+) reply', |
224 | 224 |
) |
225 | 225 |
|
226 |
- lambda { @checker.check }.should_not change { Event.count } |
|
227 |
- @checker.notified.sort.should == [] |
|
228 |
- @checker.lastseen.should == @mails.each_with_object(@checker.make_seen) { |mail, seen| |
|
226 |
+ expect { @checker.check }.not_to change { Event.count } |
|
227 |
+ expect(@checker.notified.sort).to eq([]) |
|
228 |
+ expect(@checker.lastseen).to eq(@mails.each_with_object(@checker.make_seen) { |mail, seen| |
|
229 | 229 |
seen[mail.uidvalidity] = mail.uid |
230 |
- } |
|
230 |
+ }) |
|
231 | 231 |
end |
232 | 232 |
|
233 | 233 |
it 'should never mark mails as read unless mark_as_read is true' do |
234 | 234 |
@mails.each { |mail| |
235 | 235 |
stub(mail).mark_as_read.never |
236 | 236 |
} |
237 |
- lambda { @checker.check }.should change { Event.count }.by(2) |
|
237 |
+ expect { @checker.check }.to change { Event.count }.by(2) |
|
238 | 238 |
end |
239 | 239 |
|
240 | 240 |
it 'should mark mails as read if mark_as_read is true' do |
@@ -242,7 +242,7 @@ describe Agents::ImapFolderAgent do |
||
242 | 242 |
@mails.each { |mail| |
243 | 243 |
stub(mail).mark_as_read.once |
244 | 244 |
} |
245 |
- lambda { @checker.check }.should change { Event.count }.by(2) |
|
245 |
+ expect { @checker.check }.to change { Event.count }.by(2) |
|
246 | 246 |
end |
247 | 247 |
|
248 | 248 |
it 'should create just one event for multiple mails with the same Message-Id' do |
@@ -251,7 +251,7 @@ describe Agents::ImapFolderAgent do |
||
251 | 251 |
@mails.each { |mail| |
252 | 252 |
stub(mail).mark_as_read.once |
253 | 253 |
} |
254 |
- lambda { @checker.check }.should change { Event.count }.by(1) |
|
254 |
+ expect { @checker.check }.to change { Event.count }.by(1) |
|
255 | 255 |
end |
256 | 256 |
end |
257 | 257 |
end |
@@ -35,33 +35,33 @@ describe Agents::JabberAgent do |
||
35 | 35 |
|
36 | 36 |
describe "#working?" do |
37 | 37 |
it "checks if events have been received within the expected receive period" do |
38 |
- agent.should_not be_working # No events received |
|
38 |
+ expect(agent).not_to be_working # No events received |
|
39 | 39 |
Agents::JabberAgent.async_receive agent.id, [event.id] |
40 |
- agent.reload.should be_working # Just received events |
|
40 |
+ expect(agent.reload).to be_working # Just received events |
|
41 | 41 |
two_days_from_now = 2.days.from_now |
42 | 42 |
stub(Time).now { two_days_from_now } |
43 |
- agent.reload.should_not be_working # More time has passed than the expected receive period without any new events |
|
43 |
+ expect(agent.reload).not_to be_working # More time has passed than the expected receive period without any new events |
|
44 | 44 |
end |
45 | 45 |
end |
46 | 46 |
|
47 | 47 |
describe "validation" do |
48 | 48 |
before do |
49 |
- agent.should be_valid |
|
49 |
+ expect(agent).to be_valid |
|
50 | 50 |
end |
51 | 51 |
|
52 | 52 |
it "should validate presence of of jabber_server" do |
53 | 53 |
agent.options[:jabber_server] = "" |
54 |
- agent.should_not be_valid |
|
54 |
+ expect(agent).not_to be_valid |
|
55 | 55 |
end |
56 | 56 |
|
57 | 57 |
it "should validate presence of jabber_sender" do |
58 | 58 |
agent.options[:jabber_sender] = "" |
59 |
- agent.should_not be_valid |
|
59 |
+ expect(agent).not_to be_valid |
|
60 | 60 |
end |
61 | 61 |
|
62 | 62 |
it "should validate presence of jabber_receiver" do |
63 | 63 |
agent.options[:jabber_receiver] = "" |
64 |
- agent.should_not be_valid |
|
64 |
+ expect(agent).not_to be_valid |
|
65 | 65 |
end |
66 | 66 |
end |
67 | 67 |
|
@@ -74,8 +74,8 @@ describe Agents::JabberAgent do |
||
74 | 74 |
end |
75 | 75 |
|
76 | 76 |
agent.receive([event, event2]) |
77 |
- sent.should == [ 'Warning! Weather Alert! - http://www.weather.com/', |
|
78 |
- 'Warning! Another Weather Alert! - http://www.weather.com/we-are-screwed'] |
|
77 |
+ expect(sent).to eq([ 'Warning! Weather Alert! - http://www.weather.com/', |
|
78 |
+ 'Warning! Another Weather Alert! - http://www.weather.com/we-are-screwed']) |
|
79 | 79 |
end |
80 | 80 |
end |
81 | 81 |
end |
@@ -16,19 +16,19 @@ describe Agents::JavaScriptAgent do |
||
16 | 16 |
|
17 | 17 |
describe "validations" do |
18 | 18 |
it "requires 'code'" do |
19 |
- @agent.should be_valid |
|
19 |
+ expect(@agent).to be_valid |
|
20 | 20 |
@agent.options['code'] = '' |
21 |
- @agent.should_not be_valid |
|
21 |
+ expect(@agent).not_to be_valid |
|
22 | 22 |
@agent.options.delete('code') |
23 |
- @agent.should_not be_valid |
|
23 |
+ expect(@agent).not_to be_valid |
|
24 | 24 |
end |
25 | 25 |
|
26 | 26 |
it "accepts a credential, but it must exist" do |
27 |
- @agent.should be_valid |
|
27 |
+ expect(@agent).to be_valid |
|
28 | 28 |
@agent.options['code'] = 'credential:foo' |
29 |
- @agent.should_not be_valid |
|
29 |
+ expect(@agent).not_to be_valid |
|
30 | 30 |
users(:jane).user_credentials.create! :credential_name => "foo", :credential_value => "bar" |
31 |
- @agent.reload.should be_valid |
|
31 |
+ expect(@agent.reload).to be_valid |
|
32 | 32 |
end |
33 | 33 |
end |
34 | 34 |
|
@@ -37,12 +37,12 @@ describe Agents::JavaScriptAgent do |
||
37 | 37 |
it "returns false when more than expected_update_period_in_days have passed since the last event creation" do |
38 | 38 |
@agent.options['expected_update_period_in_days'] = 1 |
39 | 39 |
@agent.save! |
40 |
- @agent.should_not be_working |
|
40 |
+ expect(@agent).not_to be_working |
|
41 | 41 |
@agent.check |
42 |
- @agent.reload.should be_working |
|
42 |
+ expect(@agent.reload).to be_working |
|
43 | 43 |
three_days_from_now = 3.days.from_now |
44 | 44 |
stub(Time).now { three_days_from_now } |
45 |
- @agent.should_not be_working |
|
45 |
+ expect(@agent).not_to be_working |
|
46 | 46 |
end |
47 | 47 |
end |
48 | 48 |
|
@@ -50,12 +50,12 @@ describe Agents::JavaScriptAgent do |
||
50 | 50 |
it "returns false when more than expected_receive_period_in_days have passed since the last event was received" do |
51 | 51 |
@agent.options['expected_receive_period_in_days'] = 1 |
52 | 52 |
@agent.save! |
53 |
- @agent.should_not be_working |
|
53 |
+ expect(@agent).not_to be_working |
|
54 | 54 |
Agents::JavaScriptAgent.async_receive @agent.id, [events(:bob_website_agent_event).id] |
55 |
- @agent.reload.should be_working |
|
55 |
+ expect(@agent.reload).to be_working |
|
56 | 56 |
two_days_from_now = 2.days.from_now |
57 | 57 |
stub(Time).now { two_days_from_now } |
58 |
- @agent.reload.should_not be_working |
|
58 |
+ expect(@agent.reload).not_to be_working |
|
59 | 59 |
end |
60 | 60 |
end |
61 | 61 |
end |
@@ -66,12 +66,12 @@ describe Agents::JavaScriptAgent do |
||
66 | 66 |
@agent.options['make_event'] = true |
67 | 67 |
@agent.save! |
68 | 68 |
|
69 |
- lambda { |
|
70 |
- lambda { |
|
69 |
+ expect { |
|
70 |
+ expect { |
|
71 | 71 |
@agent.receive([events(:bob_website_agent_event)]) |
72 | 72 |
@agent.check |
73 |
- }.should_not change { AgentLog.count } |
|
74 |
- }.should change { Event.count }.by(2) |
|
73 |
+ }.not_to change { AgentLog.count } |
|
74 |
+ }.to change { Event.count }.by(2) |
|
75 | 75 |
end |
76 | 76 |
|
77 | 77 |
|
@@ -84,13 +84,13 @@ describe Agents::JavaScriptAgent do |
||
84 | 84 |
|
85 | 85 |
it "accepts credentials" do |
86 | 86 |
@agent.check |
87 |
- AgentLog.last.message.should == "ran it" |
|
87 |
+ expect(AgentLog.last.message).to eq("ran it") |
|
88 | 88 |
end |
89 | 89 |
|
90 | 90 |
it "logs an error when the credential goes away" do |
91 | 91 |
@agent.user.user_credentials.delete_all |
92 | 92 |
@agent.reload.check |
93 |
- AgentLog.last.message.should == "Unable to find credential" |
|
93 |
+ expect(AgentLog.last.message).to eq("Unable to find credential") |
|
94 | 94 |
end |
95 | 95 |
end |
96 | 96 |
|
@@ -98,34 +98,34 @@ describe Agents::JavaScriptAgent do |
||
98 | 98 |
it "should log an error when V8 has issues" do |
99 | 99 |
@agent.options['code'] = 'syntax error!' |
100 | 100 |
@agent.save! |
101 |
- lambda { |
|
102 |
- lambda { |
|
101 |
+ expect { |
|
102 |
+ expect { |
|
103 | 103 |
@agent.check |
104 |
- }.should_not raise_error |
|
105 |
- }.should change { AgentLog.count }.by(1) |
|
106 |
- AgentLog.last.message.should =~ /Unexpected identifier/ |
|
107 |
- AgentLog.last.level.should == 4 |
|
104 |
+ }.not_to raise_error |
|
105 |
+ }.to change { AgentLog.count }.by(1) |
|
106 |
+ expect(AgentLog.last.message).to match(/Unexpected identifier/) |
|
107 |
+ expect(AgentLog.last.level).to eq(4) |
|
108 | 108 |
end |
109 | 109 |
|
110 | 110 |
it "should log an error when JavaScript throws" do |
111 | 111 |
@agent.options['code'] = 'Agent.check = function() { throw "oh no"; };' |
112 | 112 |
@agent.save! |
113 |
- lambda { |
|
114 |
- lambda { |
|
113 |
+ expect { |
|
114 |
+ expect { |
|
115 | 115 |
@agent.check |
116 |
- }.should_not raise_error |
|
117 |
- }.should change { AgentLog.count }.by(1) |
|
118 |
- AgentLog.last.message.should =~ /oh no/ |
|
119 |
- AgentLog.last.level.should == 4 |
|
116 |
+ }.not_to raise_error |
|
117 |
+ }.to change { AgentLog.count }.by(1) |
|
118 |
+ expect(AgentLog.last.message).to match(/oh no/) |
|
119 |
+ expect(AgentLog.last.level).to eq(4) |
|
120 | 120 |
end |
121 | 121 |
|
122 | 122 |
it "won't store NaNs" do |
123 | 123 |
@agent.options['code'] = 'Agent.check = function() { this.memory("foo", NaN); };' |
124 | 124 |
@agent.save! |
125 | 125 |
@agent.check |
126 |
- @agent.memory['foo'].should == 'NaN' # string |
|
126 |
+ expect(@agent.memory['foo']).to eq('NaN') # string |
|
127 | 127 |
@agent.save! |
128 |
- lambda { @agent.reload.memory }.should_not raise_error |
|
128 |
+ expect { @agent.reload.memory }.not_to raise_error |
|
129 | 129 |
end |
130 | 130 |
end |
131 | 131 |
|
@@ -133,13 +133,13 @@ describe Agents::JavaScriptAgent do |
||
133 | 133 |
it "creates events with this.createEvent in the JavaScript environment" do |
134 | 134 |
@agent.options['code'] = 'Agent.check = function() { this.createEvent({ message: "This is an event!", stuff: { foo: 5 } }); };' |
135 | 135 |
@agent.save! |
136 |
- lambda { |
|
137 |
- lambda { |
|
136 |
+ expect { |
|
137 |
+ expect { |
|
138 | 138 |
@agent.check |
139 |
- }.should_not change { AgentLog.count } |
|
140 |
- }.should change { Event.count }.by(1) |
|
139 |
+ }.not_to change { AgentLog.count } |
|
140 |
+ }.to change { Event.count }.by(1) |
|
141 | 141 |
created_event = @agent.events.last |
142 |
- created_event.payload.should == { 'message' => "This is an event!", 'stuff' => { 'foo' => 5 } } |
|
142 |
+ expect(created_event.payload).to eq({ 'message' => "This is an event!", 'stuff' => { 'foo' => 5 } }) |
|
143 | 143 |
end |
144 | 144 |
end |
145 | 145 |
|
@@ -147,18 +147,18 @@ describe Agents::JavaScriptAgent do |
||
147 | 147 |
it "can output AgentLogs with this.log and this.error in the JavaScript environment" do |
148 | 148 |
@agent.options['code'] = 'Agent.check = function() { this.log("woah"); this.error("WOAH!"); };' |
149 | 149 |
@agent.save! |
150 |
- lambda { |
|
151 |
- lambda { |
|
150 |
+ expect { |
|
151 |
+ expect { |
|
152 | 152 |
@agent.check |
153 |
- }.should_not raise_error |
|
154 |
- }.should change { AgentLog.count }.by(2) |
|
153 |
+ }.not_to raise_error |
|
154 |
+ }.to change { AgentLog.count }.by(2) |
|
155 | 155 |
|
156 | 156 |
log1, log2 = AgentLog.last(2) |
157 | 157 |
|
158 |
- log1.message.should == "woah" |
|
159 |
- log1.level.should == 3 |
|
160 |
- log2.message.should == "WOAH!" |
|
161 |
- log2.level.should == 4 |
|
158 |
+ expect(log1.message).to eq("woah") |
|
159 |
+ expect(log1.level).to eq(3) |
|
160 |
+ expect(log2.message).to eq("WOAH!") |
|
161 |
+ expect(log2.level).to eq(4) |
|
162 | 162 |
end |
163 | 163 |
end |
164 | 164 |
|
@@ -180,13 +180,13 @@ describe Agents::JavaScriptAgent do |
||
180 | 180 |
JS |
181 | 181 |
|
182 | 182 |
@agent.save! |
183 |
- lambda { |
|
184 |
- lambda { |
|
183 |
+ expect { |
|
184 |
+ expect { |
|
185 | 185 |
@agent.receive([events(:bob_website_agent_event), event]) |
186 |
- }.should_not change { AgentLog.count } |
|
187 |
- }.should change { Event.count }.by(2) |
|
186 |
+ }.not_to change { AgentLog.count } |
|
187 |
+ }.to change { Event.count }.by(2) |
|
188 | 188 |
created_event = @agent.events.first |
189 |
- created_event.payload.should == { 'message' => "I got an event!", 'event_was' => { 'data' => "Something you should know about" } } |
|
189 |
+ expect(created_event.payload).to eq({ 'message' => "I got an event!", 'event_was' => { 'data' => "Something you should know about" } }) |
|
190 | 190 |
end |
191 | 191 |
end |
192 | 192 |
|
@@ -203,26 +203,26 @@ describe Agents::JavaScriptAgent do |
||
203 | 203 |
|
204 | 204 |
@agent.save! |
205 | 205 |
|
206 |
- lambda { |
|
207 |
- lambda { |
|
206 |
+ expect { |
|
207 |
+ expect { |
|
208 | 208 |
|
209 | 209 |
@agent.check |
210 |
- @agent.memory['callCount'].should_not be_present |
|
210 |
+ expect(@agent.memory['callCount']).not_to be_present |
|
211 | 211 |
|
212 | 212 |
@agent.options['make_event'] = true |
213 | 213 |
@agent.check |
214 |
- @agent.memory['callCount'].should == 1 |
|
214 |
+ expect(@agent.memory['callCount']).to eq(1) |
|
215 | 215 |
|
216 | 216 |
@agent.check |
217 |
- @agent.memory['callCount'].should == 2 |
|
217 |
+ expect(@agent.memory['callCount']).to eq(2) |
|
218 | 218 |
|
219 | 219 |
@agent.memory['callCount'] = 20 |
220 | 220 |
@agent.check |
221 |
- @agent.memory['callCount'].should == 21 |
|
221 |
+ expect(@agent.memory['callCount']).to eq(21) |
|
222 | 222 |
|
223 |
- }.should_not change { AgentLog.count } |
|
224 |
- }.should_not change { Event.count } |
|
223 |
+ }.not_to change { AgentLog.count } |
|
224 |
+ }.not_to change { Event.count } |
|
225 | 225 |
end |
226 | 226 |
end |
227 | 227 |
end |
228 |
-end |
|
228 |
+end |
@@ -20,48 +20,48 @@ describe Agents::JiraAgent do |
||
20 | 20 |
|
21 | 21 |
describe "validating" do |
22 | 22 |
before do |
23 |
- @checker.should be_valid |
|
23 |
+ expect(@checker).to be_valid |
|
24 | 24 |
end |
25 | 25 |
|
26 | 26 |
it "should work without username" do |
27 | 27 |
@checker.options['username'] = nil |
28 |
- @checker.should be_valid |
|
28 |
+ expect(@checker).to be_valid |
|
29 | 29 |
end |
30 | 30 |
|
31 | 31 |
it "should require the jira password if username is specified" do |
32 | 32 |
@checker.options['username'] = 'user' |
33 | 33 |
@checker.options['password'] = nil |
34 |
- @checker.should_not be_valid |
|
34 |
+ expect(@checker).not_to be_valid |
|
35 | 35 |
end |
36 | 36 |
|
37 | 37 |
it "should require the jira url" do |
38 | 38 |
@checker.options['jira_url'] = nil |
39 |
- @checker.should_not be_valid |
|
39 |
+ expect(@checker).not_to be_valid |
|
40 | 40 |
end |
41 | 41 |
|
42 | 42 |
it "should work without jql" do |
43 | 43 |
@checker.options['jql'] = nil |
44 |
- @checker.should be_valid |
|
44 |
+ expect(@checker).to be_valid |
|
45 | 45 |
end |
46 | 46 |
|
47 | 47 |
it "should require the expected_update_period_in_days" do |
48 | 48 |
@checker.options['expected_update_period_in_days'] = nil |
49 |
- @checker.should_not be_valid |
|
49 |
+ expect(@checker).not_to be_valid |
|
50 | 50 |
end |
51 | 51 |
|
52 | 52 |
it "should require timeout" do |
53 | 53 |
@checker.options['timeout'] = nil |
54 |
- @checker.should_not be_valid |
|
54 |
+ expect(@checker).not_to be_valid |
|
55 | 55 |
end |
56 | 56 |
end |
57 | 57 |
|
58 | 58 |
describe "helpers" do |
59 | 59 |
it "should generate a correct request options hash" do |
60 |
- @checker.send(:request_options).should == {:basic_auth=>{:username=>"user", :password=>"pass"}, :headers => {"User-Agent" => "Huginn (https://github.com/cantino/huginn)"}} |
|
60 |
+ expect(@checker.send(:request_options)).to eq({:basic_auth=>{:username=>"user", :password=>"pass"}, :headers => {"User-Agent" => "Huginn (https://github.com/cantino/huginn)"}}) |
|
61 | 61 |
end |
62 | 62 |
|
63 | 63 |
it "should generate a correct request url" do |
64 |
- @checker.send(:request_url, 'foo=bar', 10).should == "https://jira.atlassian.com/rest/api/2/search?jql=foo%3Dbar&fields=*all&startAt=10" |
|
64 |
+ expect(@checker.send(:request_url, 'foo=bar', 10)).to eq("https://jira.atlassian.com/rest/api/2/search?jql=foo%3Dbar&fields=*all&startAt=10") |
|
65 | 65 |
end |
66 | 66 |
|
67 | 67 |
|
@@ -102,9 +102,9 @@ describe Agents::JiraAgent do |
||
102 | 102 |
|
103 | 103 |
describe "#working?" do |
104 | 104 |
it "it is working when at least one event was emited" do |
105 |
- @checker.should_not be_working |
|
105 |
+ expect(@checker).not_to be_working |
|
106 | 106 |
@checker.check |
107 |
- @checker.reload.should be_working |
|
107 |
+ expect(@checker.reload).to be_working |
|
108 | 108 |
end |
109 | 109 |
end |
110 | 110 |
end |
@@ -41,12 +41,12 @@ describe Agents::MqttAgent do |
||
41 | 41 |
|
42 | 42 |
describe "#working?" do |
43 | 43 |
it "checks if its generating events as scheduled" do |
44 |
- @checker.should_not be_working |
|
44 |
+ expect(@checker).not_to be_working |
|
45 | 45 |
@checker.check |
46 |
- @checker.reload.should be_working |
|
46 |
+ expect(@checker.reload).to be_working |
|
47 | 47 |
three_days_from_now = 3.days.from_now |
48 | 48 |
stub(Time).now { three_days_from_now } |
49 |
- @checker.should_not be_working |
|
49 |
+ expect(@checker).not_to be_working |
|
50 | 50 |
end |
51 | 51 |
end |
52 | 52 |
end |
@@ -22,17 +22,17 @@ describe Agents::PeakDetectorAgent do |
||
22 | 22 |
events = build_events(:keys => ['count', 'filter'], |
23 | 23 |
:values => [[1, "something"], [2, "something"], [3, "else"]]) |
24 | 24 |
@agent.receive events |
25 |
- @agent.memory['data']['something'].map(&:first).should == [1, 2] |
|
26 |
- @agent.memory['data']['something'].last.last.should be_within(10).of((100 - 1).hours.ago.to_i) |
|
27 |
- @agent.memory['data']['else'].first.first.should == 3 |
|
28 |
- @agent.memory['data']['else'].first.last.should be_within(10).of((100 - 2).hours.ago.to_i) |
|
25 |
+ expect(@agent.memory['data']['something'].map(&:first)).to eq([1, 2]) |
|
26 |
+ expect(@agent.memory['data']['something'].last.last).to be_within(10).of((100 - 1).hours.ago.to_i) |
|
27 |
+ expect(@agent.memory['data']['else'].first.first).to eq(3) |
|
28 |
+ expect(@agent.memory['data']['else'].first.last).to be_within(10).of((100 - 2).hours.ago.to_i) |
|
29 | 29 |
end |
30 | 30 |
|
31 | 31 |
it "works without a group_by_path as well" do |
32 | 32 |
@agent.options['group_by_path'] = "" |
33 | 33 |
events = build_events(:keys => ['count'], :values => [[1], [2]]) |
34 | 34 |
@agent.receive events |
35 |
- @agent.memory['data']['no_group'].map(&:first).should == [1, 2] |
|
35 |
+ expect(@agent.memory['data']['no_group'].map(&:first)).to eq([1, 2]) |
|
36 | 36 |
end |
37 | 37 |
|
38 | 38 |
it "keeps a rolling window of data" do |
@@ -40,7 +40,7 @@ describe Agents::PeakDetectorAgent do |
||
40 | 40 |
@agent.receive build_events(:keys => ['count'], |
41 | 41 |
:values => [1, 2, 3, 4, 5, 6, 7, 8].map {|i| [i]}, |
42 | 42 |
:pattern => { 'filter' => "something" }) |
43 |
- @agent.memory['data']['something'].map(&:first).should == [4, 5, 6, 7, 8] |
|
43 |
+ expect(@agent.memory['data']['something'].map(&:first)).to eq([4, 5, 6, 7, 8]) |
|
44 | 44 |
end |
45 | 45 |
|
46 | 46 |
it "finds peaks" do |
@@ -52,13 +52,13 @@ describe Agents::PeakDetectorAgent do |
||
52 | 52 |
8, 50, # ignored because it's too close to the first peak |
53 | 53 |
4, 5].map {|i| [i]}, |
54 | 54 |
:pattern => { 'filter' => "something" }).each.with_index do |event, index| |
55 |
- lambda { |
|
55 |
+ expect { |
|
56 | 56 |
@agent.receive([event]) |
57 |
- }.should change { @agent.events.count }.by( index == 6 ? 1 : 0 ) |
|
57 |
+ }.to change { @agent.events.count }.by( index == 6 ? 1 : 0 ) |
|
58 | 58 |
end |
59 | 59 |
|
60 |
- @agent.events.last.payload['peak'].should == 15.0 |
|
61 |
- @agent.memory['peaks']['something'].length.should == 1 |
|
60 |
+ expect(@agent.events.last.payload['peak']).to eq(15.0) |
|
61 |
+ expect(@agent.memory['peaks']['something'].length).to eq(1) |
|
62 | 62 |
end |
63 | 63 |
|
64 | 64 |
it "keeps a rolling window of peaks" do |
@@ -66,28 +66,28 @@ describe Agents::PeakDetectorAgent do |
||
66 | 66 |
@agent.receive build_events(:keys => ['count'], |
67 | 67 |
:values => [1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 10, 1].map {|i| [i]}, |
68 | 68 |
:pattern => { 'filter' => "something" }) |
69 |
- @agent.memory['peaks']['something'].length.should == 2 |
|
69 |
+ expect(@agent.memory['peaks']['something'].length).to eq(2) |
|
70 | 70 |
end |
71 | 71 |
end |
72 | 72 |
|
73 | 73 |
describe "validation" do |
74 | 74 |
before do |
75 |
- @agent.should be_valid |
|
75 |
+ expect(@agent).to be_valid |
|
76 | 76 |
end |
77 | 77 |
|
78 | 78 |
it "should validate presence of message" do |
79 | 79 |
@agent.options['message'] = nil |
80 |
- @agent.should_not be_valid |
|
80 |
+ expect(@agent).not_to be_valid |
|
81 | 81 |
end |
82 | 82 |
|
83 | 83 |
it "should validate presence of expected_receive_period_in_days" do |
84 | 84 |
@agent.options['expected_receive_period_in_days'] = "" |
85 |
- @agent.should_not be_valid |
|
85 |
+ expect(@agent).not_to be_valid |
|
86 | 86 |
end |
87 | 87 |
|
88 | 88 |
it "should validate presence of value_path" do |
89 | 89 |
@agent.options['value_path'] = "" |
90 |
- @agent.should_not be_valid |
|
90 |
+ expect(@agent).not_to be_valid |
|
91 | 91 |
end |
92 | 92 |
end |
93 | 93 |
end |
@@ -57,10 +57,10 @@ describe Agents::PostAgent do |
||
57 | 57 |
it "can make requests of each type" do |
58 | 58 |
%w[get put post patch delete].each.with_index(1) do |verb, index| |
59 | 59 |
@checker.options['method'] = verb |
60 |
- @checker.should be_valid |
|
60 |
+ expect(@checker).to be_valid |
|
61 | 61 |
@checker.check |
62 |
- @requests.should == index |
|
63 |
- @sent_requests[verb.to_sym].length.should == 1 |
|
62 |
+ expect(@requests).to eq(index) |
|
63 |
+ expect(@sent_requests[verb.to_sym].length).to eq(1) |
|
64 | 64 |
end |
65 | 65 |
end |
66 | 66 |
end |
@@ -75,26 +75,26 @@ describe Agents::PostAgent do |
||
75 | 75 |
'default' => 'value2' |
76 | 76 |
} |
77 | 77 |
|
78 |
- lambda { |
|
79 |
- lambda { |
|
78 |
+ expect { |
|
79 |
+ expect { |
|
80 | 80 |
@checker.receive([@event, event1]) |
81 |
- }.should change { @sent_requests[:post].length }.by(2) |
|
82 |
- }.should_not change { @sent_requests[:get].length } |
|
81 |
+ }.to change { @sent_requests[:post].length }.by(2) |
|
82 |
+ }.not_to change { @sent_requests[:get].length } |
|
83 | 83 |
|
84 |
- @sent_requests[:post][0].data.should == @event.payload.merge('default' => 'value').to_query |
|
85 |
- @sent_requests[:post][1].data.should == event1.payload.to_query |
|
84 |
+ expect(@sent_requests[:post][0].data).to eq(@event.payload.merge('default' => 'value').to_query) |
|
85 |
+ expect(@sent_requests[:post][1].data).to eq(event1.payload.to_query) |
|
86 | 86 |
end |
87 | 87 |
|
88 | 88 |
it "can make GET requests" do |
89 | 89 |
@checker.options['method'] = 'get' |
90 | 90 |
|
91 |
- lambda { |
|
92 |
- lambda { |
|
91 |
+ expect { |
|
92 |
+ expect { |
|
93 | 93 |
@checker.receive([@event]) |
94 |
- }.should change { @sent_requests[:get].length }.by(1) |
|
95 |
- }.should_not change { @sent_requests[:post].length } |
|
94 |
+ }.to change { @sent_requests[:get].length }.by(1) |
|
95 |
+ }.not_to change { @sent_requests[:post].length } |
|
96 | 96 |
|
97 |
- @sent_requests[:get][0].data.should == @event.payload.merge('default' => 'value').to_query |
|
97 |
+ expect(@sent_requests[:get][0].data).to eq(@event.payload.merge('default' => 'value').to_query) |
|
98 | 98 |
end |
99 | 99 |
|
100 | 100 |
it "can make a GET request merging params in post_url, payload and event" do |
@@ -107,7 +107,7 @@ describe Agents::PostAgent do |
||
107 | 107 |
@checker.receive([@event]) |
108 | 108 |
uri = @sent_requests[:get].first.uri |
109 | 109 |
# parameters are alphabetically sorted by Faraday |
110 |
- uri.request_uri.should == "/a/path?another_param=another_value&default=value&existing_param=existing_value&some_param=some_value" |
|
110 |
+ expect(uri.request_uri).to eq("/a/path?another_param=another_value&default=value&existing_param=existing_value&some_param=some_value") |
|
111 | 111 |
end |
112 | 112 |
|
113 | 113 |
it "can skip merging the incoming event when no_merge is set, but it still interpolates" do |
@@ -116,7 +116,7 @@ describe Agents::PostAgent do |
||
116 | 116 |
'key' => 'it said: {{ someotherkey.somekey }}' |
117 | 117 |
} |
118 | 118 |
@checker.receive([@event]) |
119 |
- @sent_requests[:post].first.data.should == { 'key' => 'it said: value' }.to_query |
|
119 |
+ expect(@sent_requests[:post].first.data).to eq({ 'key' => 'it said: value' }.to_query) |
|
120 | 120 |
end |
121 | 121 |
|
122 | 122 |
it "interpolates when receiving a payload" do |
@@ -127,140 +127,140 @@ describe Agents::PostAgent do |
||
127 | 127 |
} |
128 | 128 |
@checker.receive([@event]) |
129 | 129 |
uri = @sent_requests[:post].first.uri |
130 |
- uri.scheme.should == 'https' |
|
131 |
- uri.host.should == 'google.com' |
|
132 |
- uri.path.should == '/a_variable' |
|
133 |
- uri.query.should == "existing_param=existing_value" |
|
130 |
+ expect(uri.scheme).to eq('https') |
|
131 |
+ expect(uri.host).to eq('google.com') |
|
132 |
+ expect(uri.path).to eq('/a_variable') |
|
133 |
+ expect(uri.query).to eq("existing_param=existing_value") |
|
134 | 134 |
end |
135 | 135 |
end |
136 | 136 |
|
137 | 137 |
describe "#check" do |
138 | 138 |
it "sends options['payload'] as a POST request" do |
139 |
- lambda { |
|
139 |
+ expect { |
|
140 | 140 |
@checker.check |
141 |
- }.should change { @sent_requests[:post].length }.by(1) |
|
141 |
+ }.to change { @sent_requests[:post].length }.by(1) |
|
142 | 142 |
|
143 |
- @sent_requests[:post][0].data.should == @checker.options['payload'].to_query |
|
143 |
+ expect(@sent_requests[:post][0].data).to eq(@checker.options['payload'].to_query) |
|
144 | 144 |
end |
145 | 145 |
|
146 | 146 |
it "sends options['payload'] as JSON as a POST request" do |
147 | 147 |
@checker.options['content_type'] = 'json' |
148 |
- lambda { |
|
148 |
+ expect { |
|
149 | 149 |
@checker.check |
150 |
- }.should change { @sent_requests[:post].length }.by(1) |
|
150 |
+ }.to change { @sent_requests[:post].length }.by(1) |
|
151 | 151 |
|
152 |
- @sent_requests[:post][0].data.should == @checker.options['payload'] |
|
152 |
+ expect(@sent_requests[:post][0].data).to eq(@checker.options['payload']) |
|
153 | 153 |
end |
154 | 154 |
|
155 | 155 |
it "sends options['payload'] as a GET request" do |
156 | 156 |
@checker.options['method'] = 'get' |
157 |
- lambda { |
|
158 |
- lambda { |
|
157 |
+ expect { |
|
158 |
+ expect { |
|
159 | 159 |
@checker.check |
160 |
- }.should change { @sent_requests[:get].length }.by(1) |
|
161 |
- }.should_not change { @sent_requests[:post].length } |
|
160 |
+ }.to change { @sent_requests[:get].length }.by(1) |
|
161 |
+ }.not_to change { @sent_requests[:post].length } |
|
162 | 162 |
|
163 |
- @sent_requests[:get][0].data.should == @checker.options['payload'].to_query |
|
163 |
+ expect(@sent_requests[:get][0].data).to eq(@checker.options['payload'].to_query) |
|
164 | 164 |
end |
165 | 165 |
end |
166 | 166 |
|
167 | 167 |
describe "#working?" do |
168 | 168 |
it "checks if events have been received within expected receive period" do |
169 |
- @checker.should_not be_working |
|
169 |
+ expect(@checker).not_to be_working |
|
170 | 170 |
Agents::PostAgent.async_receive @checker.id, [@event.id] |
171 |
- @checker.reload.should be_working |
|
171 |
+ expect(@checker.reload).to be_working |
|
172 | 172 |
two_days_from_now = 2.days.from_now |
173 | 173 |
stub(Time).now { two_days_from_now } |
174 |
- @checker.reload.should_not be_working |
|
174 |
+ expect(@checker.reload).not_to be_working |
|
175 | 175 |
end |
176 | 176 |
end |
177 | 177 |
|
178 | 178 |
describe "validation" do |
179 | 179 |
before do |
180 |
- @checker.should be_valid |
|
180 |
+ expect(@checker).to be_valid |
|
181 | 181 |
end |
182 | 182 |
|
183 | 183 |
it "should validate presence of post_url" do |
184 | 184 |
@checker.options['post_url'] = "" |
185 |
- @checker.should_not be_valid |
|
185 |
+ expect(@checker).not_to be_valid |
|
186 | 186 |
end |
187 | 187 |
|
188 | 188 |
it "should validate presence of expected_receive_period_in_days" do |
189 | 189 |
@checker.options['expected_receive_period_in_days'] = "" |
190 |
- @checker.should_not be_valid |
|
190 |
+ expect(@checker).not_to be_valid |
|
191 | 191 |
end |
192 | 192 |
|
193 | 193 |
it "should validate method as post, get, put, patch, or delete, defaulting to post" do |
194 | 194 |
@checker.options['method'] = "" |
195 |
- @checker.method.should == "post" |
|
196 |
- @checker.should be_valid |
|
195 |
+ expect(@checker.method).to eq("post") |
|
196 |
+ expect(@checker).to be_valid |
|
197 | 197 |
|
198 | 198 |
@checker.options['method'] = "POST" |
199 |
- @checker.method.should == "post" |
|
200 |
- @checker.should be_valid |
|
199 |
+ expect(@checker.method).to eq("post") |
|
200 |
+ expect(@checker).to be_valid |
|
201 | 201 |
|
202 | 202 |
@checker.options['method'] = "get" |
203 |
- @checker.method.should == "get" |
|
204 |
- @checker.should be_valid |
|
203 |
+ expect(@checker.method).to eq("get") |
|
204 |
+ expect(@checker).to be_valid |
|
205 | 205 |
|
206 | 206 |
@checker.options['method'] = "patch" |
207 |
- @checker.method.should == "patch" |
|
208 |
- @checker.should be_valid |
|
207 |
+ expect(@checker.method).to eq("patch") |
|
208 |
+ expect(@checker).to be_valid |
|
209 | 209 |
|
210 | 210 |
@checker.options['method'] = "wut" |
211 |
- @checker.method.should == "wut" |
|
212 |
- @checker.should_not be_valid |
|
211 |
+ expect(@checker.method).to eq("wut") |
|
212 |
+ expect(@checker).not_to be_valid |
|
213 | 213 |
end |
214 | 214 |
|
215 | 215 |
it "should validate that no_merge is 'true' or 'false', if present" do |
216 | 216 |
@checker.options['no_merge'] = "" |
217 |
- @checker.should be_valid |
|
217 |
+ expect(@checker).to be_valid |
|
218 | 218 |
|
219 | 219 |
@checker.options['no_merge'] = "true" |
220 |
- @checker.should be_valid |
|
220 |
+ expect(@checker).to be_valid |
|
221 | 221 |
|
222 | 222 |
@checker.options['no_merge'] = "false" |
223 |
- @checker.should be_valid |
|
223 |
+ expect(@checker).to be_valid |
|
224 | 224 |
|
225 | 225 |
@checker.options['no_merge'] = false |
226 |
- @checker.should be_valid |
|
226 |
+ expect(@checker).to be_valid |
|
227 | 227 |
|
228 | 228 |
@checker.options['no_merge'] = true |
229 |
- @checker.should be_valid |
|
229 |
+ expect(@checker).to be_valid |
|
230 | 230 |
|
231 | 231 |
@checker.options['no_merge'] = 'blarg' |
232 |
- @checker.should_not be_valid |
|
232 |
+ expect(@checker).not_to be_valid |
|
233 | 233 |
end |
234 | 234 |
|
235 | 235 |
it "should validate payload as a hash, if present" do |
236 | 236 |
@checker.options['payload'] = "" |
237 |
- @checker.should be_valid |
|
237 |
+ expect(@checker).to be_valid |
|
238 | 238 |
|
239 | 239 |
@checker.options['payload'] = "hello" |
240 |
- @checker.should_not be_valid |
|
240 |
+ expect(@checker).not_to be_valid |
|
241 | 241 |
|
242 | 242 |
@checker.options['payload'] = ["foo", "bar"] |
243 |
- @checker.should_not be_valid |
|
243 |
+ expect(@checker).not_to be_valid |
|
244 | 244 |
|
245 | 245 |
@checker.options['payload'] = { 'this' => 'that' } |
246 |
- @checker.should be_valid |
|
246 |
+ expect(@checker).to be_valid |
|
247 | 247 |
end |
248 | 248 |
|
249 | 249 |
it "requires headers to be a hash, if present" do |
250 | 250 |
@checker.options['headers'] = [1,2,3] |
251 |
- @checker.should_not be_valid |
|
251 |
+ expect(@checker).not_to be_valid |
|
252 | 252 |
|
253 | 253 |
@checker.options['headers'] = "hello world" |
254 |
- @checker.should_not be_valid |
|
254 |
+ expect(@checker).not_to be_valid |
|
255 | 255 |
|
256 | 256 |
@checker.options['headers'] = "" |
257 |
- @checker.should be_valid |
|
257 |
+ expect(@checker).to be_valid |
|
258 | 258 |
|
259 | 259 |
@checker.options['headers'] = {} |
260 |
- @checker.should be_valid |
|
260 |
+ expect(@checker).to be_valid |
|
261 | 261 |
|
262 | 262 |
@checker.options['headers'] = { "Authorization" => "foo bar" } |
263 |
- @checker.should be_valid |
|
263 |
+ expect(@checker).to be_valid |
|
264 | 264 |
end |
265 | 265 |
end |
266 | 266 |
end |
@@ -22,36 +22,36 @@ describe Agents::PublicTransportAgent do |
||
22 | 22 |
end |
23 | 23 |
|
24 | 24 |
it "should create 4 events" do |
25 |
- lambda { @agent.check }.should change {@agent.events.count}.by(4) |
|
25 |
+ expect { @agent.check }.to change {@agent.events.count}.by(4) |
|
26 | 26 |
end |
27 | 27 |
|
28 | 28 |
it "should add 4 items to memory" do |
29 | 29 |
time_travel_to Time.parse("2014-01-14 20:21:30 +0500") do |
30 |
- @agent.memory.should == {} |
|
30 |
+ expect(@agent.memory).to eq({}) |
|
31 | 31 |
@agent.check |
32 | 32 |
@agent.save |
33 |
- @agent.reload.memory.should == {"existing_routes" => [ |
|
33 |
+ expect(@agent.reload.memory).to eq({"existing_routes" => [ |
|
34 | 34 |
{"stopTag"=>"5221", "tripTag"=>"5840324", "epochTime"=>"1389706393991", "currentTime"=>Time.now.to_s}, |
35 | 35 |
{"stopTag"=>"5221", "tripTag"=>"5840083", "epochTime"=>"1389706512784", "currentTime"=>Time.now.to_s}, |
36 | 36 |
{"stopTag"=>"5215", "tripTag"=>"5840324", "epochTime"=>"1389706282012", "currentTime"=>Time.now.to_s}, |
37 | 37 |
{"stopTag"=>"5215", "tripTag"=>"5840083", "epochTime"=>"1389706400805", "currentTime"=>Time.now.to_s} |
38 | 38 |
] |
39 |
- } |
|
39 |
+ }) |
|
40 | 40 |
end |
41 | 41 |
end |
42 | 42 |
|
43 | 43 |
it "should not create events twice" do |
44 |
- lambda { @agent.check }.should change {@agent.events.count}.by(4) |
|
45 |
- lambda { @agent.check }.should_not change {@agent.events.count} |
|
44 |
+ expect { @agent.check }.to change {@agent.events.count}.by(4) |
|
45 |
+ expect { @agent.check }.not_to change {@agent.events.count} |
|
46 | 46 |
end |
47 | 47 |
|
48 | 48 |
it "should reset memory after 2 hours" do |
49 | 49 |
time_travel_to Time.parse("2014-01-14 20:21:30 +0500") do |
50 |
- lambda { @agent.check }.should change {@agent.events.count}.by(4) |
|
50 |
+ expect { @agent.check }.to change {@agent.events.count}.by(4) |
|
51 | 51 |
end |
52 | 52 |
time_travel_to "2014-01-14 23:21:30 +0500".to_time do |
53 | 53 |
@agent.cleanup_old_memory |
54 |
- lambda { @agent.check }.should change {@agent.events.count}.by(4) |
|
54 |
+ expect { @agent.check }.to change {@agent.events.count}.by(4) |
|
55 | 55 |
end |
56 | 56 |
end |
57 | 57 |
end |
@@ -59,17 +59,17 @@ describe Agents::PublicTransportAgent do |
||
59 | 59 |
describe "validation" do |
60 | 60 |
it "should validate presence of stops" do |
61 | 61 |
@agent.options['stops'] = nil |
62 |
- @agent.should_not be_valid |
|
62 |
+ expect(@agent).not_to be_valid |
|
63 | 63 |
end |
64 | 64 |
|
65 | 65 |
it "should validate presence of agency" do |
66 | 66 |
@agent.options['agency'] = "" |
67 |
- @agent.should_not be_valid |
|
67 |
+ expect(@agent).not_to be_valid |
|
68 | 68 |
end |
69 | 69 |
|
70 | 70 |
it "should validate presence of alert_window_in_minutes" do |
71 | 71 |
@agent.options['alert_window_in_minutes'] = "" |
72 |
- @agent.should_not be_valid |
|
72 |
+ expect(@agent).not_to be_valid |
|
73 | 73 |
end |
74 | 74 |
end |
75 | 75 |
end |
@@ -21,26 +21,26 @@ describe Agents::PushbulletAgent do |
||
21 | 21 |
|
22 | 22 |
describe "validating" do |
23 | 23 |
before do |
24 |
- @checker.should be_valid |
|
24 |
+ expect(@checker).to be_valid |
|
25 | 25 |
end |
26 | 26 |
|
27 | 27 |
it "should require the api_key" do |
28 | 28 |
@checker.options['api_key'] = nil |
29 |
- @checker.should_not be_valid |
|
29 |
+ expect(@checker).not_to be_valid |
|
30 | 30 |
end |
31 | 31 |
|
32 | 32 |
it "should require the device_id" do |
33 | 33 |
@checker.options['device_id'] = nil |
34 |
- @checker.should_not be_valid |
|
34 |
+ expect(@checker).not_to be_valid |
|
35 | 35 |
end |
36 | 36 |
end |
37 | 37 |
|
38 | 38 |
describe "helpers" do |
39 | 39 |
it "should return the query_options" do |
40 |
- @checker.send(:query_options, @event).should == { |
|
40 |
+ expect(@checker.send(:query_options, @event)).to eq({ |
|
41 | 41 |
:body => {:title => 'hello from huginn', :body => 'One two test', :device_iden => @checker.options[:device_id], :type => 'note'}, |
42 | 42 |
:basic_auth => {:username =>@checker.options[:api_key], :password=>''} |
43 |
- } |
|
43 |
+ }) |
|
44 | 44 |
end |
45 | 45 |
end |
46 | 46 |
|
@@ -64,9 +64,9 @@ describe Agents::PushbulletAgent do |
||
64 | 64 |
|
65 | 65 |
describe "#working?" do |
66 | 66 |
it "should not be working until the first event was received" do |
67 |
- @checker.should_not be_working |
|
67 |
+ expect(@checker).not_to be_working |
|
68 | 68 |
@checker.last_receive_at = Time.now |
69 |
- @checker.should be_working |
|
69 |
+ expect(@checker).to be_working |
|
70 | 70 |
end |
71 | 71 |
end |
72 | 72 |
end |
@@ -42,9 +42,9 @@ describe Agents::PushoverAgent do |
||
42 | 42 |
event2.save! |
43 | 43 |
|
44 | 44 |
@checker.receive([@event,event1,event2]) |
45 |
- @sent_notifications[0]['message'].should == 'Looks like its going to rain' |
|
46 |
- @sent_notifications[1]['message'].should == 'Some message' |
|
47 |
- @sent_notifications[2]['message'].should == 'Some other message' |
|
45 |
+ expect(@sent_notifications[0]['message']).to eq('Looks like its going to rain') |
|
46 |
+ expect(@sent_notifications[1]['message']).to eq('Some message') |
|
47 |
+ expect(@sent_notifications[2]['message']).to eq('Some other message') |
|
48 | 48 |
end |
49 | 49 |
|
50 | 50 |
it 'should make sure event message overrides default message' do |
@@ -54,7 +54,7 @@ describe Agents::PushoverAgent do |
||
54 | 54 |
event.save! |
55 | 55 |
|
56 | 56 |
@checker.receive([event]) |
57 |
- @sent_notifications[0]['message'].should == 'Some new message' |
|
57 |
+ expect(@sent_notifications[0]['message']).to eq('Some new message') |
|
58 | 58 |
end |
59 | 59 |
|
60 | 60 |
it 'should make sure event text overrides default message' do |
@@ -64,7 +64,7 @@ describe Agents::PushoverAgent do |
||
64 | 64 |
event.save! |
65 | 65 |
|
66 | 66 |
@checker.receive([event]) |
67 |
- @sent_notifications[0]['message'].should == 'Some new text' |
|
67 |
+ expect(@sent_notifications[0]['message']).to eq('Some new text') |
|
68 | 68 |
end |
69 | 69 |
|
70 | 70 |
it 'should make sure event title overrides default title' do |
@@ -74,7 +74,7 @@ describe Agents::PushoverAgent do |
||
74 | 74 |
event.save! |
75 | 75 |
|
76 | 76 |
@checker.receive([event]) |
77 |
- @sent_notifications[0]['title'].should == 'Some new title' |
|
77 |
+ expect(@sent_notifications[0]['title']).to eq('Some new title') |
|
78 | 78 |
end |
79 | 79 |
|
80 | 80 |
it 'should make sure event url overrides default url' do |
@@ -84,7 +84,7 @@ describe Agents::PushoverAgent do |
||
84 | 84 |
event.save! |
85 | 85 |
|
86 | 86 |
@checker.receive([event]) |
87 |
- @sent_notifications[0]['url'].should == 'Some new url' |
|
87 |
+ expect(@sent_notifications[0]['url']).to eq('Some new url') |
|
88 | 88 |
end |
89 | 89 |
|
90 | 90 |
it 'should make sure event url_title overrides default url_title' do |
@@ -94,7 +94,7 @@ describe Agents::PushoverAgent do |
||
94 | 94 |
event.save! |
95 | 95 |
|
96 | 96 |
@checker.receive([event]) |
97 |
- @sent_notifications[0]['url_title'].should == 'Some new url_title' |
|
97 |
+ expect(@sent_notifications[0]['url_title']).to eq('Some new url_title') |
|
98 | 98 |
end |
99 | 99 |
|
100 | 100 |
it 'should make sure event priority overrides default priority' do |
@@ -104,7 +104,7 @@ describe Agents::PushoverAgent do |
||
104 | 104 |
event.save! |
105 | 105 |
|
106 | 106 |
@checker.receive([event]) |
107 |
- @sent_notifications[0]['priority'].should == 1 |
|
107 |
+ expect(@sent_notifications[0]['priority']).to eq(1) |
|
108 | 108 |
end |
109 | 109 |
|
110 | 110 |
it 'should make sure event timestamp overrides default timestamp' do |
@@ -114,7 +114,7 @@ describe Agents::PushoverAgent do |
||
114 | 114 |
event.save! |
115 | 115 |
|
116 | 116 |
@checker.receive([event]) |
117 |
- @sent_notifications[0]['timestamp'].should == 'false' |
|
117 |
+ expect(@sent_notifications[0]['timestamp']).to eq('false') |
|
118 | 118 |
end |
119 | 119 |
|
120 | 120 |
it 'should make sure event sound overrides default sound' do |
@@ -124,7 +124,7 @@ describe Agents::PushoverAgent do |
||
124 | 124 |
event.save! |
125 | 125 |
|
126 | 126 |
@checker.receive([event]) |
127 |
- @sent_notifications[0]['sound'].should == 'Some new sound' |
|
127 |
+ expect(@sent_notifications[0]['sound']).to eq('Some new sound') |
|
128 | 128 |
end |
129 | 129 |
|
130 | 130 |
it 'should make sure event retry overrides default retry' do |
@@ -134,7 +134,7 @@ describe Agents::PushoverAgent do |
||
134 | 134 |
event.save! |
135 | 135 |
|
136 | 136 |
@checker.receive([event]) |
137 |
- @sent_notifications[0]['retry'].should == 1 |
|
137 |
+ expect(@sent_notifications[0]['retry']).to eq(1) |
|
138 | 138 |
end |
139 | 139 |
|
140 | 140 |
it 'should make sure event expire overrides default expire' do |
@@ -144,79 +144,79 @@ describe Agents::PushoverAgent do |
||
144 | 144 |
event.save! |
145 | 145 |
|
146 | 146 |
@checker.receive([event]) |
147 |
- @sent_notifications[0]['expire'].should == 60 |
|
147 |
+ expect(@sent_notifications[0]['expire']).to eq(60) |
|
148 | 148 |
end |
149 | 149 |
end |
150 | 150 |
|
151 | 151 |
describe '#working?' do |
152 | 152 |
it 'checks if events have been received within the expected receive period' do |
153 | 153 |
# No events received |
154 |
- @checker.should_not be_working |
|
154 |
+ expect(@checker).not_to be_working |
|
155 | 155 |
Agents::PushoverAgent.async_receive @checker.id, [@event.id] |
156 | 156 |
|
157 | 157 |
# Just received events |
158 |
- @checker.reload.should be_working |
|
158 |
+ expect(@checker.reload).to be_working |
|
159 | 159 |
two_days_from_now = 2.days.from_now |
160 | 160 |
stub(Time).now { two_days_from_now } |
161 | 161 |
|
162 | 162 |
# More time has passed than the expected receive period without any new events |
163 |
- @checker.reload.should_not be_working |
|
163 |
+ expect(@checker.reload).not_to be_working |
|
164 | 164 |
end |
165 | 165 |
end |
166 | 166 |
|
167 | 167 |
describe "validation" do |
168 | 168 |
before do |
169 |
- @checker.should be_valid |
|
169 |
+ expect(@checker).to be_valid |
|
170 | 170 |
end |
171 | 171 |
|
172 | 172 |
it "should validate presence of token" do |
173 | 173 |
@checker.options[:token] = "" |
174 |
- @checker.should_not be_valid |
|
174 |
+ expect(@checker).not_to be_valid |
|
175 | 175 |
end |
176 | 176 |
|
177 | 177 |
it "should validate presence of user" do |
178 | 178 |
@checker.options[:user] = "" |
179 |
- @checker.should_not be_valid |
|
179 |
+ expect(@checker).not_to be_valid |
|
180 | 180 |
end |
181 | 181 |
|
182 | 182 |
it "should validate presence of expected_receive_period_in_days" do |
183 | 183 |
@checker.options[:expected_receive_period_in_days] = "" |
184 |
- @checker.should_not be_valid |
|
184 |
+ expect(@checker).not_to be_valid |
|
185 | 185 |
end |
186 | 186 |
|
187 | 187 |
it "should make sure device is optional" do |
188 | 188 |
@checker.options[:device] = "" |
189 |
- @checker.should be_valid |
|
189 |
+ expect(@checker).to be_valid |
|
190 | 190 |
end |
191 | 191 |
|
192 | 192 |
it "should make sure title is optional" do |
193 | 193 |
@checker.options[:title] = "" |
194 |
- @checker.should be_valid |
|
194 |
+ expect(@checker).to be_valid |
|
195 | 195 |
end |
196 | 196 |
|
197 | 197 |
it "should make sure url is optional" do |
198 | 198 |
@checker.options[:url] = "" |
199 |
- @checker.should be_valid |
|
199 |
+ expect(@checker).to be_valid |
|
200 | 200 |
end |
201 | 201 |
|
202 | 202 |
it "should make sure url_title is optional" do |
203 | 203 |
@checker.options[:url_title] = "" |
204 |
- @checker.should be_valid |
|
204 |
+ expect(@checker).to be_valid |
|
205 | 205 |
end |
206 | 206 |
|
207 | 207 |
it "should make sure priority is optional" do |
208 | 208 |
@checker.options[:priority] = "" |
209 |
- @checker.should be_valid |
|
209 |
+ expect(@checker).to be_valid |
|
210 | 210 |
end |
211 | 211 |
|
212 | 212 |
it "should make sure timestamp is optional" do |
213 | 213 |
@checker.options[:timestamp] = "" |
214 |
- @checker.should be_valid |
|
214 |
+ expect(@checker).to be_valid |
|
215 | 215 |
end |
216 | 216 |
|
217 | 217 |
it "should make sure sound is optional" do |
218 | 218 |
@checker.options[:sound] = "" |
219 |
- @checker.should be_valid |
|
219 |
+ expect(@checker).to be_valid |
|
220 | 220 |
end |
221 | 221 |
end |
222 | 222 |
end |
@@ -23,60 +23,60 @@ describe Agents::RssAgent do |
||
23 | 23 |
describe "validations" do |
24 | 24 |
it "should validate the presence of url" do |
25 | 25 |
agent.options['url'] = "http://google.com" |
26 |
- agent.should be_valid |
|
26 |
+ expect(agent).to be_valid |
|
27 | 27 |
|
28 | 28 |
agent.options['url'] = "" |
29 |
- agent.should_not be_valid |
|
29 |
+ expect(agent).not_to be_valid |
|
30 | 30 |
|
31 | 31 |
agent.options['url'] = nil |
32 |
- agent.should_not be_valid |
|
32 |
+ expect(agent).not_to be_valid |
|
33 | 33 |
end |
34 | 34 |
|
35 | 35 |
it "should validate the presence and numericality of expected_update_period_in_days" do |
36 | 36 |
agent.options['expected_update_period_in_days'] = "5" |
37 |
- agent.should be_valid |
|
37 |
+ expect(agent).to be_valid |
|
38 | 38 |
|
39 | 39 |
agent.options['expected_update_period_in_days'] = "wut?" |
40 |
- agent.should_not be_valid |
|
40 |
+ expect(agent).not_to be_valid |
|
41 | 41 |
|
42 | 42 |
agent.options['expected_update_period_in_days'] = 0 |
43 |
- agent.should_not be_valid |
|
43 |
+ expect(agent).not_to be_valid |
|
44 | 44 |
|
45 | 45 |
agent.options['expected_update_period_in_days'] = nil |
46 |
- agent.should_not be_valid |
|
46 |
+ expect(agent).not_to be_valid |
|
47 | 47 |
|
48 | 48 |
agent.options['expected_update_period_in_days'] = "" |
49 |
- agent.should_not be_valid |
|
49 |
+ expect(agent).not_to be_valid |
|
50 | 50 |
end |
51 | 51 |
end |
52 | 52 |
|
53 | 53 |
describe "emitting RSS events" do |
54 | 54 |
it "should emit items as events" do |
55 |
- lambda { |
|
55 |
+ expect { |
|
56 | 56 |
agent.check |
57 |
- }.should change { agent.events.count }.by(20) |
|
57 |
+ }.to change { agent.events.count }.by(20) |
|
58 | 58 |
end |
59 | 59 |
|
60 | 60 |
it "should track ids and not re-emit the same item when seen again" do |
61 | 61 |
agent.check |
62 |
- agent.memory['seen_ids'].should == agent.events.map {|e| e.payload['id'] } |
|
62 |
+ expect(agent.memory['seen_ids']).to eq(agent.events.map {|e| e.payload['id'] }) |
|
63 | 63 |
|
64 | 64 |
newest_id = agent.memory['seen_ids'][0] |
65 |
- agent.events.first.payload['id'].should == newest_id |
|
65 |
+ expect(agent.events.first.payload['id']).to eq(newest_id) |
|
66 | 66 |
agent.memory['seen_ids'] = agent.memory['seen_ids'][1..-1] # forget the newest id |
67 | 67 |
|
68 |
- lambda { |
|
68 |
+ expect { |
|
69 | 69 |
agent.check |
70 |
- }.should change { agent.events.count }.by(1) |
|
70 |
+ }.to change { agent.events.count }.by(1) |
|
71 | 71 |
|
72 |
- agent.events.first.payload['id'].should == newest_id |
|
73 |
- agent.memory['seen_ids'][0].should == newest_id |
|
72 |
+ expect(agent.events.first.payload['id']).to eq(newest_id) |
|
73 |
+ expect(agent.memory['seen_ids'][0]).to eq(newest_id) |
|
74 | 74 |
end |
75 | 75 |
|
76 | 76 |
it "should truncate the seen_ids in memory at 500 items" do |
77 | 77 |
agent.memory['seen_ids'] = ['x'] * 490 |
78 | 78 |
agent.check |
79 |
- agent.memory['seen_ids'].length.should == 500 |
|
79 |
+ expect(agent.memory['seen_ids'].length).to eq(500) |
|
80 | 80 |
end |
81 | 81 |
end |
82 | 82 |
|
@@ -86,10 +86,10 @@ describe Agents::RssAgent do |
||
86 | 86 |
end |
87 | 87 |
|
88 | 88 |
it "calculates content MD5 sums" do |
89 |
- lambda { |
|
89 |
+ expect { |
|
90 | 90 |
agent.check |
91 |
- }.should change { agent.events.count }.by(79) |
|
92 |
- agent.memory['seen_ids'].should == agent.events.map {|e| Digest::MD5.hexdigest(e.payload['content']) } |
|
91 |
+ }.to change { agent.events.count }.by(79) |
|
92 |
+ expect(agent.memory['seen_ids']).to eq(agent.events.map {|e| Digest::MD5.hexdigest(e.payload['content']) }) |
|
93 | 93 |
end |
94 | 94 |
end |
95 | 95 |
end |
@@ -11,58 +11,58 @@ describe Agents::SchedulerAgent do |
||
11 | 11 |
it "should validate action" do |
12 | 12 |
['run', 'enable', 'disable', '', nil].each { |action| |
13 | 13 |
@agent.options['action'] = action |
14 |
- @agent.should be_valid |
|
14 |
+ expect(@agent).to be_valid |
|
15 | 15 |
} |
16 | 16 |
|
17 | 17 |
['delete', 1, true].each { |action| |
18 | 18 |
@agent.options['action'] = action |
19 |
- @agent.should_not be_valid |
|
19 |
+ expect(@agent).not_to be_valid |
|
20 | 20 |
} |
21 | 21 |
end |
22 | 22 |
|
23 | 23 |
it "should validate schedule" do |
24 |
- @agent.should be_valid |
|
24 |
+ expect(@agent).to be_valid |
|
25 | 25 |
|
26 | 26 |
@agent.options.delete('schedule') |
27 |
- @agent.should_not be_valid |
|
27 |
+ expect(@agent).not_to be_valid |
|
28 | 28 |
|
29 | 29 |
@agent.options['schedule'] = nil |
30 |
- @agent.should_not be_valid |
|
30 |
+ expect(@agent).not_to be_valid |
|
31 | 31 |
|
32 | 32 |
@agent.options['schedule'] = '' |
33 |
- @agent.should_not be_valid |
|
33 |
+ expect(@agent).not_to be_valid |
|
34 | 34 |
|
35 | 35 |
@agent.options['schedule'] = '0' |
36 |
- @agent.should_not be_valid |
|
36 |
+ expect(@agent).not_to be_valid |
|
37 | 37 |
|
38 | 38 |
@agent.options['schedule'] = '*/15 * * * * * *' |
39 |
- @agent.should_not be_valid |
|
39 |
+ expect(@agent).not_to be_valid |
|
40 | 40 |
|
41 | 41 |
@agent.options['schedule'] = '*/1 * * * *' |
42 |
- @agent.should be_valid |
|
42 |
+ expect(@agent).to be_valid |
|
43 | 43 |
|
44 | 44 |
@agent.options['schedule'] = '*/1 * * *' |
45 |
- @agent.should_not be_valid |
|
45 |
+ expect(@agent).not_to be_valid |
|
46 | 46 |
|
47 | 47 |
stub(@agent).second_precision_enabled { true } |
48 | 48 |
@agent.options['schedule'] = '*/15 * * * * *' |
49 |
- @agent.should be_valid |
|
49 |
+ expect(@agent).to be_valid |
|
50 | 50 |
|
51 | 51 |
stub(@agent).second_precision_enabled { false } |
52 | 52 |
@agent.options['schedule'] = '*/10 * * * * *' |
53 |
- @agent.should_not be_valid |
|
53 |
+ expect(@agent).not_to be_valid |
|
54 | 54 |
|
55 | 55 |
@agent.options['schedule'] = '5/30 * * * * *' |
56 |
- @agent.should_not be_valid |
|
56 |
+ expect(@agent).not_to be_valid |
|
57 | 57 |
|
58 | 58 |
@agent.options['schedule'] = '*/15 * * * * *' |
59 |
- @agent.should be_valid |
|
59 |
+ expect(@agent).to be_valid |
|
60 | 60 |
|
61 | 61 |
@agent.options['schedule'] = '15,45 * * * * *' |
62 |
- @agent.should be_valid |
|
62 |
+ expect(@agent).to be_valid |
|
63 | 63 |
|
64 | 64 |
@agent.options['schedule'] = '0 * * * * *' |
65 |
- @agent.should be_valid |
|
65 |
+ expect(@agent).to be_valid |
|
66 | 66 |
end |
67 | 67 |
end |
68 | 68 |
|
@@ -70,26 +70,26 @@ describe Agents::SchedulerAgent do |
||
70 | 70 |
it "should be one of the supported values" do |
71 | 71 |
['run', '', nil].each { |action| |
72 | 72 |
@agent.options['action'] = action |
73 |
- @agent.control_action.should == 'run' |
|
73 |
+ expect(@agent.control_action).to eq('run') |
|
74 | 74 |
} |
75 | 75 |
|
76 | 76 |
['enable', 'disable'].each { |action| |
77 | 77 |
@agent.options['action'] = action |
78 |
- @agent.control_action.should == action |
|
78 |
+ expect(@agent.control_action).to eq(action) |
|
79 | 79 |
} |
80 | 80 |
end |
81 | 81 |
|
82 | 82 |
it "cannot be 'run' if any of the control targets cannot be scheduled" do |
83 |
- @agent.control_action.should == 'run' |
|
83 |
+ expect(@agent.control_action).to eq('run') |
|
84 | 84 |
@agent.control_targets = [agents(:bob_rain_notifier_agent)] |
85 |
- @agent.should_not be_valid |
|
85 |
+ expect(@agent).not_to be_valid |
|
86 | 86 |
end |
87 | 87 |
|
88 | 88 |
it "can be 'enable' or 'disable' no matter if control targets can be scheduled or not" do |
89 | 89 |
['enable', 'disable'].each { |action| |
90 | 90 |
@agent.options['action'] = action |
91 | 91 |
@agent.control_targets = [agents(:bob_rain_notifier_agent)] |
92 |
- @agent.should be_valid |
|
92 |
+ expect(@agent).to be_valid |
|
93 | 93 |
} |
94 | 94 |
end |
95 | 95 |
end |
@@ -100,13 +100,13 @@ describe Agents::SchedulerAgent do |
||
100 | 100 |
|
101 | 101 |
@agent.memory['scheduled_at'] = time |
102 | 102 |
@agent.save |
103 |
- @agent.memory['scheduled_at'].should == time |
|
103 |
+ expect(@agent.memory['scheduled_at']).to eq(time) |
|
104 | 104 |
|
105 | 105 |
@agent.memory['scheduled_at'] = time |
106 | 106 |
# Currently @agent.options[]= is not detected |
107 | 107 |
@agent.options = { 'schedule' => '*/5 * * * *' } |
108 | 108 |
@agent.save |
109 |
- @agent.memory['scheduled_at'].should be_nil |
|
109 |
+ expect(@agent.memory['scheduled_at']).to be_nil |
|
110 | 110 |
end |
111 | 111 |
end |
112 | 112 |
|
@@ -122,7 +122,7 @@ describe Agents::SchedulerAgent do |
||
122 | 122 |
} |
123 | 123 |
|
124 | 124 |
@agent.check! |
125 |
- control_target_ids.should be_empty |
|
125 |
+ expect(control_target_ids).to be_empty |
|
126 | 126 |
|
127 | 127 |
@agent.options['action'] = 'disable' |
128 | 128 |
@agent.save! |
@@ -24,36 +24,36 @@ describe Agents::SentimentAgent do |
||
24 | 24 |
|
25 | 25 |
describe "#working?" do |
26 | 26 |
it "checks if events have been received within expected receive period" do |
27 |
- @checker.should_not be_working |
|
27 |
+ expect(@checker).not_to be_working |
|
28 | 28 |
Agents::SentimentAgent.async_receive @checker.id, [@event.id] |
29 |
- @checker.reload.should be_working |
|
29 |
+ expect(@checker.reload).to be_working |
|
30 | 30 |
two_days_from_now = 2.days.from_now |
31 | 31 |
stub(Time).now { two_days_from_now } |
32 |
- @checker.reload.should_not be_working |
|
32 |
+ expect(@checker.reload).not_to be_working |
|
33 | 33 |
end |
34 | 34 |
end |
35 | 35 |
|
36 | 36 |
describe "validation" do |
37 | 37 |
before do |
38 |
- @checker.should be_valid |
|
38 |
+ expect(@checker).to be_valid |
|
39 | 39 |
end |
40 | 40 |
|
41 | 41 |
it "should validate presence of content key" do |
42 | 42 |
@checker.options[:content] = nil |
43 |
- @checker.should_not be_valid |
|
43 |
+ expect(@checker).not_to be_valid |
|
44 | 44 |
end |
45 | 45 |
|
46 | 46 |
it "should validate presence of expected_receive_period_in_days key" do |
47 | 47 |
@checker.options[:expected_receive_period_in_days] = nil |
48 |
- @checker.should_not be_valid |
|
48 |
+ expect(@checker).not_to be_valid |
|
49 | 49 |
end |
50 | 50 |
end |
51 | 51 |
|
52 | 52 |
describe "#receive" do |
53 | 53 |
it "checks if content key is working fine" do |
54 | 54 |
@checker.receive([@event]) |
55 |
- Event.last.payload[:content].should == "value1" |
|
56 |
- Event.last.payload[:original_event].should == { 'message' => "value1" } |
|
55 |
+ expect(Event.last.payload[:content]).to eq("value1") |
|
56 |
+ expect(Event.last.payload[:original_event]).to eq({ 'message' => "value1" }) |
|
57 | 57 |
end |
58 | 58 |
it "should handle multiple events" do |
59 | 59 |
event1 = Event.new |
@@ -68,9 +68,9 @@ describe Agents::SentimentAgent do |
||
68 | 68 |
:message => "The quick brown fox jumps over the lazy dog" |
69 | 69 |
} |
70 | 70 |
|
71 |
- lambda { |
|
71 |
+ expect { |
|
72 | 72 |
@checker.receive([@event,event1,event2]) |
73 |
- }.should change { Event.count }.by(3) |
|
73 |
+ }.to change { Event.count }.by(3) |
|
74 | 74 |
end |
75 | 75 |
end |
76 |
-end |
|
76 |
+end |
@@ -26,22 +26,22 @@ describe Agents::ShellCommandAgent do |
||
26 | 26 |
|
27 | 27 |
describe "validation" do |
28 | 28 |
before do |
29 |
- @checker.should be_valid |
|
29 |
+ expect(@checker).to be_valid |
|
30 | 30 |
end |
31 | 31 |
|
32 | 32 |
it "should validate presence of necessary fields" do |
33 | 33 |
@checker.options[:command] = nil |
34 |
- @checker.should_not be_valid |
|
34 |
+ expect(@checker).not_to be_valid |
|
35 | 35 |
end |
36 | 36 |
|
37 | 37 |
it "should validate path" do |
38 | 38 |
@checker.options[:path] = 'notarealpath/itreallyisnt' |
39 |
- @checker.should_not be_valid |
|
39 |
+ expect(@checker).not_to be_valid |
|
40 | 40 |
end |
41 | 41 |
|
42 | 42 |
it "should validate path" do |
43 | 43 |
@checker.options[:path] = '/' |
44 |
- @checker.should be_valid |
|
44 |
+ expect(@checker).to be_valid |
|
45 | 45 |
end |
46 | 46 |
end |
47 | 47 |
|
@@ -49,12 +49,12 @@ describe Agents::ShellCommandAgent do |
||
49 | 49 |
it "generating events as scheduled" do |
50 | 50 |
stub(@checker).run_command(@valid_path, 'pwd') { ["fake pwd output", "", 0] } |
51 | 51 |
|
52 |
- @checker.should_not be_working |
|
52 |
+ expect(@checker).not_to be_working |
|
53 | 53 |
@checker.check |
54 |
- @checker.reload.should be_working |
|
54 |
+ expect(@checker.reload).to be_working |
|
55 | 55 |
three_days_from_now = 3.days.from_now |
56 | 56 |
stub(Time).now { three_days_from_now } |
57 |
- @checker.should_not be_working |
|
57 |
+ expect(@checker).not_to be_working |
|
58 | 58 |
end |
59 | 59 |
end |
60 | 60 |
|
@@ -65,9 +65,9 @@ describe Agents::ShellCommandAgent do |
||
65 | 65 |
|
66 | 66 |
it "should create an event when checking" do |
67 | 67 |
expect { @checker.check }.to change { Event.count }.by(1) |
68 |
- Event.last.payload[:path].should == @valid_path |
|
69 |
- Event.last.payload[:command].should == 'pwd' |
|
70 |
- Event.last.payload[:output].should == "fake pwd output" |
|
68 |
+ expect(Event.last.payload[:path]).to eq(@valid_path) |
|
69 |
+ expect(Event.last.payload[:command]).to eq('pwd') |
|
70 |
+ expect(Event.last.payload[:output]).to eq("fake pwd output") |
|
71 | 71 |
end |
72 | 72 |
|
73 | 73 |
it "does not run when should_run? is false" do |
@@ -84,9 +84,9 @@ describe Agents::ShellCommandAgent do |
||
84 | 84 |
it "creates events" do |
85 | 85 |
@checker.options[:command] = "{{cmd}}" |
86 | 86 |
@checker.receive([@event]) |
87 |
- Event.last.payload[:path].should == @valid_path |
|
88 |
- Event.last.payload[:command].should == @event.payload[:cmd] |
|
89 |
- Event.last.payload[:output].should == "fake ls output" |
|
87 |
+ expect(Event.last.payload[:path]).to eq(@valid_path) |
|
88 |
+ expect(Event.last.payload[:command]).to eq(@event.payload[:cmd]) |
|
89 |
+ expect(Event.last.payload[:output]).to eq("fake ls output") |
|
90 | 90 |
end |
91 | 91 |
|
92 | 92 |
it "does not run when should_run? is false" do |
@@ -49,7 +49,7 @@ describe Agents::SlackAgent do |
||
49 | 49 |
) |
50 | 50 |
end |
51 | 51 |
|
52 |
- lambda { @checker.receive([@event]) }.should_not raise_error |
|
52 |
+ expect { @checker.receive([@event]) }.not_to raise_error |
|
53 | 53 |
end |
54 | 54 |
end |
55 | 55 |
|
@@ -37,31 +37,31 @@ describe Agents::StubhubAgent do |
||
37 | 37 |
|
38 | 38 |
it 'should properly parse the response' do |
39 | 39 |
event = @stubhub_agent.check |
40 |
- event.payload.should == response_payload |
|
40 |
+ expect(event.payload).to eq(response_payload) |
|
41 | 41 |
end |
42 | 42 |
end |
43 | 43 |
|
44 | 44 |
describe "validations" do |
45 | 45 |
before do |
46 |
- @stubhub_agent.should be_valid |
|
46 |
+ expect(@stubhub_agent).to be_valid |
|
47 | 47 |
end |
48 | 48 |
|
49 | 49 |
it "should require a url" do |
50 | 50 |
@stubhub_agent.options['url'] = nil |
51 |
- @stubhub_agent.should_not be_valid |
|
51 |
+ expect(@stubhub_agent).not_to be_valid |
|
52 | 52 |
end |
53 | 53 |
|
54 | 54 |
end |
55 | 55 |
|
56 | 56 |
describe "#working?" do |
57 | 57 |
it "checks if events have been received within the expected receive period" do |
58 |
- @stubhub_agent.should_not be_working |
|
58 |
+ expect(@stubhub_agent).not_to be_working |
|
59 | 59 |
|
60 | 60 |
Agents::StubhubAgent.async_check @stubhub_agent.id |
61 |
- @stubhub_agent.reload.should be_working |
|
61 |
+ expect(@stubhub_agent.reload).to be_working |
|
62 | 62 |
two_days_from_now = 2.days.from_now |
63 | 63 |
stub(Time).now { two_days_from_now } |
64 |
- @stubhub_agent.reload.should_not be_working |
|
64 |
+ expect(@stubhub_agent.reload).not_to be_working |
|
65 | 65 |
end |
66 | 66 |
end |
67 | 67 |
end |
@@ -42,51 +42,51 @@ describe Agents::TranslationAgent do |
||
42 | 42 |
:message => "value2" |
43 | 43 |
} |
44 | 44 |
|
45 |
- lambda { |
|
45 |
+ expect { |
|
46 | 46 |
@checker.receive([@event,event1]) |
47 |
- }.should change { Event.count }.by(2) |
|
47 |
+ }.to change { Event.count }.by(2) |
|
48 | 48 |
end |
49 | 49 |
end |
50 | 50 |
|
51 | 51 |
describe "#working?" do |
52 | 52 |
it "checks if events have been received within expected receive period" do |
53 |
- @checker.should_not be_working |
|
53 |
+ expect(@checker).not_to be_working |
|
54 | 54 |
Agents::TranslationAgent.async_receive @checker.id, [@event.id] |
55 |
- @checker.reload.should be_working |
|
55 |
+ expect(@checker.reload).to be_working |
|
56 | 56 |
two_days_from_now = 2.days.from_now |
57 | 57 |
stub(Time).now { two_days_from_now } |
58 |
- @checker.reload.should_not be_working |
|
58 |
+ expect(@checker.reload).not_to be_working |
|
59 | 59 |
end |
60 | 60 |
end |
61 | 61 |
|
62 | 62 |
describe "validation" do |
63 | 63 |
before do |
64 |
- @checker.should be_valid |
|
64 |
+ expect(@checker).to be_valid |
|
65 | 65 |
end |
66 | 66 |
|
67 | 67 |
it "should validate presence of content key" do |
68 | 68 |
@checker.options[:content] = nil |
69 |
- @checker.should_not be_valid |
|
69 |
+ expect(@checker).not_to be_valid |
|
70 | 70 |
end |
71 | 71 |
|
72 | 72 |
it "should validate presence of expected_receive_period_in_days key" do |
73 | 73 |
@checker.options[:expected_receive_period_in_days] = nil |
74 |
- @checker.should_not be_valid |
|
74 |
+ expect(@checker).not_to be_valid |
|
75 | 75 |
end |
76 | 76 |
|
77 | 77 |
it "should validate presence of client_id key" do |
78 | 78 |
@checker.options[:client_id] = "" |
79 |
- @checker.should_not be_valid |
|
79 |
+ expect(@checker).not_to be_valid |
|
80 | 80 |
end |
81 | 81 |
|
82 | 82 |
it "should validate presence of client_secret key" do |
83 | 83 |
@checker.options[:client_secret] = "" |
84 |
- @checker.should_not be_valid |
|
84 |
+ expect(@checker).not_to be_valid |
|
85 | 85 |
end |
86 | 86 |
|
87 | 87 |
it "should validate presence of 'to' key" do |
88 | 88 |
@checker.options[:to] = "" |
89 |
- @checker.should_not be_valid |
|
89 |
+ expect(@checker).not_to be_valid |
|
90 | 90 |
end |
91 | 91 |
end |
92 |
-end |
|
92 |
+end |
@@ -27,44 +27,44 @@ describe Agents::TriggerAgent do |
||
27 | 27 |
|
28 | 28 |
describe "validation" do |
29 | 29 |
before do |
30 |
- @checker.should be_valid |
|
30 |
+ expect(@checker).to be_valid |
|
31 | 31 |
end |
32 | 32 |
|
33 | 33 |
it "should validate presence of message" do |
34 | 34 |
@checker.options['message'] = nil |
35 |
- @checker.should_not be_valid |
|
35 |
+ expect(@checker).not_to be_valid |
|
36 | 36 |
|
37 | 37 |
@checker.options['message'] = '' |
38 |
- @checker.should_not be_valid |
|
38 |
+ expect(@checker).not_to be_valid |
|
39 | 39 |
end |
40 | 40 |
|
41 | 41 |
it "should be valid without a message when 'keep_event' is set" do |
42 | 42 |
@checker.options['keep_event'] = 'true' |
43 | 43 |
@checker.options['message'] = '' |
44 |
- @checker.should be_valid |
|
44 |
+ expect(@checker).to be_valid |
|
45 | 45 |
end |
46 | 46 |
|
47 | 47 |
it "if present, 'keep_event' must equal true or false" do |
48 | 48 |
@checker.options['keep_event'] = 'true' |
49 |
- @checker.should be_valid |
|
49 |
+ expect(@checker).to be_valid |
|
50 | 50 |
|
51 | 51 |
@checker.options['keep_event'] = 'false' |
52 |
- @checker.should be_valid |
|
52 |
+ expect(@checker).to be_valid |
|
53 | 53 |
|
54 | 54 |
@checker.options['keep_event'] = '' |
55 |
- @checker.should be_valid |
|
55 |
+ expect(@checker).to be_valid |
|
56 | 56 |
|
57 | 57 |
@checker.options['keep_event'] = 'tralse' |
58 |
- @checker.should_not be_valid |
|
58 |
+ expect(@checker).not_to be_valid |
|
59 | 59 |
end |
60 | 60 |
|
61 | 61 |
it "should validate the three fields in each rule" do |
62 | 62 |
@checker.options['rules'] << { 'path' => "foo", 'type' => "fake", 'value' => "6" } |
63 |
- @checker.should_not be_valid |
|
63 |
+ expect(@checker).not_to be_valid |
|
64 | 64 |
@checker.options['rules'].last['type'] = "field>=value" |
65 |
- @checker.should be_valid |
|
65 |
+ expect(@checker).to be_valid |
|
66 | 66 |
@checker.options['rules'].last.delete('value') |
67 |
- @checker.should_not be_valid |
|
67 |
+ expect(@checker).not_to be_valid |
|
68 | 68 |
end |
69 | 69 |
end |
70 | 70 |
|
@@ -72,26 +72,26 @@ describe Agents::TriggerAgent do |
||
72 | 72 |
it "checks to see if the Agent has received any events in the last 'expected_receive_period_in_days' days" do |
73 | 73 |
@event.save! |
74 | 74 |
|
75 |
- @checker.should_not be_working # no events have ever been received |
|
75 |
+ expect(@checker).not_to be_working # no events have ever been received |
|
76 | 76 |
Agents::TriggerAgent.async_receive(@checker.id, [@event.id]) |
77 |
- @checker.reload.should be_working # Events received |
|
77 |
+ expect(@checker.reload).to be_working # Events received |
|
78 | 78 |
three_days_from_now = 3.days.from_now |
79 | 79 |
stub(Time).now { three_days_from_now } |
80 |
- @checker.reload.should_not be_working # too much time has passed |
|
80 |
+ expect(@checker.reload).not_to be_working # too much time has passed |
|
81 | 81 |
end |
82 | 82 |
end |
83 | 83 |
|
84 | 84 |
describe "#receive" do |
85 | 85 |
it "handles regex" do |
86 | 86 |
@event.payload['foo']['bar']['baz'] = "a222b" |
87 |
- lambda { |
|
87 |
+ expect { |
|
88 | 88 |
@checker.receive([@event]) |
89 |
- }.should_not change { Event.count } |
|
89 |
+ }.not_to change { Event.count } |
|
90 | 90 |
|
91 | 91 |
@event.payload['foo']['bar']['baz'] = "a2b" |
92 |
- lambda { |
|
92 |
+ expect { |
|
93 | 93 |
@checker.receive([@event]) |
94 |
- }.should change { Event.count }.by(1) |
|
94 |
+ }.to change { Event.count }.by(1) |
|
95 | 95 |
end |
96 | 96 |
|
97 | 97 |
it "handles array of regex" do |
@@ -101,19 +101,19 @@ describe Agents::TriggerAgent do |
||
101 | 101 |
'value' => ["a\\db", "a\\Wb"], |
102 | 102 |
'path' => "foo.bar.baz", |
103 | 103 |
} |
104 |
- lambda { |
|
104 |
+ expect { |
|
105 | 105 |
@checker.receive([@event]) |
106 |
- }.should_not change { Event.count } |
|
106 |
+ }.not_to change { Event.count } |
|
107 | 107 |
|
108 | 108 |
@event.payload['foo']['bar']['baz'] = "a2b" |
109 |
- lambda { |
|
109 |
+ expect { |
|
110 | 110 |
@checker.receive([@event]) |
111 |
- }.should change { Event.count }.by(1) |
|
111 |
+ }.to change { Event.count }.by(1) |
|
112 | 112 |
|
113 | 113 |
@event.payload['foo']['bar']['baz'] = "a b" |
114 |
- lambda { |
|
114 |
+ expect { |
|
115 | 115 |
@checker.receive([@event]) |
116 |
- }.should change { Event.count }.by(1) |
|
116 |
+ }.to change { Event.count }.by(1) |
|
117 | 117 |
end |
118 | 118 |
|
119 | 119 |
it "handles negated regex" do |
@@ -124,14 +124,14 @@ describe Agents::TriggerAgent do |
||
124 | 124 |
'path' => "foo.bar.baz", |
125 | 125 |
} |
126 | 126 |
|
127 |
- lambda { |
|
127 |
+ expect { |
|
128 | 128 |
@checker.receive([@event]) |
129 |
- }.should_not change { Event.count } |
|
129 |
+ }.not_to change { Event.count } |
|
130 | 130 |
|
131 | 131 |
@event.payload['foo']['bar']['baz'] = "a22b" |
132 |
- lambda { |
|
132 |
+ expect { |
|
133 | 133 |
@checker.receive([@event]) |
134 |
- }.should change { Event.count }.by(1) |
|
134 |
+ }.to change { Event.count }.by(1) |
|
135 | 135 |
end |
136 | 136 |
|
137 | 137 |
it "handles array of negated regex" do |
@@ -142,19 +142,19 @@ describe Agents::TriggerAgent do |
||
142 | 142 |
'path' => "foo.bar.baz", |
143 | 143 |
} |
144 | 144 |
|
145 |
- lambda { |
|
145 |
+ expect { |
|
146 | 146 |
@checker.receive([@event]) |
147 |
- }.should_not change { Event.count } |
|
147 |
+ }.not_to change { Event.count } |
|
148 | 148 |
|
149 | 149 |
@event.payload['foo']['bar']['baz'] = "a3b" |
150 |
- lambda { |
|
150 |
+ expect { |
|
151 | 151 |
@checker.receive([@event]) |
152 |
- }.should change { Event.count }.by(1) |
|
152 |
+ }.to change { Event.count }.by(1) |
|
153 | 153 |
end |
154 | 154 |
|
155 | 155 |
it "puts can extract values into the message based on paths" do |
156 | 156 |
@checker.receive([@event]) |
157 |
- Event.last.payload['message'].should == "I saw 'a2b' from Joe" |
|
157 |
+ expect(Event.last.payload['message']).to eq("I saw 'a2b' from Joe") |
|
158 | 158 |
end |
159 | 159 |
|
160 | 160 |
it "handles numerical comparisons" do |
@@ -162,14 +162,14 @@ describe Agents::TriggerAgent do |
||
162 | 162 |
@checker.options['rules'].first['value'] = 6 |
163 | 163 |
@checker.options['rules'].first['type'] = "field<value" |
164 | 164 |
|
165 |
- lambda { |
|
165 |
+ expect { |
|
166 | 166 |
@checker.receive([@event]) |
167 |
- }.should change { Event.count }.by(1) |
|
167 |
+ }.to change { Event.count }.by(1) |
|
168 | 168 |
|
169 | 169 |
@checker.options['rules'].first['value'] = 3 |
170 |
- lambda { |
|
170 |
+ expect { |
|
171 | 171 |
@checker.receive([@event]) |
172 |
- }.should_not change { Event.count } |
|
172 |
+ }.not_to change { Event.count } |
|
173 | 173 |
end |
174 | 174 |
|
175 | 175 |
it "handles array of numerical comparisons" do |
@@ -177,14 +177,14 @@ describe Agents::TriggerAgent do |
||
177 | 177 |
@checker.options['rules'].first['value'] = [6, 3] |
178 | 178 |
@checker.options['rules'].first['type'] = "field<value" |
179 | 179 |
|
180 |
- lambda { |
|
180 |
+ expect { |
|
181 | 181 |
@checker.receive([@event]) |
182 |
- }.should change { Event.count }.by(1) |
|
182 |
+ }.to change { Event.count }.by(1) |
|
183 | 183 |
|
184 | 184 |
@checker.options['rules'].first['value'] = [4, 3] |
185 |
- lambda { |
|
185 |
+ expect { |
|
186 | 186 |
@checker.receive([@event]) |
187 |
- }.should_not change { Event.count } |
|
187 |
+ }.not_to change { Event.count } |
|
188 | 188 |
end |
189 | 189 |
|
190 | 190 |
it "handles exact comparisons" do |
@@ -192,14 +192,14 @@ describe Agents::TriggerAgent do |
||
192 | 192 |
@checker.options['rules'].first['type'] = "field==value" |
193 | 193 |
|
194 | 194 |
@checker.options['rules'].first['value'] = "hello there" |
195 |
- lambda { |
|
195 |
+ expect { |
|
196 | 196 |
@checker.receive([@event]) |
197 |
- }.should_not change { Event.count } |
|
197 |
+ }.not_to change { Event.count } |
|
198 | 198 |
|
199 | 199 |
@checker.options['rules'].first['value'] = "hello world" |
200 |
- lambda { |
|
200 |
+ expect { |
|
201 | 201 |
@checker.receive([@event]) |
202 |
- }.should change { Event.count }.by(1) |
|
202 |
+ }.to change { Event.count }.by(1) |
|
203 | 203 |
end |
204 | 204 |
|
205 | 205 |
it "handles array of exact comparisons" do |
@@ -207,14 +207,14 @@ describe Agents::TriggerAgent do |
||
207 | 207 |
@checker.options['rules'].first['type'] = "field==value" |
208 | 208 |
|
209 | 209 |
@checker.options['rules'].first['value'] = ["hello there", "hello universe"] |
210 |
- lambda { |
|
210 |
+ expect { |
|
211 | 211 |
@checker.receive([@event]) |
212 |
- }.should_not change { Event.count } |
|
212 |
+ }.not_to change { Event.count } |
|
213 | 213 |
|
214 | 214 |
@checker.options['rules'].first['value'] = ["hello world", "hello universe"] |
215 |
- lambda { |
|
215 |
+ expect { |
|
216 | 216 |
@checker.receive([@event]) |
217 |
- }.should change { Event.count }.by(1) |
|
217 |
+ }.to change { Event.count }.by(1) |
|
218 | 218 |
end |
219 | 219 |
|
220 | 220 |
it "handles negated comparisons" do |
@@ -222,15 +222,15 @@ describe Agents::TriggerAgent do |
||
222 | 222 |
@checker.options['rules'].first['type'] = "field!=value" |
223 | 223 |
@checker.options['rules'].first['value'] = "hello world" |
224 | 224 |
|
225 |
- lambda { |
|
225 |
+ expect { |
|
226 | 226 |
@checker.receive([@event]) |
227 |
- }.should_not change { Event.count } |
|
227 |
+ }.not_to change { Event.count } |
|
228 | 228 |
|
229 | 229 |
@checker.options['rules'].first['value'] = "hello there" |
230 | 230 |
|
231 |
- lambda { |
|
231 |
+ expect { |
|
232 | 232 |
@checker.receive([@event]) |
233 |
- }.should change { Event.count }.by(1) |
|
233 |
+ }.to change { Event.count }.by(1) |
|
234 | 234 |
end |
235 | 235 |
|
236 | 236 |
it "handles array of negated comparisons" do |
@@ -238,15 +238,15 @@ describe Agents::TriggerAgent do |
||
238 | 238 |
@checker.options['rules'].first['type'] = "field!=value" |
239 | 239 |
@checker.options['rules'].first['value'] = ["hello world", "hello world"] |
240 | 240 |
|
241 |
- lambda { |
|
241 |
+ expect { |
|
242 | 242 |
@checker.receive([@event]) |
243 |
- }.should_not change { Event.count } |
|
243 |
+ }.not_to change { Event.count } |
|
244 | 244 |
|
245 | 245 |
@checker.options['rules'].first['value'] = ["hello there", "hello world"] |
246 | 246 |
|
247 |
- lambda { |
|
247 |
+ expect { |
|
248 | 248 |
@checker.receive([@event]) |
249 |
- }.should change { Event.count }.by(1) |
|
249 |
+ }.to change { Event.count }.by(1) |
|
250 | 250 |
end |
251 | 251 |
|
252 | 252 |
it "does fine without dots in the path" do |
@@ -254,19 +254,19 @@ describe Agents::TriggerAgent do |
||
254 | 254 |
@checker.options['rules'].first['type'] = "field==value" |
255 | 255 |
@checker.options['rules'].first['path'] = "hello" |
256 | 256 |
@checker.options['rules'].first['value'] = "world" |
257 |
- lambda { |
|
257 |
+ expect { |
|
258 | 258 |
@checker.receive([@event]) |
259 |
- }.should change { Event.count }.by(1) |
|
259 |
+ }.to change { Event.count }.by(1) |
|
260 | 260 |
|
261 | 261 |
@checker.options['rules'].first['path'] = "foo" |
262 |
- lambda { |
|
262 |
+ expect { |
|
263 | 263 |
@checker.receive([@event]) |
264 |
- }.should_not change { Event.count } |
|
264 |
+ }.not_to change { Event.count } |
|
265 | 265 |
|
266 | 266 |
@checker.options['rules'].first['value'] = "hi" |
267 |
- lambda { |
|
267 |
+ expect { |
|
268 | 268 |
@checker.receive([@event]) |
269 |
- }.should_not change { Event.count } |
|
269 |
+ }.not_to change { Event.count } |
|
270 | 270 |
end |
271 | 271 |
|
272 | 272 |
it "handles multiple events" do |
@@ -278,9 +278,9 @@ describe Agents::TriggerAgent do |
||
278 | 278 |
event3.agent = agents(:bob_weather_agent) |
279 | 279 |
event3.payload = { 'foo' => { 'bar' => { 'baz' => "a222b" }}} |
280 | 280 |
|
281 |
- lambda { |
|
281 |
+ expect { |
|
282 | 282 |
@checker.receive([@event, event2, event3]) |
283 |
- }.should change { Event.count }.by(2) |
|
283 |
+ }.to change { Event.count }.by(2) |
|
284 | 284 |
end |
285 | 285 |
|
286 | 286 |
it "handles ANDing rules together" do |
@@ -292,14 +292,14 @@ describe Agents::TriggerAgent do |
||
292 | 292 |
|
293 | 293 |
@event.payload['foo']["bing"] = "5" |
294 | 294 |
|
295 |
- lambda { |
|
295 |
+ expect { |
|
296 | 296 |
@checker.receive([@event]) |
297 |
- }.should change { Event.count }.by(1) |
|
297 |
+ }.to change { Event.count }.by(1) |
|
298 | 298 |
|
299 | 299 |
@checker.options['rules'].last['value'] = 6 |
300 |
- lambda { |
|
300 |
+ expect { |
|
301 | 301 |
@checker.receive([@event]) |
302 |
- }.should_not change { Event.count } |
|
302 |
+ }.not_to change { Event.count } |
|
303 | 303 |
end |
304 | 304 |
|
305 | 305 |
describe "when 'keep_event' is true" do |
@@ -314,16 +314,16 @@ describe Agents::TriggerAgent do |
||
314 | 314 |
@checker.options['message'] = '' |
315 | 315 |
@event.payload['message'] = 'hi there' |
316 | 316 |
|
317 |
- lambda { |
|
317 |
+ expect { |
|
318 | 318 |
@checker.receive([@event]) |
319 |
- }.should_not change { Event.count } |
|
319 |
+ }.not_to change { Event.count } |
|
320 | 320 |
|
321 | 321 |
@checker.options['rules'].first['value'] = 6 |
322 |
- lambda { |
|
322 |
+ expect { |
|
323 | 323 |
@checker.receive([@event]) |
324 |
- }.should change { Event.count }.by(1) |
|
324 |
+ }.to change { Event.count }.by(1) |
|
325 | 325 |
|
326 |
- @checker.most_recent_event.payload.should == @event.payload |
|
326 |
+ expect(@checker.most_recent_event.payload).to eq(@event.payload) |
|
327 | 327 |
end |
328 | 328 |
|
329 | 329 |
it "merges 'message' into the original event when present" do |
@@ -331,8 +331,8 @@ describe Agents::TriggerAgent do |
||
331 | 331 |
|
332 | 332 |
@checker.receive([@event]) |
333 | 333 |
|
334 |
- @checker.most_recent_event.payload.should == @event.payload.merge(:message => "I saw '5' from Joe") |
|
334 |
+ expect(@checker.most_recent_event.payload).to eq(@event.payload.merge(:message => "I saw '5' from Joe")) |
|
335 | 335 |
end |
336 | 336 |
end |
337 | 337 |
end |
338 |
-end |
|
338 |
+end |
@@ -30,9 +30,9 @@ describe Agents::TumblrPublishAgent do |
||
30 | 30 |
describe '#receive' do |
31 | 31 |
it 'should publish any payload it receives' do |
32 | 32 |
Agents::TumblrPublishAgent.async_receive(@checker.id, [@event.id]) |
33 |
- @checker.events.count.should eq(1) |
|
34 |
- @checker.events.first.payload['post_id'].should eq('5') |
|
35 |
- @checker.events.first.payload['published_post'].should eq('[huginnbot.tumblr.com] text') |
|
33 |
+ expect(@checker.events.count).to eq(1) |
|
34 |
+ expect(@checker.events.first.payload['post_id']).to eq('5') |
|
35 |
+ expect(@checker.events.first.payload['published_post']).to eq('[huginnbot.tumblr.com] text') |
|
36 | 36 |
end |
37 | 37 |
end |
38 | 38 |
end |
@@ -37,62 +37,62 @@ describe Agents::TwilioAgent do |
||
37 | 37 |
event2.save! |
38 | 38 |
|
39 | 39 |
@checker.receive([@event,event1,event2]) |
40 |
- @sent_messages.should == ['Looks like its going to rain','Some message','Some other message'] |
|
40 |
+ expect(@sent_messages).to eq(['Looks like its going to rain','Some message','Some other message']) |
|
41 | 41 |
end |
42 | 42 |
|
43 | 43 |
it 'should check if receive_text is working fine' do |
44 | 44 |
@checker.options[:receive_text] = 'false' |
45 | 45 |
@checker.receive([@event]) |
46 |
- @sent_messages.should be_empty |
|
46 |
+ expect(@sent_messages).to be_empty |
|
47 | 47 |
end |
48 | 48 |
|
49 | 49 |
it 'should check if receive_call is working fine' do |
50 | 50 |
@checker.options[:receive_call] = 'true' |
51 | 51 |
@checker.receive([@event]) |
52 |
- @checker.memory[:pending_calls].should_not == {} |
|
52 |
+ expect(@checker.memory[:pending_calls]).not_to eq({}) |
|
53 | 53 |
end |
54 | 54 |
|
55 | 55 |
end |
56 | 56 |
|
57 | 57 |
describe '#working?' do |
58 | 58 |
it 'checks if events have been received within the expected receive period' do |
59 |
- @checker.should_not be_working # No events received |
|
59 |
+ expect(@checker).not_to be_working # No events received |
|
60 | 60 |
Agents::TwilioAgent.async_receive @checker.id, [@event.id] |
61 |
- @checker.reload.should be_working # Just received events |
|
61 |
+ expect(@checker.reload).to be_working # Just received events |
|
62 | 62 |
two_days_from_now = 2.days.from_now |
63 | 63 |
stub(Time).now { two_days_from_now } |
64 |
- @checker.reload.should_not be_working # More time has passed than the expected receive period without any new events |
|
64 |
+ expect(@checker.reload).not_to be_working # More time has passed than the expected receive period without any new events |
|
65 | 65 |
end |
66 | 66 |
end |
67 | 67 |
|
68 | 68 |
describe "validation" do |
69 | 69 |
before do |
70 |
- @checker.should be_valid |
|
70 |
+ expect(@checker).to be_valid |
|
71 | 71 |
end |
72 | 72 |
|
73 | 73 |
it "should validate presence of of account_sid" do |
74 | 74 |
@checker.options[:account_sid] = "" |
75 |
- @checker.should_not be_valid |
|
75 |
+ expect(@checker).not_to be_valid |
|
76 | 76 |
end |
77 | 77 |
|
78 | 78 |
it "should validate presence of auth_token" do |
79 | 79 |
@checker.options[:auth_token] = "" |
80 |
- @checker.should_not be_valid |
|
80 |
+ expect(@checker).not_to be_valid |
|
81 | 81 |
end |
82 | 82 |
|
83 | 83 |
it "should validate presence of receiver_cell" do |
84 | 84 |
@checker.options[:receiver_cell] = "" |
85 |
- @checker.should_not be_valid |
|
85 |
+ expect(@checker).not_to be_valid |
|
86 | 86 |
end |
87 | 87 |
|
88 | 88 |
it "should validate presence of sender_cell" do |
89 | 89 |
@checker.options[:sender_cell] = "" |
90 |
- @checker.should_not be_valid |
|
90 |
+ expect(@checker).not_to be_valid |
|
91 | 91 |
end |
92 | 92 |
|
93 | 93 |
it "should make sure filling sure filling server_url is not necessary" do |
94 | 94 |
@checker.options[:server_url] = "" |
95 |
- @checker.should be_valid |
|
95 |
+ expect(@checker).to be_valid |
|
96 | 96 |
end |
97 | 97 |
end |
98 |
-end |
|
98 |
+end |
@@ -42,19 +42,19 @@ describe Agents::TwitterPublishAgent do |
||
42 | 42 |
event2.save! |
43 | 43 |
|
44 | 44 |
Agents::TwitterPublishAgent.async_receive(@checker.id, [event1.id, event2.id]) |
45 |
- @sent_messages.count.should eq(2) |
|
46 |
- @checker.events.count.should eq(2) |
|
45 |
+ expect(@sent_messages.count).to eq(2) |
|
46 |
+ expect(@checker.events.count).to eq(2) |
|
47 | 47 |
end |
48 | 48 |
end |
49 | 49 |
|
50 | 50 |
describe '#working?' do |
51 | 51 |
it 'checks if events have been received within the expected receive period' do |
52 |
- @checker.should_not be_working # No events received |
|
52 |
+ expect(@checker).not_to be_working # No events received |
|
53 | 53 |
Agents::TwitterPublishAgent.async_receive(@checker.id, [@event.id]) |
54 |
- @checker.reload.should be_working # Just received events |
|
54 |
+ expect(@checker.reload).to be_working # Just received events |
|
55 | 55 |
two_days_from_now = 2.days.from_now |
56 | 56 |
stub(Time).now { two_days_from_now } |
57 |
- @checker.reload.should_not be_working # More time has passed than the expected receive period without any new events |
|
57 |
+ expect(@checker.reload).not_to be_working # More time has passed than the expected receive period without any new events |
|
58 | 58 |
end |
59 | 59 |
end |
60 | 60 |
end |
@@ -30,8 +30,8 @@ describe Agents::TwitterStreamAgent do |
||
30 | 30 |
@agent.process_tweet('keyword1', {:text => "something", :user => {:name => "Mr. Someone"}}) |
31 | 31 |
|
32 | 32 |
@agent.reload |
33 |
- @agent.memory[:filter_counts][:keyword1].should == 2 |
|
34 |
- @agent.memory[:filter_counts][:keyword2].should == 1 |
|
33 |
+ expect(@agent.memory[:filter_counts][:keyword1]).to eq(2) |
|
34 |
+ expect(@agent.memory[:filter_counts][:keyword2]).to eq(1) |
|
35 | 35 |
end |
36 | 36 |
|
37 | 37 |
it 'records counts for keyword sets as well' do |
@@ -46,44 +46,44 @@ describe Agents::TwitterStreamAgent do |
||
46 | 46 |
@agent.process_tweet('keyword1-1', {:text => "something", :user => {:name => "Mr. Someone"}}) |
47 | 47 |
|
48 | 48 |
@agent.reload |
49 |
- @agent.memory[:filter_counts][:'keyword1-1'].should == 4 # it stores on the first keyword |
|
50 |
- @agent.memory[:filter_counts][:keyword2].should == 2 |
|
49 |
+ expect(@agent.memory[:filter_counts][:'keyword1-1']).to eq(4) # it stores on the first keyword |
|
50 |
+ expect(@agent.memory[:filter_counts][:keyword2]).to eq(2) |
|
51 | 51 |
end |
52 | 52 |
|
53 | 53 |
it 'removes unused keys' do |
54 | 54 |
@agent.memory[:filter_counts] = {:keyword1 => 2, :keyword2 => 3, :keyword3 => 4} |
55 | 55 |
@agent.save! |
56 | 56 |
@agent.process_tweet('keyword1', {:text => "something", :user => {:name => "Mr. Someone"}}) |
57 |
- @agent.reload.memory[:filter_counts].should == { 'keyword1' => 3, 'keyword2' => 3 } |
|
57 |
+ expect(@agent.reload.memory[:filter_counts]).to eq({ 'keyword1' => 3, 'keyword2' => 3 }) |
|
58 | 58 |
end |
59 | 59 |
end |
60 | 60 |
|
61 | 61 |
context "when generate is set to 'events'" do |
62 | 62 |
it 'emits events immediately' do |
63 |
- lambda { |
|
63 |
+ expect { |
|
64 | 64 |
@agent.process_tweet('keyword1', {:text => "something", :user => {:name => "Mr. Someone"}}) |
65 |
- }.should change { @agent.events.count }.by(1) |
|
65 |
+ }.to change { @agent.events.count }.by(1) |
|
66 | 66 |
|
67 |
- @agent.events.last.payload.should == { |
|
67 |
+ expect(@agent.events.last.payload).to eq({ |
|
68 | 68 |
'filter' => 'keyword1', |
69 | 69 |
'text' => "something", |
70 | 70 |
'user' => { 'name' => "Mr. Someone" } |
71 |
- } |
|
71 |
+ }) |
|
72 | 72 |
end |
73 | 73 |
|
74 | 74 |
it 'handles keyword sets too' do |
75 | 75 |
@agent.options[:filters][0] = %w[keyword1-1 keyword1-2 keyword1-3] |
76 | 76 |
@agent.save! |
77 | 77 |
|
78 |
- lambda { |
|
78 |
+ expect { |
|
79 | 79 |
@agent.process_tweet('keyword1-2', {:text => "something", :user => {:name => "Mr. Someone"}}) |
80 |
- }.should change { @agent.events.count }.by(1) |
|
80 |
+ }.to change { @agent.events.count }.by(1) |
|
81 | 81 |
|
82 |
- @agent.events.last.payload.should == { |
|
82 |
+ expect(@agent.events.last.payload).to eq({ |
|
83 | 83 |
'filter' => 'keyword1-1', |
84 | 84 |
'text' => "something", |
85 | 85 |
'user' => { 'name' => "Mr. Someone" } |
86 |
- } |
|
86 |
+ }) |
|
87 | 87 |
end |
88 | 88 |
end |
89 | 89 |
end |
@@ -100,17 +100,17 @@ describe Agents::TwitterStreamAgent do |
||
100 | 100 |
@agent.process_tweet('keyword2', {:text => "something", :user => {:name => "Mr. Someone"}}) |
101 | 101 |
@agent.process_tweet('keyword1', {:text => "something", :user => {:name => "Mr. Someone"}}) |
102 | 102 |
|
103 |
- lambda { |
|
103 |
+ expect { |
|
104 | 104 |
@agent.reload.check |
105 |
- }.should change { @agent.events.count }.by(2) |
|
105 |
+ }.to change { @agent.events.count }.by(2) |
|
106 | 106 |
|
107 |
- @agent.events[-1].payload[:filter].should == 'keyword1' |
|
108 |
- @agent.events[-1].payload[:count].should == 2 |
|
107 |
+ expect(@agent.events[-1].payload[:filter]).to eq('keyword1') |
|
108 |
+ expect(@agent.events[-1].payload[:count]).to eq(2) |
|
109 | 109 |
|
110 |
- @agent.events[-2].payload[:filter].should == 'keyword2' |
|
111 |
- @agent.events[-2].payload[:count].should == 1 |
|
110 |
+ expect(@agent.events[-2].payload[:filter]).to eq('keyword2') |
|
111 |
+ expect(@agent.events[-2].payload[:count]).to eq(1) |
|
112 | 112 |
|
113 |
- @agent.memory[:filter_counts].should == {} |
|
113 |
+ expect(@agent.memory[:filter_counts]).to eq({}) |
|
114 | 114 |
end |
115 | 115 |
end |
116 | 116 |
|
@@ -118,11 +118,11 @@ describe Agents::TwitterStreamAgent do |
||
118 | 118 |
it 'does nothing' do |
119 | 119 |
@agent.memory[:filter_counts] = { :keyword1 => 2 } |
120 | 120 |
@agent.save! |
121 |
- lambda { |
|
121 |
+ expect { |
|
122 | 122 |
@agent.reload.check |
123 |
- }.should_not change { Event.count } |
|
124 |
- @agent.memory[:filter_counts].should == {} |
|
123 |
+ }.not_to change { Event.count } |
|
124 |
+ expect(@agent.memory[:filter_counts]).to eq({}) |
|
125 | 125 |
end |
126 | 126 |
end |
127 | 127 |
end |
128 |
-end |
|
128 |
+end |
@@ -23,7 +23,7 @@ describe Agents::TwitterUserAgent do |
||
23 | 23 |
|
24 | 24 |
describe "#check" do |
25 | 25 |
it "should check for changes" do |
26 |
- lambda { @checker.check }.should change { Event.count }.by(5) |
|
26 |
+ expect { @checker.check }.to change { Event.count }.by(5) |
|
27 | 27 |
end |
28 | 28 |
end |
29 | 29 |
|
@@ -36,7 +36,7 @@ describe Agents::TwitterUserAgent do |
||
36 | 36 |
checker.user = users(:bob) |
37 | 37 |
checker.save! |
38 | 38 |
|
39 |
- lambda { checker.check }.should change { Event.count }.by(0) |
|
39 |
+ expect { checker.check }.to change { Event.count }.by(0) |
|
40 | 40 |
end |
41 | 41 |
end |
42 | 42 |
|
@@ -12,37 +12,37 @@ describe Agents::UserLocationAgent do |
||
12 | 12 |
event.created_at = Time.now |
13 | 13 |
event.payload = { 'longitude' => 123, 'latitude' => 45, 'something' => 'else' } |
14 | 14 |
|
15 |
- lambda { |
|
15 |
+ expect { |
|
16 | 16 |
@agent.receive([event]) |
17 |
- }.should change { @agent.events.count }.by(1) |
|
17 |
+ }.to change { @agent.events.count }.by(1) |
|
18 | 18 |
|
19 |
- @agent.events.last.payload.should == { 'longitude' => 123, 'latitude' => 45, 'something' => 'else' } |
|
20 |
- @agent.events.last.lat.should == 45 |
|
21 |
- @agent.events.last.lng.should == 123 |
|
19 |
+ expect(@agent.events.last.payload).to eq({ 'longitude' => 123, 'latitude' => 45, 'something' => 'else' }) |
|
20 |
+ expect(@agent.events.last.lat).to eq(45) |
|
21 |
+ expect(@agent.events.last.lng).to eq(123) |
|
22 | 22 |
end |
23 | 23 |
|
24 | 24 |
it 'does not accept a web request that is not POST' do |
25 | 25 |
%w[get put delete patch].each { |method| |
26 | 26 |
content, status, content_type = @agent.receive_web_request({ 'secret' => 'my_secret' }, method, 'application/json') |
27 |
- status.should == 404 |
|
27 |
+ expect(status).to eq(404) |
|
28 | 28 |
} |
29 | 29 |
end |
30 | 30 |
|
31 | 31 |
it 'requires a valid secret for a web request' do |
32 | 32 |
content, status, content_type = @agent.receive_web_request({ 'secret' => 'fake' }, 'post', 'application/json') |
33 |
- status.should == 401 |
|
33 |
+ expect(status).to eq(401) |
|
34 | 34 |
|
35 | 35 |
content, status, content_type = @agent.receive_web_request({ 'secret' => 'my_secret' }, 'post', 'application/json') |
36 |
- status.should == 200 |
|
36 |
+ expect(status).to eq(200) |
|
37 | 37 |
end |
38 | 38 |
|
39 | 39 |
it 'creates an event on a web request' do |
40 |
- lambda { |
|
40 |
+ expect { |
|
41 | 41 |
@agent.receive_web_request({ 'secret' => 'my_secret', 'longitude' => 123, 'latitude' => 45, 'something' => 'else' }, 'post', 'application/json') |
42 |
- }.should change { @agent.events.count }.by(1) |
|
42 |
+ }.to change { @agent.events.count }.by(1) |
|
43 | 43 |
|
44 |
- @agent.events.last.payload.should == { 'longitude' => 123, 'latitude' => 45, 'something' => 'else' } |
|
45 |
- @agent.events.last.lat.should == 45 |
|
46 |
- @agent.events.last.lng.should == 123 |
|
44 |
+ expect(@agent.events.last.payload).to eq({ 'longitude' => 123, 'latitude' => 45, 'something' => 'else' }) |
|
45 |
+ expect(@agent.events.last.lat).to eq(45) |
|
46 |
+ expect(@agent.events.last.lng).to eq(123) |
|
47 | 47 |
end |
48 | 48 |
end |
@@ -13,27 +13,27 @@ describe Agents::WebhookAgent do |
||
13 | 13 |
describe 'receive_web_request' do |
14 | 14 |
it 'should create event if secret matches' do |
15 | 15 |
out = nil |
16 |
- lambda { |
|
16 |
+ expect { |
|
17 | 17 |
out = agent.receive_web_request({ 'secret' => 'foobar', 'payload' => payload }, "post", "text/html") |
18 |
- }.should change { Event.count }.by(1) |
|
19 |
- out.should eq(['Event Created', 201]) |
|
20 |
- Event.last.payload.should eq(payload) |
|
18 |
+ }.to change { Event.count }.by(1) |
|
19 |
+ expect(out).to eq(['Event Created', 201]) |
|
20 |
+ expect(Event.last.payload).to eq(payload) |
|
21 | 21 |
end |
22 | 22 |
|
23 | 23 |
it 'should not create event if secrets dont match' do |
24 | 24 |
out = nil |
25 |
- lambda { |
|
25 |
+ expect { |
|
26 | 26 |
out = agent.receive_web_request({ 'secret' => 'bazbat', 'payload' => payload }, "post", "text/html") |
27 |
- }.should change { Event.count }.by(0) |
|
28 |
- out.should eq(['Not Authorized', 401]) |
|
27 |
+ }.to change { Event.count }.by(0) |
|
28 |
+ expect(out).to eq(['Not Authorized', 401]) |
|
29 | 29 |
end |
30 | 30 |
|
31 | 31 |
it "should only accept POSTs" do |
32 | 32 |
out = nil |
33 |
- lambda { |
|
33 |
+ expect { |
|
34 | 34 |
out = agent.receive_web_request({ 'secret' => 'foobar', 'payload' => payload }, "get", "text/html") |
35 |
- }.should change { Event.count }.by(0) |
|
36 |
- out.should eq(['Please use POST requests only', 401]) |
|
35 |
+ }.to change { Event.count }.by(0) |
|
36 |
+ expect(out).to eq(['Please use POST requests only', 401]) |
|
37 | 37 |
end |
38 | 38 |
end |
39 | 39 |
end |
@@ -29,71 +29,71 @@ describe Agents::WebsiteAgent do |
||
29 | 29 |
|
30 | 30 |
describe "validations" do |
31 | 31 |
before do |
32 |
- @checker.should be_valid |
|
32 |
+ expect(@checker).to be_valid |
|
33 | 33 |
end |
34 | 34 |
|
35 | 35 |
it "should validate the integer fields" do |
36 | 36 |
@checker.options['expected_update_period_in_days'] = "2" |
37 |
- @checker.should be_valid |
|
37 |
+ expect(@checker).to be_valid |
|
38 | 38 |
|
39 | 39 |
@checker.options['expected_update_period_in_days'] = "nonsense" |
40 |
- @checker.should_not be_valid |
|
40 |
+ expect(@checker).not_to be_valid |
|
41 | 41 |
end |
42 | 42 |
|
43 | 43 |
it "should validate uniqueness_look_back" do |
44 | 44 |
@checker.options['uniqueness_look_back'] = "nonsense" |
45 |
- @checker.should_not be_valid |
|
45 |
+ expect(@checker).not_to be_valid |
|
46 | 46 |
|
47 | 47 |
@checker.options['uniqueness_look_back'] = "2" |
48 |
- @checker.should be_valid |
|
48 |
+ expect(@checker).to be_valid |
|
49 | 49 |
end |
50 | 50 |
|
51 | 51 |
it "should validate mode" do |
52 | 52 |
@checker.options['mode'] = "nonsense" |
53 |
- @checker.should_not be_valid |
|
53 |
+ expect(@checker).not_to be_valid |
|
54 | 54 |
|
55 | 55 |
@checker.options['mode'] = "on_change" |
56 |
- @checker.should be_valid |
|
56 |
+ expect(@checker).to be_valid |
|
57 | 57 |
|
58 | 58 |
@checker.options['mode'] = "all" |
59 |
- @checker.should be_valid |
|
59 |
+ expect(@checker).to be_valid |
|
60 | 60 |
|
61 | 61 |
@checker.options['mode'] = "" |
62 |
- @checker.should be_valid |
|
62 |
+ expect(@checker).to be_valid |
|
63 | 63 |
end |
64 | 64 |
|
65 | 65 |
it "should validate the force_encoding option" do |
66 | 66 |
@checker.options['force_encoding'] = '' |
67 |
- @checker.should be_valid |
|
67 |
+ expect(@checker).to be_valid |
|
68 | 68 |
|
69 | 69 |
@checker.options['force_encoding'] = 'UTF-8' |
70 |
- @checker.should be_valid |
|
70 |
+ expect(@checker).to be_valid |
|
71 | 71 |
|
72 | 72 |
@checker.options['force_encoding'] = ['UTF-8'] |
73 |
- @checker.should_not be_valid |
|
73 |
+ expect(@checker).not_to be_valid |
|
74 | 74 |
|
75 | 75 |
@checker.options['force_encoding'] = 'UTF-42' |
76 |
- @checker.should_not be_valid |
|
76 |
+ expect(@checker).not_to be_valid |
|
77 | 77 |
end |
78 | 78 |
end |
79 | 79 |
|
80 | 80 |
describe "#check" do |
81 | 81 |
it "should check for changes (and update Event.expires_at)" do |
82 |
- lambda { @checker.check }.should change { Event.count }.by(1) |
|
82 |
+ expect { @checker.check }.to change { Event.count }.by(1) |
|
83 | 83 |
event = Event.last |
84 | 84 |
sleep 2 |
85 |
- lambda { @checker.check }.should_not change { Event.count } |
|
85 |
+ expect { @checker.check }.not_to change { Event.count } |
|
86 | 86 |
update_event = Event.last |
87 |
- update_event.expires_at.should_not == event.expires_at |
|
87 |
+ expect(update_event.expires_at).not_to eq(event.expires_at) |
|
88 | 88 |
end |
89 | 89 |
|
90 | 90 |
it "should always save events when in :all mode" do |
91 |
- lambda { |
|
91 |
+ expect { |
|
92 | 92 |
@valid_options['mode'] = 'all' |
93 | 93 |
@checker.options = @valid_options |
94 | 94 |
@checker.check |
95 | 95 |
@checker.check |
96 |
- }.should change { Event.count }.by(2) |
|
96 |
+ }.to change { Event.count }.by(2) |
|
97 | 97 |
end |
98 | 98 |
|
99 | 99 |
it "should take uniqueness_look_back into account during deduplication" do |
@@ -105,50 +105,50 @@ describe Agents::WebsiteAgent do |
||
105 | 105 |
event.payload = "{}" |
106 | 106 |
event.save |
107 | 107 |
|
108 |
- lambda { |
|
108 |
+ expect { |
|
109 | 109 |
@valid_options['mode'] = 'on_change' |
110 | 110 |
@valid_options['uniqueness_look_back'] = 2 |
111 | 111 |
@checker.options = @valid_options |
112 | 112 |
@checker.check |
113 |
- }.should_not change { Event.count } |
|
113 |
+ }.not_to change { Event.count } |
|
114 | 114 |
|
115 |
- lambda { |
|
115 |
+ expect { |
|
116 | 116 |
@valid_options['mode'] = 'on_change' |
117 | 117 |
@valid_options['uniqueness_look_back'] = 1 |
118 | 118 |
@checker.options = @valid_options |
119 | 119 |
@checker.check |
120 |
- }.should change { Event.count }.by(1) |
|
120 |
+ }.to change { Event.count }.by(1) |
|
121 | 121 |
end |
122 | 122 |
|
123 | 123 |
it "should log an error if the number of results for a set of extraction patterns differs" do |
124 | 124 |
@valid_options['extract']['url']['css'] = "div" |
125 | 125 |
@checker.options = @valid_options |
126 | 126 |
@checker.check |
127 |
- @checker.logs.first.message.should =~ /Got an uneven number of matches/ |
|
127 |
+ expect(@checker.logs.first.message).to match(/Got an uneven number of matches/) |
|
128 | 128 |
end |
129 | 129 |
|
130 | 130 |
it "should accept an array for url" do |
131 | 131 |
@valid_options['url'] = ["http://xkcd.com/1/", "http://xkcd.com/2/"] |
132 | 132 |
@checker.options = @valid_options |
133 |
- lambda { @checker.save! }.should_not raise_error; |
|
134 |
- lambda { @checker.check }.should_not raise_error; |
|
133 |
+ expect { @checker.save! }.not_to raise_error; |
|
134 |
+ expect { @checker.check }.not_to raise_error; |
|
135 | 135 |
end |
136 | 136 |
|
137 | 137 |
it "should parse events from all urls in array" do |
138 |
- lambda { |
|
138 |
+ expect { |
|
139 | 139 |
@valid_options['url'] = ["http://xkcd.com/", "http://xkcd.com/"] |
140 | 140 |
@valid_options['mode'] = 'all' |
141 | 141 |
@checker.options = @valid_options |
142 | 142 |
@checker.check |
143 |
- }.should change { Event.count }.by(2) |
|
143 |
+ }.to change { Event.count }.by(2) |
|
144 | 144 |
end |
145 | 145 |
|
146 | 146 |
it "should follow unique rules when parsing array of urls" do |
147 |
- lambda { |
|
147 |
+ expect { |
|
148 | 148 |
@valid_options['url'] = ["http://xkcd.com/", "http://xkcd.com/"] |
149 | 149 |
@checker.options = @valid_options |
150 | 150 |
@checker.check |
151 |
- }.should change { Event.count }.by(1) |
|
151 |
+ }.to change { Event.count }.by(1) |
|
152 | 152 |
end |
153 | 153 |
end |
154 | 154 |
|
@@ -177,7 +177,7 @@ describe Agents::WebsiteAgent do |
||
177 | 177 |
|
178 | 178 |
checker.check |
179 | 179 |
event = Event.last |
180 |
- event.payload['value'].should == huginn |
|
180 |
+ expect(event.payload['value']).to eq(huginn) |
|
181 | 181 |
end |
182 | 182 |
|
183 | 183 |
it 'should be overridden with force_encoding option' do |
@@ -204,7 +204,7 @@ describe Agents::WebsiteAgent do |
||
204 | 204 |
|
205 | 205 |
checker.check |
206 | 206 |
event = Event.last |
207 |
- event.payload['value'].should == huginn |
|
207 |
+ expect(event.payload['value']).to eq(huginn) |
|
208 | 208 |
end |
209 | 209 |
end |
210 | 210 |
|
@@ -213,20 +213,20 @@ describe Agents::WebsiteAgent do |
||
213 | 213 |
stubbed_time = Time.now |
214 | 214 |
stub(Time).now { stubbed_time } |
215 | 215 |
|
216 |
- @checker.should_not be_working # No events created |
|
216 |
+ expect(@checker).not_to be_working # No events created |
|
217 | 217 |
@checker.check |
218 |
- @checker.reload.should be_working # Just created events |
|
218 |
+ expect(@checker.reload).to be_working # Just created events |
|
219 | 219 |
|
220 | 220 |
@checker.error "oh no!" |
221 |
- @checker.reload.should_not be_working # There is a recent error |
|
221 |
+ expect(@checker.reload).not_to be_working # There is a recent error |
|
222 | 222 |
|
223 | 223 |
stubbed_time = 20.minutes.from_now |
224 | 224 |
@checker.events.delete_all |
225 | 225 |
@checker.check |
226 |
- @checker.reload.should be_working # There is a newer event now |
|
226 |
+ expect(@checker.reload).to be_working # There is a newer event now |
|
227 | 227 |
|
228 | 228 |
stubbed_time = 2.days.from_now |
229 |
- @checker.reload.should_not be_working # Two days have passed without a new event having been created |
|
229 |
+ expect(@checker.reload).not_to be_working # Two days have passed without a new event having been created |
|
230 | 230 |
end |
231 | 231 |
end |
232 | 232 |
|
@@ -234,9 +234,9 @@ describe Agents::WebsiteAgent do |
||
234 | 234 |
it "parses CSS" do |
235 | 235 |
@checker.check |
236 | 236 |
event = Event.last |
237 |
- event.payload['url'].should == "http://imgs.xkcd.com/comics/evolving.png" |
|
238 |
- event.payload['title'].should == "Evolving" |
|
239 |
- event.payload['hovertext'].should =~ /^Biologists play reverse/ |
|
237 |
+ expect(event.payload['url']).to eq("http://imgs.xkcd.com/comics/evolving.png") |
|
238 |
+ expect(event.payload['title']).to eq("Evolving") |
|
239 |
+ expect(event.payload['hovertext']).to match(/^Biologists play reverse/) |
|
240 | 240 |
end |
241 | 241 |
|
242 | 242 |
it "parses XPath" do |
@@ -247,9 +247,9 @@ describe Agents::WebsiteAgent do |
||
247 | 247 |
@checker.options = @valid_options |
248 | 248 |
@checker.check |
249 | 249 |
event = Event.last |
250 |
- event.payload['url'].should == "http://imgs.xkcd.com/comics/evolving.png" |
|
251 |
- event.payload['title'].should == "Evolving" |
|
252 |
- event.payload['hovertext'].should =~ /^Biologists play reverse/ |
|
250 |
+ expect(event.payload['url']).to eq("http://imgs.xkcd.com/comics/evolving.png") |
|
251 |
+ expect(event.payload['title']).to eq("Evolving") |
|
252 |
+ expect(event.payload['hovertext']).to match(/^Biologists play reverse/) |
|
253 | 253 |
end |
254 | 254 |
|
255 | 255 |
it "should turn relative urls to absolute" do |
@@ -268,7 +268,7 @@ describe Agents::WebsiteAgent do |
||
268 | 268 |
rel.save! |
269 | 269 |
rel.check |
270 | 270 |
event = Event.last |
271 |
- event.payload['url'].should == "http://xkcd.com/about" |
|
271 |
+ expect(event.payload['url']).to eq("http://xkcd.com/about") |
|
272 | 272 |
end |
273 | 273 |
|
274 | 274 |
it "should return an integer value if XPath evaluates to one" do |
@@ -287,7 +287,7 @@ describe Agents::WebsiteAgent do |
||
287 | 287 |
rel.save! |
288 | 288 |
rel.check |
289 | 289 |
event = Event.last |
290 |
- event.payload['num_links'].should == "9" |
|
290 |
+ expect(event.payload['num_links']).to eq("9") |
|
291 | 291 |
end |
292 | 292 |
|
293 | 293 |
it "should return all texts concatenated if XPath returns many text nodes" do |
@@ -306,7 +306,7 @@ describe Agents::WebsiteAgent do |
||
306 | 306 |
rel.save! |
307 | 307 |
rel.check |
308 | 308 |
event = Event.last |
309 |
- event.payload['slogan'].should == "A webcomic of romance, sarcasm, math, and language." |
|
309 |
+ expect(event.payload['slogan']).to eq("A webcomic of romance, sarcasm, math, and language.") |
|
310 | 310 |
end |
311 | 311 |
|
312 | 312 |
it "should interpolate _response_" do |
@@ -317,7 +317,7 @@ describe Agents::WebsiteAgent do |
||
317 | 317 |
@checker.options = @valid_options |
318 | 318 |
@checker.check |
319 | 319 |
event = Event.last |
320 |
- event.payload['response_info'].should == 'The reponse was 200 OK.' |
|
320 |
+ expect(event.payload['response_info']).to eq('The reponse was 200 OK.') |
|
321 | 321 |
end |
322 | 322 |
|
323 | 323 |
describe "JSON" do |
@@ -346,8 +346,8 @@ describe Agents::WebsiteAgent do |
||
346 | 346 |
|
347 | 347 |
checker.check |
348 | 348 |
event = Event.last |
349 |
- event.payload['version'].should == 2 |
|
350 |
- event.payload['title'].should == "hello!" |
|
349 |
+ expect(event.payload['version']).to eq(2) |
|
350 |
+ expect(event.payload['title']).to eq("hello!") |
|
351 | 351 |
end |
352 | 352 |
|
353 | 353 |
it "can handle arrays" do |
@@ -375,17 +375,17 @@ describe Agents::WebsiteAgent do |
||
375 | 375 |
checker.user = users(:bob) |
376 | 376 |
checker.save! |
377 | 377 |
|
378 |
- lambda { |
|
378 |
+ expect { |
|
379 | 379 |
checker.check |
380 |
- }.should change { Event.count }.by(2) |
|
380 |
+ }.to change { Event.count }.by(2) |
|
381 | 381 |
|
382 | 382 |
event = Event.all[-1] |
383 |
- event.payload['version'].should == 2.5 |
|
384 |
- event.payload['title'].should == "second" |
|
383 |
+ expect(event.payload['version']).to eq(2.5) |
|
384 |
+ expect(event.payload['title']).to eq("second") |
|
385 | 385 |
|
386 | 386 |
event = Event.all[-2] |
387 |
- event.payload['version'].should == 2 |
|
388 |
- event.payload['title'].should == "first" |
|
387 |
+ expect(event.payload['version']).to eq(2) |
|
388 |
+ expect(event.payload['title']).to eq("first") |
|
389 | 389 |
end |
390 | 390 |
|
391 | 391 |
it "stores the whole object if :extract is not specified" do |
@@ -409,8 +409,8 @@ describe Agents::WebsiteAgent do |
||
409 | 409 |
|
410 | 410 |
checker.check |
411 | 411 |
event = Event.last |
412 |
- event.payload['response']['version'].should == 2 |
|
413 |
- event.payload['response']['title'].should == "hello!" |
|
412 |
+ expect(event.payload['response']['version']).to eq(2) |
|
413 |
+ expect(event.payload['response']['title']).to eq("hello!") |
|
414 | 414 |
end |
415 | 415 |
end |
416 | 416 |
|
@@ -442,27 +442,27 @@ fire: hot |
||
442 | 442 |
'property' => { 'regexp' => '^(?<word>.+?): (?<property>.+)$', index: 'property' }, |
443 | 443 |
}) |
444 | 444 |
|
445 |
- lambda { |
|
445 |
+ expect { |
|
446 | 446 |
@checker.check |
447 |
- }.should change { Event.count }.by(2) |
|
447 |
+ }.to change { Event.count }.by(2) |
|
448 | 448 |
|
449 | 449 |
event1, event2 = Event.last(2) |
450 |
- event1.payload['word'].should == 'water' |
|
451 |
- event1.payload['property'].should == 'wet' |
|
452 |
- event2.payload['word'].should == 'fire' |
|
453 |
- event2.payload['property'].should == 'hot' |
|
450 |
+ expect(event1.payload['word']).to eq('water') |
|
451 |
+ expect(event1.payload['property']).to eq('wet') |
|
452 |
+ expect(event2.payload['word']).to eq('fire') |
|
453 |
+ expect(event2.payload['property']).to eq('hot') |
|
454 | 454 |
end |
455 | 455 |
|
456 | 456 |
it "works with regexp with named capture" do |
457 |
- lambda { |
|
457 |
+ expect { |
|
458 | 458 |
@checker.check |
459 |
- }.should change { Event.count }.by(2) |
|
459 |
+ }.to change { Event.count }.by(2) |
|
460 | 460 |
|
461 | 461 |
event1, event2 = Event.last(2) |
462 |
- event1.payload['word'].should == 'water' |
|
463 |
- event1.payload['property'].should == 'wet' |
|
464 |
- event2.payload['word'].should == 'fire' |
|
465 |
- event2.payload['property'].should == 'hot' |
|
462 |
+ expect(event1.payload['word']).to eq('water') |
|
463 |
+ expect(event1.payload['property']).to eq('wet') |
|
464 |
+ expect(event2.payload['word']).to eq('fire') |
|
465 |
+ expect(event2.payload['property']).to eq('hot') |
|
466 | 466 |
end |
467 | 467 |
end |
468 | 468 |
end |
@@ -478,14 +478,14 @@ fire: hot |
||
478 | 478 |
end |
479 | 479 |
|
480 | 480 |
it "should scrape from the url element in incoming event payload" do |
481 |
- lambda { |
|
481 |
+ expect { |
|
482 | 482 |
@checker.options = @valid_options |
483 | 483 |
@checker.receive([@event]) |
484 |
- }.should change { Event.count }.by(1) |
|
484 |
+ }.to change { Event.count }.by(1) |
|
485 | 485 |
end |
486 | 486 |
|
487 | 487 |
it "should interpolate values from incoming event payload" do |
488 |
- lambda { |
|
488 |
+ expect { |
|
489 | 489 |
@valid_options['extract'] = { |
490 | 490 |
'from' => { |
491 | 491 |
'xpath' => '*[1]', |
@@ -498,18 +498,18 @@ fire: hot |
||
498 | 498 |
} |
499 | 499 |
@checker.options = @valid_options |
500 | 500 |
@checker.receive([@event]) |
501 |
- }.should change { Event.count }.by(1) |
|
501 |
+ }.to change { Event.count }.by(1) |
|
502 | 502 |
|
503 |
- Event.last.payload.should == { |
|
503 |
+ expect(Event.last.payload).to eq({ |
|
504 | 504 |
'from' => 'http://xkcd.com', |
505 | 505 |
'to' => 'http://dynamic.xkcd.com/random/comic/', |
506 |
- } |
|
506 |
+ }) |
|
507 | 507 |
end |
508 | 508 |
|
509 | 509 |
it "should interpolate values from incoming event payload and _response_" do |
510 | 510 |
@event.payload['title'] = 'XKCD' |
511 | 511 |
|
512 |
- lambda { |
|
512 |
+ expect { |
|
513 | 513 |
@valid_options['extract'] = { |
514 | 514 |
'response_info' => @valid_options['extract']['url'].merge( |
515 | 515 |
'value' => '{% capture sentence %}The reponse from {{title}} was {{_response_.status}} {{_response_.headers.X-Status-Message}}.{% endcapture %}{{sentence | to_xpath}}' |
@@ -517,9 +517,9 @@ fire: hot |
||
517 | 517 |
} |
518 | 518 |
@checker.options = @valid_options |
519 | 519 |
@checker.receive([@event]) |
520 |
- }.should change { Event.count }.by(1) |
|
520 |
+ }.to change { Event.count }.by(1) |
|
521 | 521 |
|
522 |
- Event.last.payload['response_info'].should == 'The reponse from XKCD was 200 OK.' |
|
522 |
+ expect(Event.last.payload['response_info']).to eq('The reponse from XKCD was 200 OK.') |
|
523 | 523 |
end |
524 | 524 |
end |
525 | 525 |
end |
@@ -549,8 +549,8 @@ fire: hot |
||
549 | 549 |
|
550 | 550 |
describe "#check" do |
551 | 551 |
it "should check for changes" do |
552 |
- lambda { @checker.check }.should change { Event.count }.by(1) |
|
553 |
- lambda { @checker.check }.should_not change { Event.count } |
|
552 |
+ expect { @checker.check }.to change { Event.count }.by(1) |
|
553 |
+ expect { @checker.check }.not_to change { Event.count } |
|
554 | 554 |
end |
555 | 555 |
end |
556 | 556 |
end |
@@ -578,7 +578,7 @@ fire: hot |
||
578 | 578 |
|
579 | 579 |
describe "#check" do |
580 | 580 |
it "should check for changes" do |
581 |
- lambda { @checker.check }.should change { Event.count }.by(1) |
|
581 |
+ expect { @checker.check }.to change { Event.count }.by(1) |
|
582 | 582 |
end |
583 | 583 |
end |
584 | 584 |
end |
@@ -38,8 +38,8 @@ describe Agents::WeiboPublishAgent do |
||
38 | 38 |
event2.save! |
39 | 39 |
|
40 | 40 |
Agents::WeiboPublishAgent.async_receive(@checker.id, [event1.id, event2.id]) |
41 |
- @sent_messages.count.should eq(2) |
|
42 |
- @checker.events.count.should eq(2) |
|
41 |
+ expect(@sent_messages.count).to eq(2) |
|
42 |
+ expect(@checker.events.count).to eq(2) |
|
43 | 43 |
end |
44 | 44 |
end |
45 | 45 |
|
@@ -51,20 +51,20 @@ describe Agents::WeiboPublishAgent do |
||
51 | 51 |
event.save! |
52 | 52 |
|
53 | 53 |
Agents::WeiboPublishAgent.async_receive(@checker.id, [event.id]) |
54 |
- @sent_messages.count.should eq(1) |
|
55 |
- @checker.events.count.should eq(1) |
|
56 |
- @sent_messages.first.include?("t.co").should_not be_truthy |
|
54 |
+ expect(@sent_messages.count).to eq(1) |
|
55 |
+ expect(@checker.events.count).to eq(1) |
|
56 |
+ expect(@sent_messages.first.include?("t.co")).not_to be_truthy |
|
57 | 57 |
end |
58 | 58 |
end |
59 | 59 |
|
60 | 60 |
describe '#working?' do |
61 | 61 |
it 'checks if events have been received within the expected receive period' do |
62 |
- @checker.should_not be_working # No events received |
|
62 |
+ expect(@checker).not_to be_working # No events received |
|
63 | 63 |
Agents::WeiboPublishAgent.async_receive(@checker.id, [@event.id]) |
64 |
- @checker.reload.should be_working # Just received events |
|
64 |
+ expect(@checker.reload).to be_working # Just received events |
|
65 | 65 |
two_days_from_now = 2.days.from_now |
66 | 66 |
stub(Time).now { two_days_from_now } |
67 |
- @checker.reload.should_not be_working # More time has passed than the expected receive period without any new events |
|
67 |
+ expect(@checker.reload).not_to be_working # More time has passed than the expected receive period without any new events |
|
68 | 68 |
end |
69 | 69 |
end |
70 |
-end |
|
70 |
+end |
@@ -21,8 +21,8 @@ describe Agents::WeiboUserAgent do |
||
21 | 21 |
|
22 | 22 |
describe "#check" do |
23 | 23 |
it "should check for changes" do |
24 |
- lambda { @checker.check }.should change { Event.count }.by(1) |
|
24 |
+ expect { @checker.check }.to change { Event.count }.by(1) |
|
25 | 25 |
end |
26 | 26 |
end |
27 | 27 |
|
28 |
-end |
|
28 |
+end |
@@ -13,17 +13,17 @@ shared_examples_for Oauthable do |
||
13 | 13 |
end |
14 | 14 |
|
15 | 15 |
it "should be oauthable" do |
16 |
- @agent.oauthable?.should == true |
|
16 |
+ expect(@agent.oauthable?).to eq(true) |
|
17 | 17 |
end |
18 | 18 |
|
19 | 19 |
describe "valid_services_for" do |
20 | 20 |
it "should return all available services without specifying valid_oauth_providers" do |
21 | 21 |
@agent = Agents::OauthableTestAgent.new |
22 |
- @agent.valid_services_for(users(:bob)).collect(&:id).sort.should == [services(:generic), services(:global)].collect(&:id).sort |
|
22 |
+ expect(@agent.valid_services_for(users(:bob)).collect(&:id).sort).to eq([services(:generic), services(:global)].collect(&:id).sort) |
|
23 | 23 |
end |
24 | 24 |
|
25 | 25 |
it "should filter the services based on the agent defaults" do |
26 |
- @agent.valid_services_for(users(:bob)).to_a.should == Service.where(provider: @agent.valid_oauth_providers) |
|
26 |
+ expect(@agent.valid_services_for(users(:bob)).to_a).to eq(Service.where(provider: @agent.valid_oauth_providers)) |
|
27 | 27 |
end |
28 | 28 |
end |
29 | 29 |
end |
@@ -7,23 +7,23 @@ describe Event do |
||
7 | 7 |
event.lat = 2 |
8 | 8 |
event.lng = 3 |
9 | 9 |
event.save! |
10 |
- Event.with_location.pluck(:id).should == [event.id] |
|
10 |
+ expect(Event.with_location.pluck(:id)).to eq([event.id]) |
|
11 | 11 |
|
12 | 12 |
event.lat = nil |
13 | 13 |
event.save! |
14 |
- Event.with_location.should be_empty |
|
14 |
+ expect(Event.with_location).to be_empty |
|
15 | 15 |
end |
16 | 16 |
end |
17 | 17 |
|
18 | 18 |
describe "#location" do |
19 | 19 |
it "returns a default hash when an event does not have a location" do |
20 | 20 |
event = events(:bob_website_agent_event) |
21 |
- event.location.should == Location.new( |
|
21 |
+ expect(event.location).to eq(Location.new( |
|
22 | 22 |
lat: nil, |
23 | 23 |
lng: nil, |
24 | 24 |
radius: 0.0, |
25 | 25 |
speed: nil, |
26 |
- course: nil) |
|
26 |
+ course: nil)) |
|
27 | 27 |
end |
28 | 28 |
|
29 | 29 |
it "returns a hash containing location information" do |
@@ -36,12 +36,12 @@ describe Event do |
||
36 | 36 |
course: 90.0, |
37 | 37 |
} |
38 | 38 |
event.save! |
39 |
- event.location.should == Location.new( |
|
39 |
+ expect(event.location).to eq(Location.new( |
|
40 | 40 |
lat: 2.0, |
41 | 41 |
lng: 3.0, |
42 | 42 |
radius: 0.0, |
43 | 43 |
speed: 0.5, |
44 |
- course: 90.0) |
|
44 |
+ course: 90.0)) |
|
45 | 45 |
end |
46 | 46 |
end |
47 | 47 |
|
@@ -50,14 +50,14 @@ describe Event do |
||
50 | 50 |
events(:bob_website_agent_event).lat = 2 |
51 | 51 |
events(:bob_website_agent_event).lng = 3 |
52 | 52 |
events(:bob_website_agent_event).created_at = 2.weeks.ago |
53 |
- lambda { |
|
53 |
+ expect { |
|
54 | 54 |
events(:bob_website_agent_event).reemit! |
55 |
- }.should change { Event.count }.by(1) |
|
56 |
- Event.last.payload.should == events(:bob_website_agent_event).payload |
|
57 |
- Event.last.agent.should == events(:bob_website_agent_event).agent |
|
58 |
- Event.last.lat.should == 2 |
|
59 |
- Event.last.lng.should == 3 |
|
60 |
- Event.last.created_at.to_i.should be_within(2).of(Time.now.to_i) |
|
55 |
+ }.to change { Event.count }.by(1) |
|
56 |
+ expect(Event.last.payload).to eq(events(:bob_website_agent_event).payload) |
|
57 |
+ expect(Event.last.agent).to eq(events(:bob_website_agent_event).agent) |
|
58 |
+ expect(Event.last.lat).to eq(2) |
|
59 |
+ expect(Event.last.lng).to eq(3) |
|
60 |
+ expect(Event.last.created_at.to_i).to be_within(2).of(Time.now.to_i) |
|
61 | 61 |
end |
62 | 62 |
end |
63 | 63 |
|
@@ -76,31 +76,31 @@ describe Event do |
||
76 | 76 |
stub(Time).now { current_time } |
77 | 77 |
|
78 | 78 |
Event.cleanup_expired! |
79 |
- Event.find_by_id(half_hour_event.id).should_not be_nil |
|
80 |
- Event.find_by_id(one_hour_event.id).should_not be_nil |
|
81 |
- Event.find_by_id(two_hour_event.id).should_not be_nil |
|
82 |
- Event.find_by_id(three_hour_event.id).should_not be_nil |
|
83 |
- Event.find_by_id(non_expiring_event.id).should_not be_nil |
|
84 |
- agents(:bob_weather_agent).reload.events_count.should == initial_bob_count |
|
85 |
- agents(:jane_weather_agent).reload.events_count.should == initial_jane_count |
|
79 |
+ expect(Event.find_by_id(half_hour_event.id)).not_to be_nil |
|
80 |
+ expect(Event.find_by_id(one_hour_event.id)).not_to be_nil |
|
81 |
+ expect(Event.find_by_id(two_hour_event.id)).not_to be_nil |
|
82 |
+ expect(Event.find_by_id(three_hour_event.id)).not_to be_nil |
|
83 |
+ expect(Event.find_by_id(non_expiring_event.id)).not_to be_nil |
|
84 |
+ expect(agents(:bob_weather_agent).reload.events_count).to eq(initial_bob_count) |
|
85 |
+ expect(agents(:jane_weather_agent).reload.events_count).to eq(initial_jane_count) |
|
86 | 86 |
|
87 | 87 |
current_time = 119.minutes.from_now # move almost 2 hours into the future |
88 | 88 |
Event.cleanup_expired! |
89 |
- Event.find_by_id(half_hour_event.id).should be_nil |
|
90 |
- Event.find_by_id(one_hour_event.id).should be_nil |
|
91 |
- Event.find_by_id(two_hour_event.id).should_not be_nil |
|
92 |
- Event.find_by_id(three_hour_event.id).should_not be_nil |
|
93 |
- Event.find_by_id(non_expiring_event.id).should_not be_nil |
|
94 |
- agents(:bob_weather_agent).reload.events_count.should == initial_bob_count - 1 |
|
95 |
- agents(:jane_weather_agent).reload.events_count.should == initial_jane_count - 1 |
|
89 |
+ expect(Event.find_by_id(half_hour_event.id)).to be_nil |
|
90 |
+ expect(Event.find_by_id(one_hour_event.id)).to be_nil |
|
91 |
+ expect(Event.find_by_id(two_hour_event.id)).not_to be_nil |
|
92 |
+ expect(Event.find_by_id(three_hour_event.id)).not_to be_nil |
|
93 |
+ expect(Event.find_by_id(non_expiring_event.id)).not_to be_nil |
|
94 |
+ expect(agents(:bob_weather_agent).reload.events_count).to eq(initial_bob_count - 1) |
|
95 |
+ expect(agents(:jane_weather_agent).reload.events_count).to eq(initial_jane_count - 1) |
|
96 | 96 |
|
97 | 97 |
current_time = 2.minutes.from_now # move 2 minutes further into the future |
98 | 98 |
Event.cleanup_expired! |
99 |
- Event.find_by_id(two_hour_event.id).should be_nil |
|
100 |
- Event.find_by_id(three_hour_event.id).should_not be_nil |
|
101 |
- Event.find_by_id(non_expiring_event.id).should_not be_nil |
|
102 |
- agents(:bob_weather_agent).reload.events_count.should == initial_bob_count - 1 |
|
103 |
- agents(:jane_weather_agent).reload.events_count.should == initial_jane_count - 2 |
|
99 |
+ expect(Event.find_by_id(two_hour_event.id)).to be_nil |
|
100 |
+ expect(Event.find_by_id(three_hour_event.id)).not_to be_nil |
|
101 |
+ expect(Event.find_by_id(non_expiring_event.id)).not_to be_nil |
|
102 |
+ expect(agents(:bob_weather_agent).reload.events_count).to eq(initial_bob_count - 1) |
|
103 |
+ expect(agents(:jane_weather_agent).reload.events_count).to eq(initial_jane_count - 2) |
|
104 | 104 |
end |
105 | 105 |
|
106 | 106 |
it "doesn't touch Events with no expired_at" do |
@@ -113,37 +113,37 @@ describe Event do |
||
113 | 113 |
stub(Time).now { current_time } |
114 | 114 |
|
115 | 115 |
Event.cleanup_expired! |
116 |
- Event.find_by_id(event.id).should_not be_nil |
|
116 |
+ expect(Event.find_by_id(event.id)).not_to be_nil |
|
117 | 117 |
current_time = 2.days.from_now |
118 | 118 |
Event.cleanup_expired! |
119 |
- Event.find_by_id(event.id).should_not be_nil |
|
119 |
+ expect(Event.find_by_id(event.id)).not_to be_nil |
|
120 | 120 |
end |
121 | 121 |
end |
122 | 122 |
|
123 | 123 |
describe "after destroy" do |
124 | 124 |
it "nullifies any dependent AgentLogs" do |
125 |
- agent_logs(:log_for_jane_website_agent).outbound_event_id.should be_present |
|
126 |
- agent_logs(:log_for_bob_website_agent).outbound_event_id.should be_present |
|
125 |
+ expect(agent_logs(:log_for_jane_website_agent).outbound_event_id).to be_present |
|
126 |
+ expect(agent_logs(:log_for_bob_website_agent).outbound_event_id).to be_present |
|
127 | 127 |
|
128 | 128 |
agent_logs(:log_for_bob_website_agent).outbound_event.destroy |
129 | 129 |
|
130 |
- agent_logs(:log_for_jane_website_agent).reload.outbound_event_id.should be_present |
|
131 |
- agent_logs(:log_for_bob_website_agent).reload.outbound_event_id.should be_nil |
|
130 |
+ expect(agent_logs(:log_for_jane_website_agent).reload.outbound_event_id).to be_present |
|
131 |
+ expect(agent_logs(:log_for_bob_website_agent).reload.outbound_event_id).to be_nil |
|
132 | 132 |
end |
133 | 133 |
end |
134 | 134 |
|
135 | 135 |
describe "caches" do |
136 | 136 |
describe "when an event is created" do |
137 | 137 |
it "updates a counter cache on agent" do |
138 |
- lambda { |
|
138 |
+ expect { |
|
139 | 139 |
agents(:jane_weather_agent).events.create!(:user => users(:jane)) |
140 |
- }.should change { agents(:jane_weather_agent).reload.events_count }.by(1) |
|
140 |
+ }.to change { agents(:jane_weather_agent).reload.events_count }.by(1) |
|
141 | 141 |
end |
142 | 142 |
|
143 | 143 |
it "updates last_event_at on agent" do |
144 |
- lambda { |
|
144 |
+ expect { |
|
145 | 145 |
agents(:jane_weather_agent).events.create!(:user => users(:jane)) |
146 |
- }.should change { agents(:jane_weather_agent).reload.last_event_at } |
|
146 |
+ }.to change { agents(:jane_weather_agent).reload.last_event_at } |
|
147 | 147 |
end |
148 | 148 |
end |
149 | 149 |
|
@@ -153,9 +153,9 @@ describe Event do |
||
153 | 153 |
|
154 | 154 |
agents(:jane_weather_agent).update_attribute :last_event_at, 2.days.ago |
155 | 155 |
|
156 |
- lambda { |
|
156 |
+ expect { |
|
157 | 157 |
event.update_attribute :payload, { 'hello' => 'world' } |
158 |
- }.should_not change { agents(:jane_weather_agent).reload.last_event_at } |
|
158 |
+ }.not_to change { agents(:jane_weather_agent).reload.last_event_at } |
|
159 | 159 |
end |
160 | 160 |
end |
161 | 161 |
end |
@@ -180,12 +180,12 @@ describe EventDrop do |
||
180 | 180 |
end |
181 | 181 |
|
182 | 182 |
it 'should be created via Agent#to_liquid' do |
183 |
- @event.to_liquid.class.should be(EventDrop) |
|
183 |
+ expect(@event.to_liquid.class).to be(EventDrop) |
|
184 | 184 |
end |
185 | 185 |
|
186 | 186 |
it 'should have attributes of its payload' do |
187 | 187 |
t = '{{title}}: {{url}}' |
188 |
- interpolate(t, @event).should eq('some title: http://some.site.example.org/') |
|
188 |
+ expect(interpolate(t, @event)).to eq('some title: http://some.site.example.org/') |
|
189 | 189 |
end |
190 | 190 |
|
191 | 191 |
it 'should use created_at from the payload if it exists' do |
@@ -194,27 +194,27 @@ describe EventDrop do |
||
194 | 194 |
@event.payload['created_at'] = created_at.strftime("%s") |
195 | 195 |
@event.save! |
196 | 196 |
t = '{{created_at | date:"%s" }}' |
197 |
- interpolate(t, @event).should eq(created_at.strftime("%s")) |
|
197 |
+ expect(interpolate(t, @event)).to eq(created_at.strftime("%s")) |
|
198 | 198 |
end |
199 | 199 |
|
200 | 200 |
it 'should be iteratable' do |
201 | 201 |
# to_liquid returns self |
202 | 202 |
t = "{% for pair in to_liquid %}{{pair | join:':' }}\n{% endfor %}" |
203 |
- interpolate(t, @event).should eq("title:some title\nurl:http://some.site.example.org/\n") |
|
203 |
+ expect(interpolate(t, @event)).to eq("title:some title\nurl:http://some.site.example.org/\n") |
|
204 | 204 |
end |
205 | 205 |
|
206 | 206 |
it 'should have agent' do |
207 | 207 |
t = '{{agent.name}}' |
208 |
- interpolate(t, @event).should eq('SF Weather') |
|
208 |
+ expect(interpolate(t, @event)).to eq('SF Weather') |
|
209 | 209 |
end |
210 | 210 |
|
211 | 211 |
it 'should have created_at' do |
212 | 212 |
t = '{{created_at | date:"%FT%T%z" }}' |
213 |
- interpolate(t, @event).should eq(@event.created_at.strftime("%FT%T%z")) |
|
213 |
+ expect(interpolate(t, @event)).to eq(@event.created_at.strftime("%FT%T%z")) |
|
214 | 214 |
end |
215 | 215 |
|
216 | 216 |
it 'should have _location_' do |
217 | 217 |
t = '{{_location_.lat}},{{_location_.lng}}' |
218 |
- interpolate(t, @event).should eq("2.0,3.0") |
|
218 |
+ expect(interpolate(t, @event)).to eq("2.0,3.0") |
|
219 | 219 |
end |
220 | 220 |
end |
@@ -82,7 +82,7 @@ describe ScenarioImport do |
||
82 | 82 |
|
83 | 83 |
describe "initialization" do |
84 | 84 |
it "is initialized with an attributes hash" do |
85 |
- ScenarioImport.new(:url => "http://google.com").url.should == "http://google.com" |
|
85 |
+ expect(ScenarioImport.new(:url => "http://google.com").url).to eq("http://google.com") |
|
86 | 86 |
end |
87 | 87 |
end |
88 | 88 |
|
@@ -94,79 +94,79 @@ describe ScenarioImport do |
||
94 | 94 |
end |
95 | 95 |
|
96 | 96 |
it "is not valid when none of file, url, or data are present" do |
97 |
- subject.should_not be_valid |
|
98 |
- subject.should have(1).error_on(:base) |
|
99 |
- subject.errors[:base].should include("Please provide either a Scenario JSON File or a Public Scenario URL.") |
|
97 |
+ expect(subject).not_to be_valid |
|
98 |
+ expect(subject).to have(1).error_on(:base) |
|
99 |
+ expect(subject.errors[:base]).to include("Please provide either a Scenario JSON File or a Public Scenario URL.") |
|
100 | 100 |
end |
101 | 101 |
|
102 | 102 |
describe "data" do |
103 | 103 |
it "should be invalid with invalid data" do |
104 | 104 |
subject.data = invalid_data |
105 |
- subject.should_not be_valid |
|
106 |
- subject.should have(1).error_on(:base) |
|
105 |
+ expect(subject).not_to be_valid |
|
106 |
+ expect(subject).to have(1).error_on(:base) |
|
107 | 107 |
|
108 | 108 |
subject.data = "foo" |
109 |
- subject.should_not be_valid |
|
110 |
- subject.should have(1).error_on(:base) |
|
109 |
+ expect(subject).not_to be_valid |
|
110 |
+ expect(subject).to have(1).error_on(:base) |
|
111 | 111 |
|
112 | 112 |
# It also clears the data when invalid |
113 |
- subject.data.should be_nil |
|
113 |
+ expect(subject.data).to be_nil |
|
114 | 114 |
end |
115 | 115 |
|
116 | 116 |
it "should be valid with valid data" do |
117 | 117 |
subject.data = valid_data |
118 |
- subject.should be_valid |
|
118 |
+ expect(subject).to be_valid |
|
119 | 119 |
end |
120 | 120 |
end |
121 | 121 |
|
122 | 122 |
describe "url" do |
123 | 123 |
it "should be invalid with an unreasonable URL" do |
124 | 124 |
subject.url = "foo" |
125 |
- subject.should_not be_valid |
|
126 |
- subject.should have(1).error_on(:url) |
|
127 |
- subject.errors[:url].should include("appears to be invalid") |
|
125 |
+ expect(subject).not_to be_valid |
|
126 |
+ expect(subject).to have(1).error_on(:url) |
|
127 |
+ expect(subject.errors[:url]).to include("appears to be invalid") |
|
128 | 128 |
end |
129 | 129 |
|
130 | 130 |
it "should be invalid when the referenced url doesn't contain a scenario" do |
131 | 131 |
stub_request(:get, "http://example.com/scenarios/1/export.json").to_return(:status => 200, :body => invalid_data) |
132 | 132 |
subject.url = "http://example.com/scenarios/1/export.json" |
133 |
- subject.should_not be_valid |
|
134 |
- subject.errors[:base].should include("The provided data does not appear to be a valid Scenario.") |
|
133 |
+ expect(subject).not_to be_valid |
|
134 |
+ expect(subject.errors[:base]).to include("The provided data does not appear to be a valid Scenario.") |
|
135 | 135 |
end |
136 | 136 |
|
137 | 137 |
it "should be valid when the url points to a valid scenario" do |
138 | 138 |
stub_request(:get, "http://example.com/scenarios/1/export.json").to_return(:status => 200, :body => valid_data) |
139 | 139 |
subject.url = "http://example.com/scenarios/1/export.json" |
140 |
- subject.should be_valid |
|
140 |
+ expect(subject).to be_valid |
|
141 | 141 |
end |
142 | 142 |
end |
143 | 143 |
|
144 | 144 |
describe "file" do |
145 | 145 |
it "should be invalid when the uploaded file doesn't contain a scenario" do |
146 | 146 |
subject.file = StringIO.new("foo") |
147 |
- subject.should_not be_valid |
|
148 |
- subject.errors[:base].should include("The provided data does not appear to be a valid Scenario.") |
|
147 |
+ expect(subject).not_to be_valid |
|
148 |
+ expect(subject.errors[:base]).to include("The provided data does not appear to be a valid Scenario.") |
|
149 | 149 |
|
150 | 150 |
subject.file = StringIO.new(invalid_data) |
151 |
- subject.should_not be_valid |
|
152 |
- subject.errors[:base].should include("The provided data does not appear to be a valid Scenario.") |
|
151 |
+ expect(subject).not_to be_valid |
|
152 |
+ expect(subject.errors[:base]).to include("The provided data does not appear to be a valid Scenario.") |
|
153 | 153 |
end |
154 | 154 |
|
155 | 155 |
it "should be valid with a valid uploaded scenario" do |
156 | 156 |
subject.file = StringIO.new(valid_data) |
157 |
- subject.should be_valid |
|
157 |
+ expect(subject).to be_valid |
|
158 | 158 |
end |
159 | 159 |
end |
160 | 160 |
end |
161 | 161 |
|
162 | 162 |
describe "#dangerous?" do |
163 | 163 |
it "returns false on most Agents" do |
164 |
- ScenarioImport.new(:data => valid_data).should_not be_dangerous |
|
164 |
+ expect(ScenarioImport.new(:data => valid_data)).not_to be_dangerous |
|
165 | 165 |
end |
166 | 166 |
|
167 | 167 |
it "returns true if a ShellCommandAgent is present" do |
168 | 168 |
valid_parsed_data[:agents][0][:type] = "Agents::ShellCommandAgent" |
169 |
- ScenarioImport.new(:data => valid_parsed_data.to_json).should be_dangerous |
|
169 |
+ expect(ScenarioImport.new(:data => valid_parsed_data.to_json)).to be_dangerous |
|
170 | 170 |
end |
171 | 171 |
end |
172 | 172 |
|
@@ -180,57 +180,57 @@ describe ScenarioImport do |
||
180 | 180 |
context "when this scenario has never been seen before" do |
181 | 181 |
describe "#import" do |
182 | 182 |
it "makes a new scenario" do |
183 |
- lambda { |
|
183 |
+ expect { |
|
184 | 184 |
scenario_import.import(:skip_agents => true) |
185 |
- }.should change { users(:bob).scenarios.count }.by(1) |
|
186 |
- |
|
187 |
- scenario_import.scenario.name.should == name |
|
188 |
- scenario_import.scenario.description.should == description |
|
189 |
- scenario_import.scenario.guid.should == guid |
|
190 |
- scenario_import.scenario.tag_fg_color.should == tag_fg_color |
|
191 |
- scenario_import.scenario.tag_bg_color.should == tag_bg_color |
|
192 |
- scenario_import.scenario.source_url.should == source_url |
|
193 |
- scenario_import.scenario.public.should be_falsey |
|
185 |
+ }.to change { users(:bob).scenarios.count }.by(1) |
|
186 |
+ |
|
187 |
+ expect(scenario_import.scenario.name).to eq(name) |
|
188 |
+ expect(scenario_import.scenario.description).to eq(description) |
|
189 |
+ expect(scenario_import.scenario.guid).to eq(guid) |
|
190 |
+ expect(scenario_import.scenario.tag_fg_color).to eq(tag_fg_color) |
|
191 |
+ expect(scenario_import.scenario.tag_bg_color).to eq(tag_bg_color) |
|
192 |
+ expect(scenario_import.scenario.source_url).to eq(source_url) |
|
193 |
+ expect(scenario_import.scenario.public).to be_falsey |
|
194 | 194 |
end |
195 | 195 |
|
196 | 196 |
it "creates the Agents" do |
197 |
- lambda { |
|
197 |
+ expect { |
|
198 | 198 |
scenario_import.import |
199 |
- }.should change { users(:bob).agents.count }.by(2) |
|
199 |
+ }.to change { users(:bob).agents.count }.by(2) |
|
200 | 200 |
|
201 | 201 |
weather_agent = scenario_import.scenario.agents.find_by(:guid => "a-weather-agent") |
202 | 202 |
trigger_agent = scenario_import.scenario.agents.find_by(:guid => "a-trigger-agent") |
203 | 203 |
|
204 |
- weather_agent.name.should == "a weather agent" |
|
205 |
- weather_agent.schedule.should == "5pm" |
|
206 |
- weather_agent.keep_events_for.should == 14 |
|
207 |
- weather_agent.propagate_immediately.should be_falsey |
|
208 |
- weather_agent.should be_disabled |
|
209 |
- weather_agent.memory.should be_empty |
|
210 |
- weather_agent.options.should == weather_agent_options |
|
211 |
- |
|
212 |
- trigger_agent.name.should == "listen for weather" |
|
213 |
- trigger_agent.sources.should == [weather_agent] |
|
214 |
- trigger_agent.schedule.should be_nil |
|
215 |
- trigger_agent.keep_events_for.should == 0 |
|
216 |
- trigger_agent.propagate_immediately.should be_truthy |
|
217 |
- trigger_agent.should_not be_disabled |
|
218 |
- trigger_agent.memory.should be_empty |
|
219 |
- trigger_agent.options.should == trigger_agent_options |
|
204 |
+ expect(weather_agent.name).to eq("a weather agent") |
|
205 |
+ expect(weather_agent.schedule).to eq("5pm") |
|
206 |
+ expect(weather_agent.keep_events_for).to eq(14) |
|
207 |
+ expect(weather_agent.propagate_immediately).to be_falsey |
|
208 |
+ expect(weather_agent).to be_disabled |
|
209 |
+ expect(weather_agent.memory).to be_empty |
|
210 |
+ expect(weather_agent.options).to eq(weather_agent_options) |
|
211 |
+ |
|
212 |
+ expect(trigger_agent.name).to eq("listen for weather") |
|
213 |
+ expect(trigger_agent.sources).to eq([weather_agent]) |
|
214 |
+ expect(trigger_agent.schedule).to be_nil |
|
215 |
+ expect(trigger_agent.keep_events_for).to eq(0) |
|
216 |
+ expect(trigger_agent.propagate_immediately).to be_truthy |
|
217 |
+ expect(trigger_agent).not_to be_disabled |
|
218 |
+ expect(trigger_agent.memory).to be_empty |
|
219 |
+ expect(trigger_agent.options).to eq(trigger_agent_options) |
|
220 | 220 |
end |
221 | 221 |
|
222 | 222 |
it "creates new Agents, even if one already exists with the given guid (so that we don't overwrite a user's work outside of the scenario)" do |
223 | 223 |
agents(:bob_weather_agent).update_attribute :guid, "a-weather-agent" |
224 | 224 |
|
225 |
- lambda { |
|
225 |
+ expect { |
|
226 | 226 |
scenario_import.import |
227 |
- }.should change { users(:bob).agents.count }.by(2) |
|
227 |
+ }.to change { users(:bob).agents.count }.by(2) |
|
228 | 228 |
end |
229 | 229 |
end |
230 | 230 |
|
231 | 231 |
describe "#generate_diff" do |
232 | 232 |
it "returns AgentDiff objects for the incoming Agents" do |
233 |
- scenario_import.should be_valid |
|
233 |
+ expect(scenario_import).to be_valid |
|
234 | 234 |
|
235 | 235 |
agent_diffs = scenario_import.agent_diffs |
236 | 236 |
|
@@ -241,27 +241,27 @@ describe ScenarioImport do |
||
241 | 241 |
if key == :type |
242 | 242 |
value = value.split("::").last |
243 | 243 |
end |
244 |
- weather_agent_diff.should respond_to(key) |
|
244 |
+ expect(weather_agent_diff).to respond_to(key) |
|
245 | 245 |
field = weather_agent_diff.send(key) |
246 |
- field.should be_a(ScenarioImport::AgentDiff::FieldDiff) |
|
247 |
- field.incoming.should == value |
|
248 |
- field.updated.should == value |
|
249 |
- field.current.should be_nil |
|
246 |
+ expect(field).to be_a(ScenarioImport::AgentDiff::FieldDiff) |
|
247 |
+ expect(field.incoming).to eq(value) |
|
248 |
+ expect(field.updated).to eq(value) |
|
249 |
+ expect(field.current).to be_nil |
|
250 | 250 |
end |
251 |
- weather_agent_diff.should_not respond_to(:propagate_immediately) |
|
251 |
+ expect(weather_agent_diff).not_to respond_to(:propagate_immediately) |
|
252 | 252 |
|
253 | 253 |
valid_parsed_trigger_agent_data.each do |key, value| |
254 | 254 |
if key == :type |
255 | 255 |
value = value.split("::").last |
256 | 256 |
end |
257 |
- trigger_agent_diff.should respond_to(key) |
|
257 |
+ expect(trigger_agent_diff).to respond_to(key) |
|
258 | 258 |
field = trigger_agent_diff.send(key) |
259 |
- field.should be_a(ScenarioImport::AgentDiff::FieldDiff) |
|
260 |
- field.incoming.should == value |
|
261 |
- field.updated.should == value |
|
262 |
- field.current.should be_nil |
|
259 |
+ expect(field).to be_a(ScenarioImport::AgentDiff::FieldDiff) |
|
260 |
+ expect(field.incoming).to eq(value) |
|
261 |
+ expect(field.updated).to eq(value) |
|
262 |
+ expect(field.current).to be_nil |
|
263 | 263 |
end |
264 |
- trigger_agent_diff.should_not respond_to(:schedule) |
|
264 |
+ expect(trigger_agent_diff).not_to respond_to(:schedule) |
|
265 | 265 |
end |
266 | 266 |
end |
267 | 267 |
end |
@@ -280,49 +280,49 @@ describe ScenarioImport do |
||
280 | 280 |
|
281 | 281 |
describe "#import" do |
282 | 282 |
it "uses the existing scenario, updating its data" do |
283 |
- lambda { |
|
283 |
+ expect { |
|
284 | 284 |
scenario_import.import(:skip_agents => true) |
285 |
- scenario_import.scenario.should == existing_scenario |
|
286 |
- }.should_not change { users(:bob).scenarios.count } |
|
285 |
+ expect(scenario_import.scenario).to eq(existing_scenario) |
|
286 |
+ }.not_to change { users(:bob).scenarios.count } |
|
287 | 287 |
|
288 | 288 |
existing_scenario.reload |
289 |
- existing_scenario.guid.should == guid |
|
290 |
- existing_scenario.tag_fg_color.should == tag_fg_color |
|
291 |
- existing_scenario.tag_bg_color.should == tag_bg_color |
|
292 |
- existing_scenario.description.should == description |
|
293 |
- existing_scenario.name.should == name |
|
294 |
- existing_scenario.source_url.should == source_url |
|
295 |
- existing_scenario.public.should be_falsey |
|
289 |
+ expect(existing_scenario.guid).to eq(guid) |
|
290 |
+ expect(existing_scenario.tag_fg_color).to eq(tag_fg_color) |
|
291 |
+ expect(existing_scenario.tag_bg_color).to eq(tag_bg_color) |
|
292 |
+ expect(existing_scenario.description).to eq(description) |
|
293 |
+ expect(existing_scenario.name).to eq(name) |
|
294 |
+ expect(existing_scenario.source_url).to eq(source_url) |
|
295 |
+ expect(existing_scenario.public).to be_falsey |
|
296 | 296 |
end |
297 | 297 |
|
298 | 298 |
it "updates any existing agents in the scenario, and makes new ones as needed" do |
299 |
- scenario_import.should be_valid |
|
299 |
+ expect(scenario_import).to be_valid |
|
300 | 300 |
|
301 |
- lambda { |
|
301 |
+ expect { |
|
302 | 302 |
scenario_import.import |
303 |
- }.should change { users(:bob).agents.count }.by(1) # One, because the weather agent already existed. |
|
303 |
+ }.to change { users(:bob).agents.count }.by(1) # One, because the weather agent already existed. |
|
304 | 304 |
|
305 | 305 |
weather_agent = existing_scenario.agents.find_by(:guid => "a-weather-agent") |
306 | 306 |
trigger_agent = existing_scenario.agents.find_by(:guid => "a-trigger-agent") |
307 | 307 |
|
308 |
- weather_agent.should == agents(:bob_weather_agent) |
|
309 |
- |
|
310 |
- weather_agent.name.should == "a weather agent" |
|
311 |
- weather_agent.schedule.should == "5pm" |
|
312 |
- weather_agent.keep_events_for.should == 14 |
|
313 |
- weather_agent.propagate_immediately.should be_falsey |
|
314 |
- weather_agent.should be_disabled |
|
315 |
- weather_agent.memory.should be_empty |
|
316 |
- weather_agent.options.should == weather_agent_options |
|
317 |
- |
|
318 |
- trigger_agent.name.should == "listen for weather" |
|
319 |
- trigger_agent.sources.should == [weather_agent] |
|
320 |
- trigger_agent.schedule.should be_nil |
|
321 |
- trigger_agent.keep_events_for.should == 0 |
|
322 |
- trigger_agent.propagate_immediately.should be_truthy |
|
323 |
- trigger_agent.should_not be_disabled |
|
324 |
- trigger_agent.memory.should be_empty |
|
325 |
- trigger_agent.options.should == trigger_agent_options |
|
308 |
+ expect(weather_agent).to eq(agents(:bob_weather_agent)) |
|
309 |
+ |
|
310 |
+ expect(weather_agent.name).to eq("a weather agent") |
|
311 |
+ expect(weather_agent.schedule).to eq("5pm") |
|
312 |
+ expect(weather_agent.keep_events_for).to eq(14) |
|
313 |
+ expect(weather_agent.propagate_immediately).to be_falsey |
|
314 |
+ expect(weather_agent).to be_disabled |
|
315 |
+ expect(weather_agent.memory).to be_empty |
|
316 |
+ expect(weather_agent.options).to eq(weather_agent_options) |
|
317 |
+ |
|
318 |
+ expect(trigger_agent.name).to eq("listen for weather") |
|
319 |
+ expect(trigger_agent.sources).to eq([weather_agent]) |
|
320 |
+ expect(trigger_agent.schedule).to be_nil |
|
321 |
+ expect(trigger_agent.keep_events_for).to eq(0) |
|
322 |
+ expect(trigger_agent.propagate_immediately).to be_truthy |
|
323 |
+ expect(trigger_agent).not_to be_disabled |
|
324 |
+ expect(trigger_agent.memory).to be_empty |
|
325 |
+ expect(trigger_agent.options).to eq(trigger_agent_options) |
|
326 | 326 |
end |
327 | 327 |
|
328 | 328 |
it "honors updates coming from the UI" do |
@@ -336,16 +336,16 @@ describe ScenarioImport do |
||
336 | 336 |
} |
337 | 337 |
} |
338 | 338 |
|
339 |
- scenario_import.should be_valid |
|
339 |
+ expect(scenario_import).to be_valid |
|
340 | 340 |
|
341 |
- scenario_import.import.should be_truthy |
|
341 |
+ expect(scenario_import.import).to be_truthy |
|
342 | 342 |
|
343 | 343 |
weather_agent = existing_scenario.agents.find_by(:guid => "a-weather-agent") |
344 |
- weather_agent.name.should == "updated name" |
|
345 |
- weather_agent.schedule.should == "6pm" |
|
346 |
- weather_agent.keep_events_for.should == 2 |
|
347 |
- weather_agent.should_not be_disabled |
|
348 |
- weather_agent.options.should == weather_agent_options.merge("api_key" => "foo") |
|
344 |
+ expect(weather_agent.name).to eq("updated name") |
|
345 |
+ expect(weather_agent.schedule).to eq("6pm") |
|
346 |
+ expect(weather_agent.keep_events_for).to eq(2) |
|
347 |
+ expect(weather_agent).not_to be_disabled |
|
348 |
+ expect(weather_agent.options).to eq(weather_agent_options.merge("api_key" => "foo")) |
|
349 | 349 |
end |
350 | 350 |
|
351 | 351 |
it "adds errors when updated agents are invalid" do |
@@ -358,12 +358,12 @@ describe ScenarioImport do |
||
358 | 358 |
} |
359 | 359 |
} |
360 | 360 |
|
361 |
- scenario_import.import.should be_falsey |
|
361 |
+ expect(scenario_import.import).to be_falsey |
|
362 | 362 |
|
363 | 363 |
errors = scenario_import.errors.full_messages.to_sentence |
364 |
- errors.should =~ /Name can't be blank/ |
|
365 |
- errors.should =~ /api_key is required/ |
|
366 |
- errors.should =~ /Schedule is not a valid schedule/ |
|
364 |
+ expect(errors).to match(/Name can't be blank/) |
|
365 |
+ expect(errors).to match(/api_key is required/) |
|
366 |
+ expect(errors).to match(/Schedule is not a valid schedule/) |
|
367 | 367 |
end |
368 | 368 |
end |
369 | 369 |
|
@@ -374,15 +374,15 @@ describe ScenarioImport do |
||
374 | 374 |
trigger_agent_diff = agent_diffs[1] |
375 | 375 |
|
376 | 376 |
# Already exists |
377 |
- weather_agent_diff.agent.should == agents(:bob_weather_agent) |
|
377 |
+ expect(weather_agent_diff.agent).to eq(agents(:bob_weather_agent)) |
|
378 | 378 |
valid_parsed_weather_agent_data.each do |key, value| |
379 | 379 |
next if key == :type |
380 |
- weather_agent_diff.send(key).current.should == agents(:bob_weather_agent).send(key) |
|
380 |
+ expect(weather_agent_diff.send(key).current).to eq(agents(:bob_weather_agent).send(key)) |
|
381 | 381 |
end |
382 | 382 |
|
383 | 383 |
# Doesn't exist yet |
384 | 384 |
valid_parsed_trigger_agent_data.each do |key, value| |
385 |
- trigger_agent_diff.send(key).current.should be_nil |
|
385 |
+ expect(trigger_agent_diff.send(key).current).to be_nil |
|
386 | 386 |
end |
387 | 387 |
end |
388 | 388 |
|
@@ -400,20 +400,20 @@ describe ScenarioImport do |
||
400 | 400 |
} |
401 | 401 |
} |
402 | 402 |
|
403 |
- scenario_import.should be_valid |
|
403 |
+ expect(scenario_import).to be_valid |
|
404 | 404 |
|
405 | 405 |
agent_diffs = scenario_import.agent_diffs |
406 | 406 |
weather_agent_diff = agent_diffs[0] |
407 | 407 |
trigger_agent_diff = agent_diffs[1] |
408 | 408 |
|
409 |
- weather_agent_diff.name.current.should == agents(:bob_weather_agent).name |
|
410 |
- weather_agent_diff.name.incoming.should == valid_parsed_weather_agent_data[:name] |
|
411 |
- weather_agent_diff.name.updated.should == "a new name" |
|
409 |
+ expect(weather_agent_diff.name.current).to eq(agents(:bob_weather_agent).name) |
|
410 |
+ expect(weather_agent_diff.name.incoming).to eq(valid_parsed_weather_agent_data[:name]) |
|
411 |
+ expect(weather_agent_diff.name.updated).to eq("a new name") |
|
412 | 412 |
|
413 |
- weather_agent_diff.schedule.updated.should == "6pm" |
|
414 |
- weather_agent_diff.keep_events_for.updated.should == "2" |
|
415 |
- weather_agent_diff.disabled.updated.should == "true" |
|
416 |
- weather_agent_diff.options.updated.should == weather_agent_options.merge("api_key" => "foo") |
|
413 |
+ expect(weather_agent_diff.schedule.updated).to eq("6pm") |
|
414 |
+ expect(weather_agent_diff.keep_events_for.updated).to eq("2") |
|
415 |
+ expect(weather_agent_diff.disabled.updated).to eq("true") |
|
416 |
+ expect(weather_agent_diff.options.updated).to eq(weather_agent_options.merge("api_key" => "foo")) |
|
417 | 417 |
end |
418 | 418 |
|
419 | 419 |
it "adds errors on validation when updated options are unparsable" do |
@@ -422,8 +422,8 @@ describe ScenarioImport do |
||
422 | 422 |
"options" => '{' |
423 | 423 |
} |
424 | 424 |
} |
425 |
- scenario_import.should_not be_valid |
|
426 |
- scenario_import.should have(1).error_on(:base) |
|
425 |
+ expect(scenario_import).not_to be_valid |
|
426 |
+ expect(scenario_import).to have(1).error_on(:base) |
|
427 | 427 |
end |
428 | 428 |
end |
429 | 429 |
end |
@@ -448,12 +448,12 @@ describe ScenarioImport do |
||
448 | 448 |
it "should check if the agent requires a service" do |
449 | 449 |
agent_diffs = services_scenario_import.agent_diffs |
450 | 450 |
basecamp_agent_diff = agent_diffs[0] |
451 |
- basecamp_agent_diff.requires_service?.should == true |
|
451 |
+ expect(basecamp_agent_diff.requires_service?).to eq(true) |
|
452 | 452 |
end |
453 | 453 |
|
454 | 454 |
it "should add an error when no service is selected" do |
455 |
- services_scenario_import.import.should == false |
|
456 |
- services_scenario_import.errors[:base].length.should == 1 |
|
455 |
+ expect(services_scenario_import.import).to eq(false) |
|
456 |
+ expect(services_scenario_import.errors[:base].length).to eq(1) |
|
457 | 457 |
end |
458 | 458 |
end |
459 | 459 |
|
@@ -464,9 +464,9 @@ describe ScenarioImport do |
||
464 | 464 |
"service_id" => "0", |
465 | 465 |
} |
466 | 466 |
} |
467 |
- lambda { |
|
468 |
- services_scenario_import.import.should == true |
|
469 |
- }.should change { users(:bob).agents.count }.by(2) |
|
467 |
+ expect { |
|
468 |
+ expect(services_scenario_import.import).to eq(true) |
|
469 |
+ }.to change { users(:bob).agents.count }.by(2) |
|
470 | 470 |
end |
471 | 471 |
end |
472 | 472 |
end |
@@ -7,61 +7,61 @@ describe Scenario do |
||
7 | 7 |
|
8 | 8 |
describe "validations" do |
9 | 9 |
before do |
10 |
- new_instance.should be_valid |
|
10 |
+ expect(new_instance).to be_valid |
|
11 | 11 |
end |
12 | 12 |
|
13 | 13 |
it "validates the presence of name" do |
14 | 14 |
new_instance.name = '' |
15 |
- new_instance.should_not be_valid |
|
15 |
+ expect(new_instance).not_to be_valid |
|
16 | 16 |
end |
17 | 17 |
|
18 | 18 |
it "validates the presence of user" do |
19 | 19 |
new_instance.user = nil |
20 |
- new_instance.should_not be_valid |
|
20 |
+ expect(new_instance).not_to be_valid |
|
21 | 21 |
end |
22 | 22 |
|
23 | 23 |
it "validates tag_fg_color is hex color" do |
24 | 24 |
new_instance.tag_fg_color = '#N07H3X' |
25 |
- new_instance.should_not be_valid |
|
25 |
+ expect(new_instance).not_to be_valid |
|
26 | 26 |
new_instance.tag_fg_color = '#BADA55' |
27 |
- new_instance.should be_valid |
|
27 |
+ expect(new_instance).to be_valid |
|
28 | 28 |
end |
29 | 29 |
|
30 | 30 |
it "allows nil tag_fg_color" do |
31 | 31 |
new_instance.tag_fg_color = nil |
32 |
- new_instance.should be_valid |
|
32 |
+ expect(new_instance).to be_valid |
|
33 | 33 |
end |
34 | 34 |
|
35 | 35 |
it "validates tag_bg_color is hex color" do |
36 | 36 |
new_instance.tag_bg_color = '#N07H3X' |
37 |
- new_instance.should_not be_valid |
|
37 |
+ expect(new_instance).not_to be_valid |
|
38 | 38 |
new_instance.tag_bg_color = '#BADA55' |
39 |
- new_instance.should be_valid |
|
39 |
+ expect(new_instance).to be_valid |
|
40 | 40 |
end |
41 | 41 |
|
42 | 42 |
it "allows nil tag_bg_color" do |
43 | 43 |
new_instance.tag_bg_color = nil |
44 |
- new_instance.should be_valid |
|
44 |
+ expect(new_instance).to be_valid |
|
45 | 45 |
end |
46 | 46 |
|
47 | 47 |
it "only allows Agents owned by user" do |
48 | 48 |
new_instance.agent_ids = [agents(:bob_website_agent).id] |
49 |
- new_instance.should be_valid |
|
49 |
+ expect(new_instance).to be_valid |
|
50 | 50 |
|
51 | 51 |
new_instance.agent_ids = [agents(:jane_website_agent).id] |
52 |
- new_instance.should_not be_valid |
|
52 |
+ expect(new_instance).not_to be_valid |
|
53 | 53 |
end |
54 | 54 |
end |
55 | 55 |
|
56 | 56 |
describe "counters" do |
57 | 57 |
it "maintains a counter cache on user" do |
58 |
- lambda { |
|
58 |
+ expect { |
|
59 | 59 |
new_instance.save! |
60 |
- }.should change { users(:bob).reload.scenario_count }.by(1) |
|
60 |
+ }.to change { users(:bob).reload.scenario_count }.by(1) |
|
61 | 61 |
|
62 |
- lambda { |
|
62 |
+ expect { |
|
63 | 63 |
new_instance.destroy |
64 |
- }.should change { users(:bob).reload.scenario_count }.by(-1) |
|
64 |
+ }.to change { users(:bob).reload.scenario_count }.by(-1) |
|
65 | 65 |
end |
66 | 66 |
end |
67 | 67 |
end |
@@ -8,11 +8,11 @@ describe Service do |
||
8 | 8 |
describe "#toggle_availability!" do |
9 | 9 |
it "should toggle the global flag" do |
10 | 10 |
@service = services(:generic) |
11 |
- @service.global.should == false |
|
11 |
+ expect(@service.global).to eq(false) |
|
12 | 12 |
@service.toggle_availability! |
13 |
- @service.global.should == true |
|
13 |
+ expect(@service.global).to eq(true) |
|
14 | 14 |
@service.toggle_availability! |
15 |
- @service.global.should == false |
|
15 |
+ expect(@service.global).to eq(false) |
|
16 | 16 |
end |
17 | 17 |
|
18 | 18 |
it "disconnects agents and disables them if the previously global service is made private again", focus: true do |
@@ -21,15 +21,15 @@ describe Service do |
||
21 | 21 |
|
22 | 22 |
service = agent.service |
23 | 23 |
service.toggle_availability! |
24 |
- service.agents.length.should == 2 |
|
24 |
+ expect(service.agents.length).to eq(2) |
|
25 | 25 |
|
26 | 26 |
service.toggle_availability! |
27 | 27 |
jane_agent.reload |
28 |
- jane_agent.service_id.should be_nil |
|
29 |
- jane_agent.disabled.should be true |
|
28 |
+ expect(jane_agent.service_id).to be_nil |
|
29 |
+ expect(jane_agent.disabled).to be true |
|
30 | 30 |
|
31 | 31 |
service.reload |
32 |
- service.agents.length.should == 1 |
|
32 |
+ expect(service.agents.length).to eq(1) |
|
33 | 33 |
end |
34 | 34 |
end |
35 | 35 |
|
@@ -38,8 +38,8 @@ describe Service do |
||
38 | 38 |
service = agent.service |
39 | 39 |
service.destroy |
40 | 40 |
agent.reload |
41 |
- agent.service_id.should be_nil |
|
42 |
- agent.disabled.should be true |
|
41 |
+ expect(agent.service_id).to be_nil |
|
42 |
+ expect(agent.disabled).to be true |
|
43 | 43 |
end |
44 | 44 |
|
45 | 45 |
describe "preparing for a request" do |
@@ -49,18 +49,18 @@ describe Service do |
||
49 | 49 |
|
50 | 50 |
it "should not update the token if the token never expires" do |
51 | 51 |
@service.expires_at = nil |
52 |
- @service.prepare_request.should == nil |
|
52 |
+ expect(@service.prepare_request).to eq(nil) |
|
53 | 53 |
end |
54 | 54 |
|
55 | 55 |
it "should not update the token if the token is still valid" do |
56 | 56 |
@service.expires_at = Time.now + 1.hour |
57 |
- @service.prepare_request.should == nil |
|
57 |
+ expect(@service.prepare_request).to eq(nil) |
|
58 | 58 |
end |
59 | 59 |
|
60 | 60 |
it "should call refresh_token! if the token expired" do |
61 | 61 |
stub(@service).refresh_token! { @service } |
62 | 62 |
@service.expires_at = Time.now - 1.hour |
63 |
- @service.prepare_request.should == @service |
|
63 |
+ expect(@service.prepare_request).to eq(@service) |
|
64 | 64 |
end |
65 | 65 |
end |
66 | 66 |
|
@@ -71,7 +71,7 @@ describe Service do |
||
71 | 71 |
|
72 | 72 |
it "should return the correct endpoint" do |
73 | 73 |
@service.provider = '37signals' |
74 |
- @service.send(:endpoint).to_s.should == "https://launchpad.37signals.com/authorization/token" |
|
74 |
+ expect(@service.send(:endpoint).to_s).to eq("https://launchpad.37signals.com/authorization/token") |
|
75 | 75 |
end |
76 | 76 |
|
77 | 77 |
it "should update the token" do |
@@ -80,7 +80,7 @@ describe Service do |
||
80 | 80 |
@service.provider = '37signals' |
81 | 81 |
@service.refresh_token = 'refreshtokentest' |
82 | 82 |
@service.refresh_token! |
83 |
- @service.token.should == 'NEWTOKEN' |
|
83 |
+ expect(@service.token).to eq('NEWTOKEN') |
|
84 | 84 |
end |
85 | 85 |
end |
86 | 86 |
|
@@ -92,11 +92,11 @@ describe Service do |
||
92 | 92 |
service.save! |
93 | 93 |
}.to change { @user.services.count }.by(1) |
94 | 94 |
service = @user.services.first |
95 |
- service.name.should == 'johnqpublic' |
|
96 |
- service.uid.should == '123456' |
|
97 |
- service.provider.should == 'twitter' |
|
98 |
- service.token.should == 'a1b2c3d4...' |
|
99 |
- service.secret.should == 'abcdef1234' |
|
95 |
+ expect(service.name).to eq('johnqpublic') |
|
96 |
+ expect(service.uid).to eq('123456') |
|
97 |
+ expect(service.provider).to eq('twitter') |
|
98 |
+ expect(service.token).to eq('a1b2c3d4...') |
|
99 |
+ expect(service.secret).to eq('abcdef1234') |
|
100 | 100 |
end |
101 | 101 |
it "should work with 37signals services" do |
102 | 102 |
signals = JSON.parse(File.read(Rails.root.join('spec/data_fixtures/services/37signals.json'))) |
@@ -105,12 +105,12 @@ describe Service do |
||
105 | 105 |
service.save! |
106 | 106 |
}.to change { @user.services.count }.by(1) |
107 | 107 |
service = @user.services.first |
108 |
- service.provider.should == '37signals' |
|
109 |
- service.name.should == 'Dominik Sander' |
|
110 |
- service.token.should == 'abcde' |
|
111 |
- service.uid.should == '12345' |
|
112 |
- service.refresh_token.should == 'fghrefresh' |
|
113 |
- service.options[:user_id].should == 12345 |
|
108 |
+ expect(service.provider).to eq('37signals') |
|
109 |
+ expect(service.name).to eq('Dominik Sander') |
|
110 |
+ expect(service.token).to eq('abcde') |
|
111 |
+ expect(service.uid).to eq('12345') |
|
112 |
+ expect(service.refresh_token).to eq('fghrefresh') |
|
113 |
+ expect(service.options[:user_id]).to eq(12345) |
|
114 | 114 |
service.expires_at = Time.at(1401554352) |
115 | 115 |
end |
116 | 116 |
it "should work with github services" do |
@@ -120,10 +120,10 @@ describe Service do |
||
120 | 120 |
service.save! |
121 | 121 |
}.to change { @user.services.count }.by(1) |
122 | 122 |
service = @user.services.first |
123 |
- service.provider.should == 'github' |
|
124 |
- service.name.should == 'dsander' |
|
125 |
- service.uid.should == '12345' |
|
126 |
- service.token.should == 'agithubtoken' |
|
123 |
+ expect(service.provider).to eq('github') |
|
124 |
+ expect(service.name).to eq('dsander') |
|
125 |
+ expect(service.uid).to eq('12345') |
|
126 |
+ expect(service.token).to eq('agithubtoken') |
|
127 | 127 |
end |
128 | 128 |
end |
129 | 129 |
end |
@@ -2,18 +2,18 @@ require 'spec_helper' |
||
2 | 2 |
|
3 | 3 |
describe UserCredential do |
4 | 4 |
describe "validation" do |
5 |
- it { should validate_uniqueness_of(:credential_name).scoped_to(:user_id) } |
|
6 |
- it { should validate_presence_of(:credential_name) } |
|
7 |
- it { should validate_presence_of(:credential_value) } |
|
8 |
- it { should validate_presence_of(:user_id) } |
|
5 |
+ it { is_expected.to validate_uniqueness_of(:credential_name).scoped_to(:user_id) } |
|
6 |
+ it { is_expected.to validate_presence_of(:credential_name) } |
|
7 |
+ it { is_expected.to validate_presence_of(:credential_value) } |
|
8 |
+ it { is_expected.to validate_presence_of(:user_id) } |
|
9 | 9 |
end |
10 | 10 |
|
11 | 11 |
describe "mass assignment" do |
12 |
- it { should allow_mass_assignment_of :credential_name } |
|
12 |
+ it { is_expected.to allow_mass_assignment_of :credential_name } |
|
13 | 13 |
|
14 |
- it { should allow_mass_assignment_of :credential_value } |
|
14 |
+ it { is_expected.to allow_mass_assignment_of :credential_value } |
|
15 | 15 |
|
16 |
- it { should_not allow_mass_assignment_of :user_id } |
|
16 |
+ it { is_expected.not_to allow_mass_assignment_of :user_id } |
|
17 | 17 |
end |
18 | 18 |
|
19 | 19 |
describe "cleaning fields" do |
@@ -22,8 +22,8 @@ describe UserCredential do |
||
22 | 22 |
user_credential.credential_name = " new name " |
23 | 23 |
user_credential.credential_value = " new value " |
24 | 24 |
user_credential.save! |
25 |
- user_credential.credential_name.should == "new name" |
|
26 |
- user_credential.credential_value.should == "new value" |
|
25 |
+ expect(user_credential.credential_name).to eq("new name") |
|
26 |
+ expect(user_credential.credential_value).to eq("new value") |
|
27 | 27 |
end |
28 | 28 |
end |
29 | 29 |
end |
@@ -5,13 +5,13 @@ describe User do |
||
5 | 5 |
describe "invitation_code" do |
6 | 6 |
it "only accepts valid invitation codes" do |
7 | 7 |
User::INVITATION_CODES.each do |v| |
8 |
- should allow_value(v).for(:invitation_code) |
|
8 |
+ is_expected.to allow_value(v).for(:invitation_code) |
|
9 | 9 |
end |
10 | 10 |
end |
11 | 11 |
|
12 | 12 |
it "can reject invalid invitation codes" do |
13 | 13 |
%w['foo', 'bar'].each do |v| |
14 |
- should_not allow_value(v).for(:invitation_code) |
|
14 |
+ is_expected.not_to allow_value(v).for(:invitation_code) |
|
15 | 15 |
end |
16 | 16 |
end |
17 | 17 |
end |
@@ -1,23 +1,23 @@ |
||
1 | 1 |
require 'spec_helper' |
2 | 2 |
|
3 |
-describe "routing for web requests" do |
|
3 |
+describe "routing for web requests", :type => :routing do |
|
4 | 4 |
it "routes to handle_request" do |
5 | 5 |
resulting_params = { :user_id => "6", :agent_id => "2", :secret => "foobar" } |
6 |
- get("/users/6/web_requests/2/foobar").should route_to("web_requests#handle_request", resulting_params) |
|
7 |
- post("/users/6/web_requests/2/foobar").should route_to("web_requests#handle_request", resulting_params) |
|
8 |
- put("/users/6/web_requests/2/foobar").should route_to("web_requests#handle_request", resulting_params) |
|
9 |
- delete("/users/6/web_requests/2/foobar").should route_to("web_requests#handle_request", resulting_params) |
|
6 |
+ expect(get("/users/6/web_requests/2/foobar")).to route_to("web_requests#handle_request", resulting_params) |
|
7 |
+ expect(post("/users/6/web_requests/2/foobar")).to route_to("web_requests#handle_request", resulting_params) |
|
8 |
+ expect(put("/users/6/web_requests/2/foobar")).to route_to("web_requests#handle_request", resulting_params) |
|
9 |
+ expect(delete("/users/6/web_requests/2/foobar")).to route_to("web_requests#handle_request", resulting_params) |
|
10 | 10 |
end |
11 | 11 |
|
12 | 12 |
it "supports the legacy /webhooks/ route" do |
13 |
- post("/users/6/webhooks/2/foobar").should route_to("web_requests#handle_request", :user_id => "6", :agent_id => "2", :secret => "foobar") |
|
13 |
+ expect(post("/users/6/webhooks/2/foobar")).to route_to("web_requests#handle_request", :user_id => "6", :agent_id => "2", :secret => "foobar") |
|
14 | 14 |
end |
15 | 15 |
|
16 | 16 |
it "routes with format" do |
17 |
- get("/users/6/web_requests/2/foobar.json").should route_to("web_requests#handle_request", |
|
17 |
+ expect(get("/users/6/web_requests/2/foobar.json")).to route_to("web_requests#handle_request", |
|
18 | 18 |
{ :user_id => "6", :agent_id => "2", :secret => "foobar", :format => "json" }) |
19 | 19 |
|
20 |
- get("/users/6/web_requests/2/foobar.atom").should route_to("web_requests#handle_request", |
|
20 |
+ expect(get("/users/6/web_requests/2/foobar.atom")).to route_to("web_requests#handle_request", |
|
21 | 21 |
{ :user_id => "6", :agent_id => "2", :secret => "foobar", :format => "atom" }) |
22 | 22 |
end |
23 | 23 |
end |
@@ -53,7 +53,7 @@ RSpec.configure do |config| |
||
53 | 53 |
|
54 | 54 |
config.render_views |
55 | 55 |
|
56 |
- config.include Devise::TestHelpers, :type => :controller |
|
56 |
+ config.include Devise::TestHelpers, type: :controller |
|
57 | 57 |
config.include SpecHelpers |
58 | 58 |
config.include Delorean |
59 | 59 |
end |
@@ -16,73 +16,73 @@ shared_examples_for EmailConcern do |
||
16 | 16 |
|
17 | 17 |
describe "validations" do |
18 | 18 |
it "should be valid" do |
19 |
- agent.should be_valid |
|
19 |
+ expect(agent).to be_valid |
|
20 | 20 |
end |
21 | 21 |
|
22 | 22 |
it "should validate the presence of 'subject'" do |
23 | 23 |
agent.options['subject'] = '' |
24 |
- agent.should_not be_valid |
|
24 |
+ expect(agent).not_to be_valid |
|
25 | 25 |
|
26 | 26 |
agent.options['subject'] = nil |
27 |
- agent.should_not be_valid |
|
27 |
+ expect(agent).not_to be_valid |
|
28 | 28 |
end |
29 | 29 |
|
30 | 30 |
it "should validate the presence of 'expected_receive_period_in_days'" do |
31 | 31 |
agent.options['expected_receive_period_in_days'] = '' |
32 |
- agent.should_not be_valid |
|
32 |
+ expect(agent).not_to be_valid |
|
33 | 33 |
|
34 | 34 |
agent.options['expected_receive_period_in_days'] = nil |
35 |
- agent.should_not be_valid |
|
35 |
+ expect(agent).not_to be_valid |
|
36 | 36 |
end |
37 | 37 |
|
38 | 38 |
it "should validate that recipients, when provided, is one or more valid email addresses" do |
39 | 39 |
agent.options['recipients'] = '' |
40 |
- agent.should be_valid |
|
40 |
+ expect(agent).to be_valid |
|
41 | 41 |
|
42 | 42 |
agent.options['recipients'] = nil |
43 |
- agent.should be_valid |
|
43 |
+ expect(agent).to be_valid |
|
44 | 44 |
|
45 | 45 |
agent.options['recipients'] = 'bob@example.com' |
46 |
- agent.should be_valid |
|
46 |
+ expect(agent).to be_valid |
|
47 | 47 |
|
48 | 48 |
agent.options['recipients'] = ['bob@example.com'] |
49 |
- agent.should be_valid |
|
49 |
+ expect(agent).to be_valid |
|
50 | 50 |
|
51 | 51 |
agent.options['recipients'] = ['bob@example.com', 'jane@example.com'] |
52 |
- agent.should be_valid |
|
52 |
+ expect(agent).to be_valid |
|
53 | 53 |
|
54 | 54 |
agent.options['recipients'] = ['bob@example.com', 'example.com'] |
55 |
- agent.should_not be_valid |
|
55 |
+ expect(agent).not_to be_valid |
|
56 | 56 |
|
57 | 57 |
agent.options['recipients'] = ['hi!'] |
58 |
- agent.should_not be_valid |
|
58 |
+ expect(agent).not_to be_valid |
|
59 | 59 |
|
60 | 60 |
agent.options['recipients'] = { :foo => "bar" } |
61 |
- agent.should_not be_valid |
|
61 |
+ expect(agent).not_to be_valid |
|
62 | 62 |
|
63 | 63 |
agent.options['recipients'] = "wut" |
64 |
- agent.should_not be_valid |
|
64 |
+ expect(agent).not_to be_valid |
|
65 | 65 |
end |
66 | 66 |
end |
67 | 67 |
|
68 | 68 |
describe "#recipients" do |
69 | 69 |
it "defaults to the user's email address" do |
70 |
- agent.recipients.should == [users(:jane).email] |
|
70 |
+ expect(agent.recipients).to eq([users(:jane).email]) |
|
71 | 71 |
end |
72 | 72 |
|
73 | 73 |
it "wraps a string with an array" do |
74 | 74 |
agent.options['recipients'] = 'bob@bob.com' |
75 |
- agent.recipients.should == ['bob@bob.com'] |
|
75 |
+ expect(agent.recipients).to eq(['bob@bob.com']) |
|
76 | 76 |
end |
77 | 77 |
|
78 | 78 |
it "handles an array" do |
79 | 79 |
agent.options['recipients'] = ['bob@bob.com', 'jane@jane.com'] |
80 |
- agent.recipients.should == ['bob@bob.com', 'jane@jane.com'] |
|
80 |
+ expect(agent.recipients).to eq(['bob@bob.com', 'jane@jane.com']) |
|
81 | 81 |
end |
82 | 82 |
|
83 | 83 |
it "interpolates" do |
84 | 84 |
agent.options['recipients'] = "{{ username }}@{{ domain }}" |
85 |
- agent.recipients('username' => 'bob', 'domain' => 'example.com').should == ["bob@example.com"] |
|
85 |
+ expect(agent.recipients('username' => 'bob', 'domain' => 'example.com')).to eq(["bob@example.com"]) |
|
86 | 86 |
end |
87 | 87 |
end |
88 | 88 |
end |
@@ -3,10 +3,10 @@ require 'spec_helper' |
||
3 | 3 |
shared_examples_for HasGuid do |
4 | 4 |
it "gets created before_save, but only if it's not present" do |
5 | 5 |
instance = new_instance |
6 |
- instance.guid.should be_nil |
|
6 |
+ expect(instance.guid).to be_nil |
|
7 | 7 |
instance.save! |
8 |
- instance.guid.should_not be_nil |
|
8 |
+ expect(instance.guid).not_to be_nil |
|
9 | 9 |
|
10 |
- lambda { instance.save! }.should_not change { instance.reload.guid } |
|
10 |
+ expect { instance.save! }.not_to change { instance.reload.guid } |
|
11 | 11 |
end |
12 | 12 |
end |
@@ -22,72 +22,72 @@ shared_examples_for LiquidInterpolatable do |
||
22 | 22 |
|
23 | 23 |
describe "interpolating liquid templates" do |
24 | 24 |
it "should work" do |
25 |
- @checker.interpolate_options(@checker.options, @event).should == { |
|
25 |
+ expect(@checker.interpolate_options(@checker.options, @event)).to eq({ |
|
26 | 26 |
"normal" => "just some normal text", |
27 | 27 |
"variable" => "hello", |
28 | 28 |
"text" => "Some test with an embedded hello", |
29 | 29 |
"escape" => "This should be Hello+world" |
30 |
- } |
|
30 |
+ }) |
|
31 | 31 |
end |
32 | 32 |
|
33 | 33 |
it "should work with arrays", focus: true do |
34 | 34 |
@checker.options = {"value" => ["{{variable}}", "Much array", "Hey, {{hello_world}}"]} |
35 |
- @checker.interpolate_options(@checker.options, @event).should == { |
|
35 |
+ expect(@checker.interpolate_options(@checker.options, @event)).to eq({ |
|
36 | 36 |
"value" => ["hello", "Much array", "Hey, Hello world"] |
37 |
- } |
|
37 |
+ }) |
|
38 | 38 |
end |
39 | 39 |
|
40 | 40 |
it "should work recursively" do |
41 | 41 |
@checker.options['hash'] = {'recursive' => "{{variable}}"} |
42 | 42 |
@checker.options['indifferent_hash'] = ActiveSupport::HashWithIndifferentAccess.new({'recursive' => "{{variable}}"}) |
43 |
- @checker.interpolate_options(@checker.options, @event).should == { |
|
43 |
+ expect(@checker.interpolate_options(@checker.options, @event)).to eq({ |
|
44 | 44 |
"normal" => "just some normal text", |
45 | 45 |
"variable" => "hello", |
46 | 46 |
"text" => "Some test with an embedded hello", |
47 | 47 |
"escape" => "This should be Hello+world", |
48 | 48 |
"hash" => {'recursive' => 'hello'}, |
49 | 49 |
"indifferent_hash" => {'recursive' => 'hello'}, |
50 |
- } |
|
50 |
+ }) |
|
51 | 51 |
end |
52 | 52 |
|
53 | 53 |
it "should work for strings" do |
54 |
- @checker.interpolate_string("{{variable}}", @event).should == "hello" |
|
55 |
- @checker.interpolate_string("{{variable}} you", @event).should == "hello you" |
|
54 |
+ expect(@checker.interpolate_string("{{variable}}", @event)).to eq("hello") |
|
55 |
+ expect(@checker.interpolate_string("{{variable}} you", @event)).to eq("hello you") |
|
56 | 56 |
end |
57 | 57 |
|
58 | 58 |
it "should use local variables while in a block" do |
59 | 59 |
@checker.options['locals'] = '{{_foo_}} {{_bar_}}' |
60 | 60 |
|
61 | 61 |
@checker.interpolation_context.tap { |context| |
62 |
- @checker.interpolated['locals'].should == ' ' |
|
62 |
+ expect(@checker.interpolated['locals']).to eq(' ') |
|
63 | 63 |
|
64 | 64 |
context.stack { |
65 | 65 |
context['_foo_'] = 'This is' |
66 | 66 |
context['_bar_'] = 'great.' |
67 | 67 |
|
68 |
- @checker.interpolated['locals'].should == 'This is great.' |
|
68 |
+ expect(@checker.interpolated['locals']).to eq('This is great.') |
|
69 | 69 |
} |
70 | 70 |
|
71 |
- @checker.interpolated['locals'].should == ' ' |
|
71 |
+ expect(@checker.interpolated['locals']).to eq(' ') |
|
72 | 72 |
} |
73 | 73 |
end |
74 | 74 |
|
75 | 75 |
it "should use another self object while in a block" do |
76 | 76 |
@checker.options['properties'] = '{{_foo_}} {{_bar_}}' |
77 | 77 |
|
78 |
- @checker.interpolated['properties'].should == ' ' |
|
78 |
+ expect(@checker.interpolated['properties']).to eq(' ') |
|
79 | 79 |
|
80 | 80 |
@checker.interpolate_with({ '_foo_' => 'That was', '_bar_' => 'nice.' }) { |
81 |
- @checker.interpolated['properties'].should == 'That was nice.' |
|
81 |
+ expect(@checker.interpolated['properties']).to eq('That was nice.') |
|
82 | 82 |
} |
83 | 83 |
|
84 |
- @checker.interpolated['properties'].should == ' ' |
|
84 |
+ expect(@checker.interpolated['properties']).to eq(' ') |
|
85 | 85 |
end |
86 | 86 |
end |
87 | 87 |
|
88 | 88 |
describe "liquid tags" do |
89 | 89 |
it "should work with existing credentials" do |
90 |
- @checker.interpolate_string("{% credential aws_key %}", {}).should == '2222222222-jane' |
|
90 |
+ expect(@checker.interpolate_string("{% credential aws_key %}", {})).to eq('2222222222-jane') |
|
91 | 91 |
end |
92 | 92 |
|
93 | 93 |
it "should raise an exception for undefined credentials" do |
@@ -9,58 +9,58 @@ shared_examples_for WebRequestConcern do |
||
9 | 9 |
|
10 | 10 |
describe "validations" do |
11 | 11 |
it "should be valid" do |
12 |
- agent.should be_valid |
|
12 |
+ expect(agent).to be_valid |
|
13 | 13 |
end |
14 | 14 |
|
15 | 15 |
it "should validate user_agent" do |
16 | 16 |
agent.options['user_agent'] = nil |
17 |
- agent.should be_valid |
|
17 |
+ expect(agent).to be_valid |
|
18 | 18 |
|
19 | 19 |
agent.options['user_agent'] = "" |
20 |
- agent.should be_valid |
|
20 |
+ expect(agent).to be_valid |
|
21 | 21 |
|
22 | 22 |
agent.options['user_agent'] = "foo" |
23 |
- agent.should be_valid |
|
23 |
+ expect(agent).to be_valid |
|
24 | 24 |
|
25 | 25 |
agent.options['user_agent'] = ["foo"] |
26 |
- agent.should_not be_valid |
|
26 |
+ expect(agent).not_to be_valid |
|
27 | 27 |
|
28 | 28 |
agent.options['user_agent'] = 1 |
29 |
- agent.should_not be_valid |
|
29 |
+ expect(agent).not_to be_valid |
|
30 | 30 |
end |
31 | 31 |
|
32 | 32 |
it "should validate headers" do |
33 | 33 |
agent.options['headers'] = "blah" |
34 |
- agent.should_not be_valid |
|
34 |
+ expect(agent).not_to be_valid |
|
35 | 35 |
|
36 | 36 |
agent.options['headers'] = "" |
37 |
- agent.should be_valid |
|
37 |
+ expect(agent).to be_valid |
|
38 | 38 |
|
39 | 39 |
agent.options['headers'] = {} |
40 |
- agent.should be_valid |
|
40 |
+ expect(agent).to be_valid |
|
41 | 41 |
|
42 | 42 |
agent.options['headers'] = { 'foo' => 'bar' } |
43 |
- agent.should be_valid |
|
43 |
+ expect(agent).to be_valid |
|
44 | 44 |
end |
45 | 45 |
|
46 | 46 |
it "should validate basic_auth" do |
47 | 47 |
agent.options['basic_auth'] = "foo:bar" |
48 |
- agent.should be_valid |
|
48 |
+ expect(agent).to be_valid |
|
49 | 49 |
|
50 | 50 |
agent.options['basic_auth'] = ["foo", "bar"] |
51 |
- agent.should be_valid |
|
51 |
+ expect(agent).to be_valid |
|
52 | 52 |
|
53 | 53 |
agent.options['basic_auth'] = "" |
54 |
- agent.should be_valid |
|
54 |
+ expect(agent).to be_valid |
|
55 | 55 |
|
56 | 56 |
agent.options['basic_auth'] = nil |
57 |
- agent.should be_valid |
|
57 |
+ expect(agent).to be_valid |
|
58 | 58 |
|
59 | 59 |
agent.options['basic_auth'] = "blah" |
60 |
- agent.should_not be_valid |
|
60 |
+ expect(agent).not_to be_valid |
|
61 | 61 |
|
62 | 62 |
agent.options['basic_auth'] = ["blah"] |
63 |
- agent.should_not be_valid |
|
63 |
+ expect(agent).not_to be_valid |
|
64 | 64 |
end |
65 | 65 |
end |
66 | 66 |
|
@@ -75,17 +75,17 @@ shared_examples_for WebRequestConcern do |
||
75 | 75 |
end |
76 | 76 |
|
77 | 77 |
it "should have the default value set by Faraday" do |
78 |
- agent.user_agent.should == Faraday.new.headers[:user_agent] |
|
78 |
+ expect(agent.user_agent).to eq(Faraday.new.headers[:user_agent]) |
|
79 | 79 |
end |
80 | 80 |
|
81 | 81 |
it "should be overridden by the environment variable if present" do |
82 | 82 |
ENV['DEFAULT_HTTP_USER_AGENT'] = 'Huginn - https://github.com/cantino/huginn' |
83 |
- agent.user_agent.should == 'Huginn - https://github.com/cantino/huginn' |
|
83 |
+ expect(agent.user_agent).to eq('Huginn - https://github.com/cantino/huginn') |
|
84 | 84 |
end |
85 | 85 |
|
86 | 86 |
it "should be overriden by the value in options if present" do |
87 | 87 |
agent.options['user_agent'] = 'Override' |
88 |
- agent.user_agent.should == 'Override' |
|
88 |
+ expect(agent.user_agent).to eq('Override') |
|
89 | 89 |
end |
90 | 90 |
end |
91 | 91 |
end |
@@ -7,23 +7,23 @@ shared_examples_for WorkingHelpers do |
||
7 | 7 |
|
8 | 8 |
agent.last_error_log_at = 10.minutes.ago |
9 | 9 |
agent.last_event_at = 10.minutes.ago |
10 |
- agent.recent_error_logs?.should be_truthy |
|
10 |
+ expect(agent.recent_error_logs?).to be_truthy |
|
11 | 11 |
|
12 | 12 |
agent.last_error_log_at = 11.minutes.ago |
13 | 13 |
agent.last_event_at = 10.minutes.ago |
14 |
- agent.recent_error_logs?.should be_truthy |
|
14 |
+ expect(agent.recent_error_logs?).to be_truthy |
|
15 | 15 |
|
16 | 16 |
agent.last_error_log_at = 5.minutes.ago |
17 | 17 |
agent.last_event_at = 10.minutes.ago |
18 |
- agent.recent_error_logs?.should be_truthy |
|
18 |
+ expect(agent.recent_error_logs?).to be_truthy |
|
19 | 19 |
|
20 | 20 |
agent.last_error_log_at = 15.minutes.ago |
21 | 21 |
agent.last_event_at = 10.minutes.ago |
22 |
- agent.recent_error_logs?.should be_falsey |
|
22 |
+ expect(agent.recent_error_logs?).to be_falsey |
|
23 | 23 |
|
24 | 24 |
agent.last_error_log_at = 2.days.ago |
25 | 25 |
agent.last_event_at = 10.minutes.ago |
26 |
- agent.recent_error_logs?.should be_falsey |
|
26 |
+ expect(agent.recent_error_logs?).to be_falsey |
|
27 | 27 |
end |
28 | 28 |
end |
29 | 29 |
|
@@ -33,21 +33,21 @@ shared_examples_for WorkingHelpers do |
||
33 | 33 |
end |
34 | 34 |
|
35 | 35 |
it "should return false until the first event was received" do |
36 |
- @agent.received_event_without_error?.should == false |
|
36 |
+ expect(@agent.received_event_without_error?).to eq(false) |
|
37 | 37 |
@agent.last_receive_at = Time.now |
38 |
- @agent.received_event_without_error?.should == true |
|
38 |
+ expect(@agent.received_event_without_error?).to eq(true) |
|
39 | 39 |
end |
40 | 40 |
|
41 | 41 |
it "should return false when the last error occured after the last received event" do |
42 | 42 |
@agent.last_receive_at = Time.now - 1.minute |
43 | 43 |
@agent.last_error_log_at = Time.now |
44 |
- @agent.received_event_without_error?.should == false |
|
44 |
+ expect(@agent.received_event_without_error?).to eq(false) |
|
45 | 45 |
end |
46 | 46 |
|
47 | 47 |
it "should return true when the last received event occured after the last error" do |
48 | 48 |
@agent.last_receive_at = Time.now |
49 | 49 |
@agent.last_error_log_at = Time.now - 1.minute |
50 |
- @agent.received_event_without_error?.should == true |
|
50 |
+ expect(@agent.received_event_without_error?).to eq(true) |
|
51 | 51 |
end |
52 | 52 |
end |
53 | 53 |
end |