|
38 | 38 | end |
39 | 39 | end |
40 | 40 |
|
41 | | - describe 'returned fields' do |
42 | | - it 'returns the expected fields' do |
43 | | - project = Patch::Project.retrieve_projects(page: 1).data.first |
44 | | - |
45 | | - keys = attributes_for(:project).keys |
46 | | - expect(project.to_hash.keys).to include(*keys) |
47 | | - |
48 | | - expect(project.photos).to be_an_instance_of(Array) |
49 | | - expect(project.average_price_per_tonne_cents_usd) |
50 | | - .to be_an_instance_of(Integer) |
51 | | - expect(project.remaining_mass_g).to be_an_instance_of(Integer) |
52 | | - expect(project.longitude).to be_an_instance_of(Float) |
53 | | - expect(project.latitude).to be_an_instance_of(Float) |
54 | | - |
55 | | - expect(project.technology_type) |
56 | | - .to be_an_instance_of(Patch::TechnologyType) |
57 | | - expect(project.technology_type.name).to be_an_instance_of(String) |
58 | | - expect(project.technology_type.slug).to be_an_instance_of(String) |
59 | | - |
60 | | - parent_type = project.technology_type.parent_technology_type |
61 | | - expect(parent_type).to be_an_instance_of(Patch::ParentTechnologyType) |
62 | | - expect(parent_type.name).to be_an_instance_of(String) |
63 | | - expect(parent_type.slug).to be_an_instance_of(String) |
64 | | - |
65 | | - expect(project.highlights).to be_an_instance_of(Array) |
66 | | - |
67 | | - inventory = project.inventory |
68 | | - expect(inventory).to be_an_instance_of(Array) |
69 | | - expect(inventory[0]).to be_an_instance_of(Patch::Inventory) |
70 | | - expect(inventory[0].vintage_year).to be_an_instance_of(Integer) |
71 | | - expect(inventory[0].amount_available).to be_an_instance_of(Integer) |
72 | | - expect(inventory[0].price).to be_an_instance_of(Integer) |
73 | | - expect(inventory[0].currency).to be_an_instance_of(String) |
74 | | - expect(inventory[0].unit).to be_an_instance_of(String) |
75 | | - end |
| 41 | + it 'returns the expected fields' do |
| 42 | + project = Patch::Project.retrieve_projects(page: 1).data.first |
| 43 | + |
| 44 | + keys = attributes_for(:project).keys |
| 45 | + expect(project.to_hash.keys).to include(*keys) |
| 46 | + |
| 47 | + expect(project.photos).to be_an_instance_of(Array) |
| 48 | + expect(project.average_price_per_tonne_cents_usd) |
| 49 | + .to be_an_instance_of(Integer) |
| 50 | + expect(project.remaining_mass_g).to be_an_instance_of(Integer) |
| 51 | + expect(project.longitude).to be_an_instance_of(Float) |
| 52 | + expect(project.latitude).to be_an_instance_of(Float) |
| 53 | + |
| 54 | + expect(project.technology_type) |
| 55 | + .to be_an_instance_of(Patch::TechnologyType) |
| 56 | + expect(project.technology_type.name).to be_an_instance_of(String) |
| 57 | + expect(project.technology_type.slug).to be_an_instance_of(String) |
| 58 | + |
| 59 | + parent_type = project.technology_type.parent_technology_type |
| 60 | + expect(parent_type).to be_an_instance_of(Patch::ParentTechnologyType) |
| 61 | + expect(parent_type.name).to be_an_instance_of(String) |
| 62 | + expect(parent_type.slug).to be_an_instance_of(String) |
| 63 | + |
| 64 | + expect(project.highlights).to be_an_instance_of(Array) |
| 65 | + |
| 66 | + inventory = project.inventory |
| 67 | + expect(inventory).to be_an_instance_of(Array) |
| 68 | + expect(inventory[0]).to be_an_instance_of(Patch::Inventory) |
| 69 | + expect(inventory[0].vintage_year).to be_an_instance_of(Integer) |
| 70 | + expect(inventory[0].amount_available).to be_an_instance_of(Integer) |
| 71 | + expect(inventory[0].price).to be_an_instance_of(Integer) |
| 72 | + expect(inventory[0].currency).to be_an_instance_of(String) |
| 73 | + expect(inventory[0].unit).to be_an_instance_of(String) |
| 74 | + end |
| 75 | + |
| 76 | + it 'retrieves projects in the requested language' do |
| 77 | + projects_response = Patch::Project.retrieve_projects(accept_language: 'fr') |
| 78 | + |
| 79 | + expect(projects_response.data.first.name).to include 'Projet' # French |
| 80 | + |
| 81 | + project_id = projects_response.data.first.id |
| 82 | + project_response = Patch::Project.retrieve_project(project_id, accept_language: 'fr') |
| 83 | + expect(project_response.data.name).to include 'Projet' # Frenc |
76 | 84 | end |
77 | 85 | end |
0 commit comments