From cb4d2f5660fea741fab82cd14adba1f1ae1532d9 Mon Sep 17 00:00:00 2001 From: Peter Golm Date: Tue, 17 Dec 2013 23:26:28 +0100 Subject: [PATCH] improve code --- spec/factories/inventory.rb | 8 ++------ spec/requests/apis_spec.rb | 6 ++++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/spec/factories/inventory.rb b/spec/factories/inventory.rb index ef53ae4..a2cbf78 100644 --- a/spec/factories/inventory.rb +++ b/spec/factories/inventory.rb @@ -5,15 +5,11 @@ name { "Inventory#{id}" } owner { create(:user) } - trait :with_host do - hosts { create_list(:host, 1, inventory_id: id) } - end - trait :with_hosts do - hosts { create_list(:host, 12, inventory_id: id) } + hosts { create_list(:host, 3, inventory_id: id) } end - factory :small_inventory, traits: [:with_host] + factory :small_inventory, traits: [:with_hosts] factory :big_inventory, traits: [:with_hosts] end diff --git a/spec/requests/apis_spec.rb b/spec/requests/apis_spec.rb index ded6c5e..2d3f103 100644 --- a/spec/requests/apis_spec.rb +++ b/spec/requests/apis_spec.rb @@ -31,9 +31,9 @@ expect(response.body).to eq @expected end - it "returns a inventory with host" do + it "returns a inventory with hosts" do @expected = { - all: [small_inventory.hosts[0].alias], + all: small_inventory.hosts.map(&:alias), }.to_json get "/api/v1/inventory/#{small_inventory.key}?token=#{admin.api_key}" @@ -41,6 +41,8 @@ expect(response.status).to eq 200 expect(response.body).to eq @expected end + + it "returns an inventory with groups" end describe "GET host" do