forked from swagger-api/swagger-codegen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pet_spec.rb
69 lines (58 loc) · 1.6 KB
/
pet_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
require 'spec_helper'
describe "Pet" do
before do
Swagger.configure do |config|
config.api_key = 'special-key'
config.host = 'petstore.swagger.wordnik.com'
config.base_path = '/api'
end
end
describe "pet methods" do
it "should fetch a pet object" do
pet = Pet_api.get_pet_by_id(1)
pet.id.should == 1
pet.name.should == "Cat 1"
end
it "should find pets by status" do
pets = Pet_api.find_pets_by_status('available')
pets.length.should >= 3
end
it "should not find a pet with invalid status" do
pets = Pet_api.find_pets_by_status('dead')
pets.length.should == 0
end
it "should find a pet by status" do
pets = Pet_api.find_pets_by_status("available,sold")
pets.map {|pet|
if(pet.status != 'available' && pet.status != 'sold')
raise "pet status wasn't right"
end
}
end
it "should update a pet" do
pet = Pet.new({:id => 99, :name => 'programmer', :status => 'coding'})
Pet_api.add_pet(pet)
fetched = Pet_api.get_pet_by_id(99)
fetched.id.should == 99
end
it "should create a pet" do
pet = Pet.new({:id => 100, :name => "Gorilla"})
Pet_api.add_pet(pet)
pet = Pet_api.get_pet_by_id(100)
pet.id.should == 100
end
end
end
describe "Store" do
before do
Swagger.configure do |config|
config.api_key = 'special-key'
config.host = 'petstore.swagger.wordnik.com'
config.base_path = '/api'
end
end
it "should fetch an order" do
item = Store_api.get_order_by_id(1)
item.id.should == 1
end
end