Skip to content

Commit

Permalink
Updated recipe endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
parix committed Jun 29, 2015
1 parent 6d8ea4a commit 86d67da
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 22 deletions.
8 changes: 4 additions & 4 deletions lib/gw2/recipe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ module GW2
module Recipe
extend Resource

def self.all
get("/recipes.json")["recipes"]
def self.ids
get("/recipes")
end

def self.details(recipe_id)
get("/recipe_details.json", { recipe_id: recipe_id })
def self.find(recipe_id)
get("/recipes/#{recipe_id}")
end
end
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions spec/fixtures/GW2_Recipe/_ids/returns_all_recipes.yml

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions spec/gw2/recipe_spec.rb
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
require "spec_helper"

describe GW2::Recipe do
describe ".all" do
describe ".ids" do
before :each do
@recipes = [1275, 1276, 1277, 1278, 1279]
end

it "exists" do
expect(GW2::Recipe.respond_to?(:all)).to eq(true)
expect(GW2::Recipe.respond_to?(:ids)).to eq(true)
end

it "returns all recipes", :vcr do
expect(GW2::Recipe.all).to include(*@recipes)
expect(GW2::Recipe.ids).to include(*@recipes)
end
end

describe ".details" do
describe ".find" do
before :each do
@recipe_details = {
"recipe_id" => "1275",
"type" => "Coat",
"output_item_id" => "11541",
"output_item_count" => "1",
"min_rating" => "25",
"time_to_craft_ms" => "1000",
"disciplines"=>["Leatherworker"],
"flags"=>[],
"type" => "RefinementEctoplasm",
"output_item_id" => 46742,
"output_item_count" => 1,
"min_rating" => 450,
"time_to_craft_ms" => 5000,
"disciplines" => [ "Armorsmith", "Artificer", "Huntsman", "Weaponsmith" ],
"flags" => [ "AutoLearned" ],
"ingredients" => [
{"item_id" => "19797","count" => "1"},
{"item_id" => "13094","count" => "1"},
{"item_id" => "13093","count" => "1"}
]
{ "item_id" => 19684, "count" => 50 },
{ "item_id" => 19721, "count" => 1 },
{ "item_id" => 46747, "count" => 10 }
],
"id" => 7319
}
end

it "exists" do
expect(GW2::Recipe.respond_to?(:details)).to eq(true)
expect(GW2::Recipe.respond_to?(:find)).to eq(true)
end

it "returns the details of a recipe by id", :vcr do
expect(GW2::Recipe.details(1275)).to eq(@recipe_details)
expect(GW2::Recipe.find(7319)).to eq(@recipe_details)
end
end
end

0 comments on commit 86d67da

Please sign in to comment.