Skip to content

Instantly share code, notes, and snippets.

@r7kamura
Created April 25, 2013 15:20
Show Gist options
  • Save r7kamura/5460542 to your computer and use it in GitHub Desktop.
Save r7kamura/5460542 to your computer and use it in GitHub Desktop.
be_json_spec.rb
it "returns an array of resources" do
get "https://api.github.com/resource"
response.body.should be_json([
{
"url" => /^https:/,
"id" => /^\d+$/,
"description" => /gist/,
"public" => true,
"user" => Hash,
"files" => Hash,
"comments" => Fixnum,
"comments_url" => /^https:/,
"html_url" => /^https:/,
"git_pull_url" => /^git:/,
"git_push_url" => /^git@/,
"created_at" => /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ/,
}
])
end
# actual response
# [
# {
# "url" => "https://api.github.com/gists/17a07d0a27fd3f708f5f",
# "id" => "1",
# "description" => "description of gist",
# "public" => true,
# "user" => {
# "login" => "octocat",
# "id" => 1,
# "avatar_url" => "https://github.com/images/error/octocat_happy.gif",
# "gravatar_id" => "somehexcode",
# "url" => "https://api.github.com/users/octocat"
# },
# "files" => {
# "ring.erl" => {
# "size" => 932,
# "filename" => "ring.erl",
# "raw_url" => "https://gist.github.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl"
# }
# },
# "comments" => 0,
# "comments_url" => "https://api.github.com/gists/6fb6af8cb6e26dbbc327/comments/",
# "html_url" => "https://gist.github.com/1",
# "git_pull_url" => "git://gist.github.com/1.git",
# "git_push_url" => "git@gist.github.com:1.git",
# "created_at" => "2010-04-14T02:15:15Z"
# }
# ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment