-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ulverson
committed
Jun 9, 2017
1 parent
3292d61
commit 8e6675c
Showing
7 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Rails.application.routes.draw do | ||
root to: "charts#index" | ||
get "charts/:name", to: "charts#show", as: :chart | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require "rails_helper" | ||
require 'charts' | ||
|
||
describe ChartsController, type: :controller do | ||
|
||
let(:api_request) { Charts::ApiRequest.new(bitbay_request_url) } | ||
let(:storage) { Charts::ResponseStorage.new(api_request, "btc_usd") } | ||
|
||
context "when there is chart data" do | ||
before do | ||
stub_bitbay_successfull_response | ||
storage.store_request | ||
end | ||
|
||
it "returns chart data" do | ||
get :show, params: { name: "bitcoin" } | ||
expect(response).to be_success | ||
expect(JSON.parse(response.body)).to eq(storage.values) | ||
end | ||
|
||
end | ||
|
||
context "when there is no chart data" do | ||
|
||
it "returns empty array" do | ||
get :show, params: { name: "ethereum" } | ||
expect(response).to be_success | ||
expect(JSON.parse(response.body)).to eq([]) | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
module Requests | ||
end | ||
|
||
require_relative "requests/bitbay" | ||
require_relative "requests/bitbay" | ||
require_relative "requests/json_helpers/request_helpers" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Requests | ||
module JsonHelpers | ||
def json | ||
JSON.parse(response.body) | ||
end | ||
end | ||
end |