Sha256: 8c455bee41e795ab79d3b3113a7b40ebc84109c6a5a76704b6e8d39208e3f167
Contents?: true
Size: 794 Bytes
Versions: 4
Compression:
Stored size: 794 Bytes
Contents
require File.expand_path('../test_helper', __FILE__) DB.create_table :albums do primary_key :id String :title String :artist end class Album < Sequel::Model def to_json "X" end def to_hash { :name => name, :author => author } end def to_xml "lol" end end class ToJsonTest < UnitTest class App < Sinatra::Base register Sinatra::RestAPI disable :show_exceptions enable :raise_errors rest_resource("/album/:id") { |id| Album[id] } end def app() App; end setup do @album = Album.new @album.title = "Tanto Tempo" @album.artist = "Bebel Gilberto" @album.save header 'Accept', 'application/json, */*' end test "use to_json" do get "/album/#{@album.id}" assert last_response.body == @album.to_json end end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
sinatra-backbone-2-0.1.1 | test/to_json_test.rb |
sinatra-backbone-0.1.1 | test/to_json_test.rb |
sinatra-backbone-0.1.0.rc2 | test/to_json_test.rb |
sinatra-backbone-0.1.0.rc1 | test/to_json_test.rb |