-
Notifications
You must be signed in to change notification settings - Fork 43
/
albums_controller_spec.rb
60 lines (48 loc) · 1.88 KB
/
albums_controller_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe AlbumsController do
before do
response.stub(:content_type) { "application/atom+xml" }
3.times do |i|
album = Album.create!(:title => "Album #{i}", :description => "Description #{i}", :length => i*10)
4.times do |j|
album.songs.create!(:title => "Song #{j} from Album #{i}", :description => "Description for song #{j} from Album #{i}", :length => j*10 + i)
end
end
end
render_views
describe "get index" do
before do
request.accept = "application/atom+xml"
get :index, :format => :atom
@feed = Restfulie::Common::Representation::Atom::Factory.create(response.body)
end
it "generation atom feed to get index" do
@feed.entries.size.should == Album.count
end
it "title feed personalize" do
@feed.title.should == "Index Album feed spec"
end
it "members artists transitions included" do
transitions = @feed.entries.first.links
transitions.find {|t| t.rel == 'artists'}.should be_kind_of(::Restfulie::Common::Representation::Atom::Link)
end
end # describe "get index"
describe "get show" do
before do
response.content_type = "application/atom+xml"
@album = Album.first
pending
get :show, :id => @album.id, :format => :atom
@entry = Restfulie::Common::Representation::Atom::Factory.create(response.body)
end
it "generation atom entry" do
pending
@entry.title.should == @album.title
end
it "return extension values" do
pending
@entry.doc.at_xpath("albums:length_in_minutes", "albums" => "http://localhost/albums").content.to_i.should == @album.length
@entry.doc.at_xpath("albums:description", "albums" => "http://localhost/albums").content.should == @album.description
end
end # describe "get show"
end