|
|
@@ -5,7 +5,10 @@ describe Agents::AftershipAgent do
|
5
|
5
|
|
6
|
6
|
@opts = {
|
7
|
7
|
"api_key" => '800deeaf-e285-9d62-bc90-j999c1973cc9',
|
8
|
|
- "get" => 'trackings'
|
|
8
|
+ "get" => 'trackings',
|
|
9
|
+ "slug" => 'usps',
|
|
10
|
+ "tracking_number" => "9361289684090010005054"
|
|
11
|
+
|
9
|
12
|
}
|
10
|
13
|
|
11
|
14
|
@checker = Agents::AftershipAgent.new(:name => "tectonic", :options => @opts)
|
|
|
@@ -13,6 +16,20 @@ describe Agents::AftershipAgent do
|
13
|
16
|
@checker.save!
|
14
|
17
|
end
|
15
|
18
|
|
|
19
|
+ describe '#helpers' do
|
|
20
|
+ it "should return the correct request header" do
|
|
21
|
+ expect(@checker.send(:request_options)).to eq({:headers => {"aftership-api-key" => '800deeaf-e285-9d62-bc90-j999c1973cc9', "Content-Type"=>"application/json"}})
|
|
22
|
+ end
|
|
23
|
+
|
|
24
|
+ it "should generate the correct events url" do
|
|
25
|
+ expect(@checker.send(:event_url)).to eq("https://api.aftership.com/v4/trackings")
|
|
26
|
+ end
|
|
27
|
+
|
|
28
|
+ it "should generate the correct single or checkpoint tracking url" do
|
|
29
|
+ expect(@checker.send(:single_or_checkpoint_tracking_url)).to eq("https://api.aftership.com/v4/trackings/usps/9361289684090010005054")
|
|
30
|
+ end
|
|
31
|
+ end
|
|
32
|
+
|
16
|
33
|
describe "#that checker should be valid" do
|
17
|
34
|
it "should check that the aftership object is valid" do
|
18
|
35
|
expect(@checker).to be_valid
|
|
|
@@ -33,4 +50,6 @@ describe Agents::AftershipAgent do
|
33
|
50
|
expect(@checker.errors.full_messages.first).to eq("You need to specify a get request")
|
34
|
51
|
end
|
35
|
52
|
end
|
|
53
|
+
|
|
54
|
+ describe '#check'
|
36
|
55
|
end
|