Skip to content

Instantly share code, notes, and snippets.

@yjean
Created March 22, 2012 14:39
Show Gist options
  • Save yjean/2158688 to your computer and use it in GitHub Desktop.
Save yjean/2158688 to your computer and use it in GitHub Desktop.
Simple use of capybara-json
require "test_helper"
describe "Posts APIJSon" do
describe Post do
it "returns list of posts in json format" do
10.times {|i| Post.create!(:subject => "Post #{i}", :body => "...", :user => User.new)}
expected_count = Post.all.size
get posts_path(:format => :json)
body.first["id"].must_equal 1
body.size.must_equal expected_count
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment