-
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
1 parent
320c379
commit dfc19ee
Showing
5 changed files
with
64 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'hashie' | ||
require 'tankard/api/request/get' | ||
require 'tankard/api/utils/finders' | ||
|
||
module Tankard | ||
module Api | ||
class Styles | ||
include ::Enumerable | ||
include Tankard::Api::Request::Get | ||
include Tankard::Api::Utils::Finders | ||
|
||
def initialize(request) | ||
@request = request | ||
end | ||
|
||
def each(&block) | ||
find_on_single_page("styles", @request, nil, block) | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require 'spec_helper' | ||
|
||
describe Tankard::Api::Styles do | ||
|
||
let(:styles) { Tankard::Api::Styles.new(@request) } | ||
|
||
before do | ||
@request = mock("request") | ||
end | ||
|
||
describe "when making a request" do | ||
|
||
context "and no data is returned" do | ||
|
||
it "raises a Tankard::Error::InvalidResponse error" do | ||
@request.stub(:get).with("styles", nil).and_return({}) | ||
expect { styles.collect { |x| x} }.to raise_error(Tankard::Error::InvalidResponse) | ||
end | ||
end | ||
|
||
it "returns the data portion of the request" do | ||
@request.stub(:get).with("styles", nil).and_return({"data" => ["test1", "test2"]}) | ||
expect(styles.collect { |x| x}).to eql(["test1", "test2"]) | ||
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