Created
October 1, 2013 09:24
-
-
Save phawk/6775938 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require_relative "../../../acceptance_helper.rb" | |
# require File.expand_path("../../../../acceptance_helper", __FILE__) | |
describe "api/v1/colours" do | |
before do | |
@data = { | |
url: "http://illustrationage.files.wordpress.com/2013/08/breaking-bad-walter-white-darth-heisenberg-pj-mcquade-9.jpg", | |
filename: "breaking-bad-walter-white-darth-heisenberg-pj-mcquade-9.jpg" | |
} | |
end | |
describe "when colour_count is left out" do | |
let(:single_json) { get_json "/api/v1/colours/http%3A%2F%2Fillustrationage.files.wordpress.com%2F2013%2F08%2Fbreaking-bad-walter-white-darth-heisenberg-pj-mcquade-9.jpg" } | |
let(:image) { single_json[:image] } | |
it "is successful" do | |
assert_equal single_json[:status], "success" | |
end | |
it "has 4 colours" do | |
assert_equal image[:dominant_colours].size, 4 | |
end | |
it "colours have info" do | |
colour = image[:dominant_colours].first | |
refute_nil colour[:hex] | |
refute_nil colour[:name] | |
refute_nil colour[:basic_name] | |
end | |
it "has a url" do | |
assert_equal image[:url], @data[:url] | |
end | |
it "has a filename" do | |
assert_equal image[:filename], @data[:filename] | |
end | |
end | |
describe "when colour_count is passed" do | |
let(:multi_json) { get_json "/api/v1/colours/http%3A%2F%2Fillustrationage.files.wordpress.com%2F2013%2F08%2Fbreaking-bad-walter-white-darth-heisenberg-pj-mcquade-9.jpg/10" } | |
let(:image) { multi_json[:image] } | |
it "is successful" do | |
assert_equal multi_json[:status], "success" | |
end | |
it "has 10 colours" do | |
assert_equal image[:dominant_colours].size, 10 | |
end | |
it "colours have info" do | |
colour = image[:dominant_colours].first | |
refute_nil colour[:hex] | |
refute_nil colour[:name] | |
refute_nil colour[:basic_name] | |
end | |
it "has a url" do | |
assert_equal image[:url], @data[:url] | |
end | |
it "has a filename" do | |
assert_equal image[:filename], @data[:filename] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment