Fingertips-jewelry_portfolio 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +69 -87
- data/VERSION.yml +2 -2
- data/lib/jewelry_portfolio.rb +18 -9
- data/lib/jewelry_portfolio/repo.rb +19 -3
- data/lib/jewelry_portfolio/repos_index.rb +1 -0
- data/lib/jewelry_portfolio/template.rb +18 -44
- data/lib/jewelry_portfolio/template/feed.rb +123 -0
- data/lib/jewelry_portfolio/template/html.rb +18 -0
- data/test/fixtures/alloy.github.com.tgz +0 -0
- data/test/fixtures/dr-nic-magic-awesome.gemspec_ +2 -0
- data/test/fixtures/feed_with_defaults.rb +1 -0
- data/test/fixtures/feed_with_defaults.xml +27 -0
- data/test/fixtures/feed_with_options.rb +26 -0
- data/test/fixtures/feed_with_options.xml +27 -0
- data/test/fixtures/index.erb +8 -0
- data/test/fixtures/index.html +11 -0
- data/test/fixtures/microgem.gemspec_ +2 -0
- data/test/fixtures/repos.yml +2 -0
- data/test/jewelry_portfolio_test.rb +24 -8
- data/test/repo_test.rb +28 -3
- data/test/repos_index_test.rb +18 -10
- data/test/template_test.rb +175 -42
- metadata +44 -15
- data/test/fixtures/repo.html.erb +0 -2
- data/test/fixtures/template.html +0 -8
- data/test/fixtures/template.html.erb +0 -5
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
class JewelryPortfolio
|
4
|
+
class Template
|
5
|
+
# This class is responsible for rendering a HTML template.
|
6
|
+
class HTML < Template
|
7
|
+
# Returns the repos ordered by name.
|
8
|
+
def repos
|
9
|
+
super.sort_by { |r| r.name }
|
10
|
+
end
|
11
|
+
|
12
|
+
# Renders the HTML and returns the output.
|
13
|
+
def render
|
14
|
+
ERB.new(File.read(@file)).result(binding)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
# nothing is overriden
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<feed xmlns="http://www.w3.org/2005/Atom">
|
3
|
+
<id>http://alloy.github.com/</id>
|
4
|
+
<link href="http://alloy.github.com/feed.xml" rel="self"/>
|
5
|
+
<updated>TIME_NOW</updated>
|
6
|
+
<author>
|
7
|
+
<name>alloy</name>
|
8
|
+
</author>
|
9
|
+
<title>Code from alloy</title>
|
10
|
+
<subtitle>The Ruby libraries, from alloy, available as open-source projects</subtitle>
|
11
|
+
<entry>
|
12
|
+
<id>http://github.com/alloy/microgem/tree/master#0.2.0</id>
|
13
|
+
<updated>2009-03-04T00:00:00Z</updated>
|
14
|
+
<title>microgem 0.2.0</title>
|
15
|
+
<link href="http://github.com/alloy/microgem/tree/master"/>
|
16
|
+
<summary>MicroGem provides a simple naive replacement for the `gem install' command in the form of the `mgem' commandline utility.</summary>
|
17
|
+
<content>MicroGem provides a simple naive replacement for the `gem install' command in the form of the `mgem' commandline utility.</content>
|
18
|
+
</entry>
|
19
|
+
<entry>
|
20
|
+
<id>http://github.com/alloy/dr-nic-magic-awesome/tree/master#1.0.0</id>
|
21
|
+
<updated>2009-03-04T00:00:00Z</updated>
|
22
|
+
<title>dr-nic-magic-awesome 1.0.0</title>
|
23
|
+
<link href="http://github.com/alloy/dr-nic-magic-awesome/tree/master"/>
|
24
|
+
<summary>Magically fix your projects overnight!</summary>
|
25
|
+
<content>A gem which summons Dr. Nic to fix all your projects while you are cuddled underneath your blankie.</content>
|
26
|
+
</entry>
|
27
|
+
</feed>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
feed.title = 'Code from Eloy Duran (alloy)'
|
2
|
+
feed.description = 'The Ruby libraries, from Eloy Duran, available as open-source projects'
|
3
|
+
|
4
|
+
def feed.id_for_repo(repo)
|
5
|
+
"#{repo.name}-#{repo.version}"
|
6
|
+
end
|
7
|
+
|
8
|
+
def feed.updated_for_repo(repo)
|
9
|
+
'Right about NOW!'
|
10
|
+
end
|
11
|
+
|
12
|
+
def feed.title_for_repo(repo)
|
13
|
+
"#{repo.name.capitalize} (#{repo.version})"
|
14
|
+
end
|
15
|
+
|
16
|
+
def feed.link_for_repo(repo)
|
17
|
+
"http://google.com?q=#{repo.name}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def feed.summary_for_repo(repo)
|
21
|
+
"#{repo.name.capitalize} is awesome!"
|
22
|
+
end
|
23
|
+
|
24
|
+
def feed.description_for_repo(repo)
|
25
|
+
summary_for_repo(repo)
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<feed xmlns="http://www.w3.org/2005/Atom">
|
3
|
+
<id>http://alloy.github.com/</id>
|
4
|
+
<link href="http://alloy.github.com/feed.xml" rel="self"/>
|
5
|
+
<updated>TIME_NOW</updated>
|
6
|
+
<author>
|
7
|
+
<name>alloy</name>
|
8
|
+
</author>
|
9
|
+
<title>Code from Eloy Duran (alloy)</title>
|
10
|
+
<subtitle>The Ruby libraries, from Eloy Duran, available as open-source projects</subtitle>
|
11
|
+
<entry>
|
12
|
+
<id>microgem-0.2.0</id>
|
13
|
+
<updated>Right about NOW!</updated>
|
14
|
+
<title>Microgem (0.2.0)</title>
|
15
|
+
<link href="http://google.com?q=microgem"/>
|
16
|
+
<summary>Microgem is awesome!</summary>
|
17
|
+
<content>Microgem is awesome!</content>
|
18
|
+
</entry>
|
19
|
+
<entry>
|
20
|
+
<id>dr-nic-magic-awesome-1.0.0</id>
|
21
|
+
<updated>Right about NOW!</updated>
|
22
|
+
<title>Dr-nic-magic-awesome (1.0.0)</title>
|
23
|
+
<link href="http://google.com?q=dr-nic-magic-awesome"/>
|
24
|
+
<summary>Dr-nic-magic-awesome is awesome!</summary>
|
25
|
+
<content>Dr-nic-magic-awesome is awesome!</content>
|
26
|
+
</entry>
|
27
|
+
</feed>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<html>
|
2
|
+
<body>
|
3
|
+
|
4
|
+
<h1>dr-nic-magic-awesome</h1>
|
5
|
+
<p>A gem which summons Dr. Nic to fix all your projects while you are cuddled underneath your blankie.</p>
|
6
|
+
|
7
|
+
<h1>microgem</h1>
|
8
|
+
<p>MicroGem provides a simple naive replacement for the `gem install' command in the form of the `mgem' commandline utility.</p>
|
9
|
+
|
10
|
+
</body>
|
11
|
+
</html>
|
data/test/fixtures/repos.yml
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
gem: true
|
6
6
|
name: dr-nic-magic-awesome
|
7
7
|
summary: Magically fix your projects overnight!
|
8
|
+
updated_at: 2009-03-04 00:00:00 Z
|
8
9
|
version: 1.0.0
|
9
10
|
- !ruby/object:JewelryPortfolio::Repo
|
10
11
|
account: alloy
|
@@ -12,4 +13,5 @@
|
|
12
13
|
gem: true
|
13
14
|
name: microgem
|
14
15
|
summary: MicroGem provides a simple naive replacement for the `gem install' command in the form of the `mgem' commandline utility.
|
16
|
+
updated_at: 2009-03-04 00:00:00 Z
|
15
17
|
version: 0.2.0
|
@@ -42,16 +42,30 @@ describe "JewelryPortfolio" do
|
|
42
42
|
index.repos.map { |r| r.name }.should == %w{ dr-nic-magic-awesome microgem }
|
43
43
|
end
|
44
44
|
|
45
|
-
it "should return the template" do
|
46
|
-
template = @portfolio.
|
47
|
-
template.should.be.instance_of JewelryPortfolio::Template
|
48
|
-
template.
|
49
|
-
template.
|
45
|
+
it "should return the html template" do
|
46
|
+
template = @portfolio.html_template
|
47
|
+
template.should.be.instance_of JewelryPortfolio::Template::HTML
|
48
|
+
template.file.should == File.join(@portfolio.index.path, 'index.erb')
|
49
|
+
template.account.should == 'alloy'
|
50
|
+
template.repos.should == @portfolio.index.repos.to_a.sort_by { |r| r.name }
|
50
51
|
end
|
51
52
|
|
52
|
-
it "should
|
53
|
+
it "should return the feed template" do
|
54
|
+
template = @portfolio.feed_template
|
55
|
+
template.should.be.instance_of JewelryPortfolio::Template::Feed
|
56
|
+
template.file.should == File.join(@portfolio.index.path, 'feed.rb')
|
57
|
+
template.account.should == 'alloy'
|
58
|
+
template.repos.should == @portfolio.index.repos.to_a.sort
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should write out the template and feed" do
|
62
|
+
time = Time.now
|
63
|
+
Time.stubs(:now).returns(time)
|
64
|
+
expected_feed = File.read(fixture('feed_with_options.xml')).gsub('TIME_NOW', time.iso8601)
|
65
|
+
|
53
66
|
@portfolio.render!
|
54
|
-
File.read(File.join(@portfolio.index.path, 'index.html')).should == File.read(fixture('
|
67
|
+
File.read(File.join(@portfolio.index.path, 'index.html')).should == File.read(fixture('index.html'))
|
68
|
+
File.read(File.join(@portfolio.index.path, 'feed.xml')).should == expected_feed
|
55
69
|
end
|
56
70
|
|
57
71
|
it "should render, commit, and push the master branch" do
|
@@ -66,7 +80,9 @@ end
|
|
66
80
|
describe "JewelryPortfolio, with a custom work_directory" do
|
67
81
|
before do
|
68
82
|
JewelryPortfolio::ReposIndex.any_instance.stubs(:load_pages_repo!)
|
69
|
-
JewelryPortfolio::Template.stubs(:new)
|
83
|
+
JewelryPortfolio::Template::HTML.stubs(:new)
|
84
|
+
JewelryPortfolio::Template::Feed.stubs(:new)
|
85
|
+
|
70
86
|
@portfolio = JewelryPortfolio.new('alloy')
|
71
87
|
end
|
72
88
|
|
data/test/repo_test.rb
CHANGED
@@ -50,10 +50,11 @@ module SharedRepoSpecs
|
|
50
50
|
it "should return itself serialized as YAML" do
|
51
51
|
loaded_repo = YAML.load(@repo.to_yaml)
|
52
52
|
|
53
|
-
loaded_repo.name.should
|
54
|
-
loaded_repo.version.should
|
55
|
-
loaded_repo.summary.should
|
53
|
+
loaded_repo.name.should == @repo.name
|
54
|
+
loaded_repo.version.should == @repo.version
|
55
|
+
loaded_repo.summary.should == @repo.summary
|
56
56
|
loaded_repo.description.should == @repo.description
|
57
|
+
loaded_repo.updated_at.should == @repo.updated_at
|
57
58
|
end
|
58
59
|
|
59
60
|
it "should be valid with all necessary attributes set" do
|
@@ -74,6 +75,9 @@ end
|
|
74
75
|
|
75
76
|
describe "JewelryPortfolio::Repo, when initialized without a gemspec" do
|
76
77
|
before do
|
78
|
+
@time = Time.now
|
79
|
+
Time.stubs(:now).returns(@time)
|
80
|
+
|
77
81
|
@repo = JewelryPortfolio::Repo.new
|
78
82
|
@repo.account = 'alloy'
|
79
83
|
@repo.name = 'dr-nic-magic-awesome'
|
@@ -87,6 +91,11 @@ describe "JewelryPortfolio::Repo, when initialized without a gemspec" do
|
|
87
91
|
it "should return that there's _no_ a gem for the repo" do
|
88
92
|
@repo.gem?.should.be false
|
89
93
|
end
|
94
|
+
|
95
|
+
it "should return a new updated_at Time instance if there was no updated_at yet" do
|
96
|
+
@repo.updated_at.should == @time
|
97
|
+
@repo.instance_variable_get("@updated_at").should == @time
|
98
|
+
end
|
90
99
|
end
|
91
100
|
|
92
101
|
describe "JewelryPortfolio::Repo, when initialized with a gemspec" do
|
@@ -97,6 +106,10 @@ describe "JewelryPortfolio::Repo, when initialized with a gemspec" do
|
|
97
106
|
|
98
107
|
include SharedRepoSpecs
|
99
108
|
|
109
|
+
it "should return the date from the gemspec" do
|
110
|
+
@repo.updated_at.should == Time.utc(@spec.date.year, @spec.date.month, @spec.date.day)
|
111
|
+
end
|
112
|
+
|
100
113
|
it "should return that there's a gem for the repo" do
|
101
114
|
@repo.gem?.should.be true
|
102
115
|
end
|
@@ -108,4 +121,16 @@ describe "JewelryPortfolio::Repo, when initialized with a gemspec" do
|
|
108
121
|
it "should return the gem install command" do
|
109
122
|
@repo.gem_install_command.should == "sudo gem install #{@repo.gem_name} -s http://gems.github.com"
|
110
123
|
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe "JewelryPortfolio::Repo, when initialized from YAML" do
|
127
|
+
before do
|
128
|
+
@repo = YAML.load(fixture_read('repos.yml')).first
|
129
|
+
end
|
130
|
+
|
131
|
+
include SharedRepoSpecs
|
132
|
+
|
133
|
+
it "should return the date as it was serialized in the yaml" do
|
134
|
+
YAML.load(@repo.to_yaml).updated_at.should == @repo.updated_at
|
135
|
+
end
|
111
136
|
end
|
data/test/repos_index_test.rb
CHANGED
@@ -44,11 +44,12 @@ describe "JewelryPortfolio::ReposIndex, in general, when the user specified a wo
|
|
44
44
|
@index.repos_file.should == File.join(@index.path, 'repos.yml')
|
45
45
|
end
|
46
46
|
|
47
|
-
it "should not
|
47
|
+
it "should not clean, fetch, and merge from the remote pages repo when opening the repo" do
|
48
48
|
@index.instance_variable_set("@pages_repo", nil)
|
49
49
|
|
50
50
|
Git.expects(:open).with(@index.path)
|
51
51
|
Git::Base.any_instance.expects(:pull).never
|
52
|
+
Git::Base.any_instance.expects(:checkout).never
|
52
53
|
@index.pages_repo
|
53
54
|
end
|
54
55
|
end
|
@@ -76,15 +77,20 @@ describe "JewelryPortfolio::ReposIndex, when working with a pages repo" do
|
|
76
77
|
File.should.exist File.join(TMP_PAGES_REPO, 'repos.yml')
|
77
78
|
end
|
78
79
|
|
79
|
-
it "should not create a new checkout if it already exists, but fetch and merge" do
|
80
|
-
@index.pages_repo
|
80
|
+
it "should not create a new checkout if it already exists, but clean, fetch and merge" do
|
81
|
+
@index.pages_repo
|
82
|
+
File.open(@index.repos_file, 'w') { |f| f << 'updated' }
|
83
|
+
|
84
|
+
# set @pages_repo to nil so the repo is re-opened the next we access it
|
81
85
|
@index.instance_variable_set("@pages_repo", nil)
|
82
86
|
|
83
87
|
Git.expects(:clone).never
|
84
|
-
Git::Base.any_instance.expects(:checkout).with('
|
88
|
+
#Git::Base.any_instance.expects(:checkout).with('.')
|
85
89
|
Git::Base.any_instance.expects(:fetch).with('origin')
|
86
90
|
Git::Base.any_instance.expects(:merge).with('origin/master')
|
87
91
|
@index.pages_repo
|
92
|
+
|
93
|
+
File.read(@index.repos_file).should.not == 'updated'
|
88
94
|
end
|
89
95
|
|
90
96
|
it "should create and checkout the `master' branch" do
|
@@ -106,10 +112,11 @@ describe "JewelryPortfolio::ReposIndex, when working with a pages repo" do
|
|
106
112
|
|
107
113
|
it "should return an empty set if the repos.yml file does not exist yet" do
|
108
114
|
FileUtils.rm(@index.repos_file)
|
115
|
+
Git::Base.any_instance.stubs(:checkout)
|
109
116
|
@index.repos.should == Set.new
|
110
117
|
end
|
111
118
|
|
112
|
-
it "should return a set of repos
|
119
|
+
it "should return a set of repos" do
|
113
120
|
FileUtils.rm_rf(TMP_PAGES_REPO)
|
114
121
|
|
115
122
|
@index.repos.should == [
|
@@ -145,8 +152,10 @@ describe "JewelryPortfolio::ReposIndex, when working with a pages repo" do
|
|
145
152
|
FileUtils.rm_rf(TMP_PAGES_REPO)
|
146
153
|
@index.repos # make sure its loaded
|
147
154
|
|
148
|
-
|
149
|
-
|
155
|
+
spec = eval(fixture_read('dr-nic-magic-awesome.gemspec_').
|
156
|
+
gsub('dr-nic-magic-awesome', 'dr-nic-magic-awesome-v2'))
|
157
|
+
|
158
|
+
repo = JewelryPortfolio::Repo.new('alloy', spec)
|
150
159
|
|
151
160
|
assert_difference('repos_from_file.length', +1) do
|
152
161
|
@index.add(repo)
|
@@ -159,7 +168,8 @@ describe "JewelryPortfolio::ReposIndex, when working with a pages repo" do
|
|
159
168
|
FileUtils.rm_rf(TMP_PAGES_REPO)
|
160
169
|
@index.repos # make sure its loaded
|
161
170
|
|
162
|
-
|
171
|
+
spec = eval(fixture_read('dr-nic-magic-awesome.gemspec_').gsub('1.0.0', '1.1.1'))
|
172
|
+
repo = JewelryPortfolio::Repo.new('alloy', spec)
|
163
173
|
|
164
174
|
assert_no_difference('repos_from_file.length') do
|
165
175
|
@index.add(repo)
|
@@ -170,8 +180,6 @@ describe "JewelryPortfolio::ReposIndex, when working with a pages repo" do
|
|
170
180
|
|
171
181
|
it "should re-raise Git::GitExecuteErrors with the repo path prepended" do
|
172
182
|
message = nil
|
173
|
-
@index.commit! 'clean'
|
174
|
-
|
175
183
|
begin
|
176
184
|
@index.commit! 'error'
|
177
185
|
rescue Git::GitExecuteError => e
|
data/test/template_test.rb
CHANGED
@@ -1,77 +1,210 @@
|
|
1
1
|
require File.expand_path('../test_helper', __FILE__)
|
2
2
|
|
3
|
-
|
3
|
+
module SharedTemplateSpecs
|
4
|
+
def self.included(klass)
|
5
|
+
klass.class_eval do
|
6
|
+
it "should turn the repos set into an array" do
|
7
|
+
@template.repos.should.be.instance_of Array
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should raise a JewelryPortfolio::FileMissingError if the specified template does not exist" do
|
11
|
+
e = nil
|
12
|
+
begin
|
13
|
+
JewelryPortfolio::Template.new('/not/existing', 'alloy', @repos)
|
14
|
+
rescue JewelryPortfolio::Template::FileMissingError => e
|
15
|
+
end
|
16
|
+
|
17
|
+
e.should.be.instance_of JewelryPortfolio::Template::FileMissingError
|
18
|
+
e.message.should == "Could not find template at path `/not/existing'"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return the path to the template file" do
|
22
|
+
@template.file.should == @file
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should return the view_path" do
|
26
|
+
@template.view_path.should == FIXTURE_PATH
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "JewelryPortfolio::Template::HTML" do
|
4
33
|
before do
|
5
34
|
@repos = %w{ dr-nic-magic-awesome.gemspec_ microgem.gemspec_ }.
|
6
35
|
map { |spec| JewelryPortfolio::Repo.new('alloy', fixture_eval(spec)) }
|
7
36
|
|
8
|
-
@
|
37
|
+
@file = fixture('index.erb')
|
38
|
+
@template = JewelryPortfolio::Template::HTML.new(@file, 'alloy', @repos.to_set)
|
9
39
|
end
|
10
40
|
|
11
|
-
|
12
|
-
|
41
|
+
include SharedTemplateSpecs
|
42
|
+
|
43
|
+
it "should render with the specified gem repos available as `repos'" do
|
44
|
+
File.stubs(:read).returns('<%= repos.inspect %>')
|
45
|
+
@template.render.should == @repos.sort_by { |r| r.name }.inspect
|
13
46
|
end
|
14
47
|
|
15
|
-
it "should
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
48
|
+
it "should render the ERB template" do
|
49
|
+
@template.render.should == File.read(fixture('index.html'))
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should return the repos ordered by name" do
|
53
|
+
@template.repos.should == @repos.sort_by { |r| r.name }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "JewelryPortfolio::Template::Feed, in general" do
|
58
|
+
before do
|
59
|
+
@repos = %w{ dr-nic-magic-awesome.gemspec_ microgem.gemspec_ }.
|
60
|
+
map { |spec| JewelryPortfolio::Repo.new('alloy', fixture_eval(spec)) }
|
21
61
|
|
22
|
-
|
23
|
-
|
62
|
+
@file = fixture('feed_with_defaults.rb')
|
63
|
+
@template = JewelryPortfolio::Template::Feed.new(@file, 'alloy', @repos.to_set)
|
64
|
+
end
|
65
|
+
|
66
|
+
include SharedTemplateSpecs
|
67
|
+
|
68
|
+
it "should return the feed id" do
|
69
|
+
@template.feed_id.should == 'http://alloy.github.com/'
|
24
70
|
end
|
25
71
|
|
26
|
-
it "should return the
|
27
|
-
@
|
72
|
+
it "should return the feed id with all lower case characters" do
|
73
|
+
@template.instance_variable_set("@account", 'Fingertips')
|
74
|
+
@template.feed_id.should == 'http://fingertips.github.com/'
|
28
75
|
end
|
29
76
|
|
30
|
-
it "should return the
|
31
|
-
@
|
77
|
+
it "should return the feed url" do
|
78
|
+
@template.feed_url.should == 'http://alloy.github.com/feed.xml'
|
32
79
|
end
|
33
80
|
|
34
|
-
it "should return the
|
35
|
-
@
|
81
|
+
it "should return the repos ordered by updated_at" do
|
82
|
+
repos = @template.repos
|
83
|
+
|
84
|
+
repos.last.stubs(:updated_at).returns(Time.now)
|
85
|
+
sleep 1.1
|
86
|
+
repos.first.stubs(:updated_at).returns(Time.now)
|
87
|
+
|
88
|
+
@template.repos.should == @repos.sort
|
36
89
|
end
|
37
90
|
|
38
|
-
it "should
|
39
|
-
|
40
|
-
|
91
|
+
it "should return the repos ordered by version if updated_at is the same" do
|
92
|
+
repos = @template.repos
|
93
|
+
time = Time.now
|
94
|
+
|
95
|
+
repos.each { |r| r.stubs(:updated_at).returns(time) }
|
96
|
+
|
97
|
+
repos.first.version = '0.11.45'
|
98
|
+
repos.last.version = '1.2.3'
|
99
|
+
|
100
|
+
@template.repos.should == @repos.sort
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "JewelryPortfolio::Template::Feed, with defaults" do
|
105
|
+
before do
|
106
|
+
@repos = %w{ dr-nic-magic-awesome.gemspec_ microgem.gemspec_ }.
|
107
|
+
map { |spec| JewelryPortfolio::Repo.new('alloy', fixture_eval(spec)) }
|
108
|
+
@repo = @repos.first
|
109
|
+
|
110
|
+
@file = fixture('feed_with_defaults.rb')
|
111
|
+
@template = JewelryPortfolio::Template::Feed.new(@file, 'alloy', @repos.to_set)
|
41
112
|
end
|
42
113
|
|
43
|
-
it "should
|
44
|
-
@
|
45
|
-
File.read(fixture('dr-nic-magic-awesome.html'))
|
114
|
+
it "should return the title" do
|
115
|
+
@template.title.should == 'Code from alloy'
|
46
116
|
end
|
47
117
|
|
48
|
-
it "should
|
49
|
-
@
|
50
|
-
File.read(fixture('dr-nic-magic-awesome.html'))
|
118
|
+
it "should return the description" do
|
119
|
+
@template.description.should == 'The Ruby libraries, from alloy, available as open-source projects'
|
51
120
|
end
|
52
121
|
|
53
|
-
it "should
|
54
|
-
|
55
|
-
@page.repo_partial(@repos.first, :extra_var => 'extra_var_value').should == "#{@repos.first.name} extra_var_value"
|
122
|
+
it "should return the `id' attribute for a repo" do
|
123
|
+
@template.id_for_repo(@repo).should == "#{@repo.url}##{@repo.version}"
|
56
124
|
end
|
57
125
|
|
58
|
-
it "should
|
59
|
-
|
60
|
-
|
61
|
-
|
126
|
+
it "should return the `updated' attribute for a repo" do
|
127
|
+
@template.updated_for_repo(@repo).should == @repo.updated_at.iso8601
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should return the `title' attribute for a repo" do
|
131
|
+
@template.title_for_repo(@repo).should == "#{@repo.name} #{@repo.version}"
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should return the `link' attribute for a repo" do
|
135
|
+
@template.link_for_repo(@repo).should == @repo.url
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should return the `summary' attribute for a repo" do
|
139
|
+
@template.summary_for_repo(@repo).should == @repo.summary
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should return the `description' attribute for a repo" do
|
143
|
+
@template.description_for_repo(@repo).should == @repo.description
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should render the template" do
|
147
|
+
time = Time.now
|
148
|
+
Time.stubs(:now).returns(time)
|
149
|
+
expected = File.read(fixture('feed_with_defaults.xml')).gsub('TIME_NOW', time.iso8601)
|
150
|
+
|
151
|
+
@template.render.should == expected
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
describe "JewelryPortfolio::Template::Feed, with overriden options from the template" do
|
156
|
+
before do
|
157
|
+
@repos = %w{ dr-nic-magic-awesome.gemspec_ microgem.gemspec_ }.
|
158
|
+
map { |spec| JewelryPortfolio::Repo.new('alloy', fixture_eval(spec)) }
|
159
|
+
@repo = @repos.first
|
62
160
|
|
63
|
-
@
|
161
|
+
@file = fixture('feed_with_options.rb')
|
162
|
+
@template = JewelryPortfolio::Template::Feed.new(@file, 'alloy', @repos.to_set)
|
64
163
|
end
|
65
164
|
|
66
|
-
|
67
|
-
|
165
|
+
include SharedTemplateSpecs
|
166
|
+
|
167
|
+
it "should return the title that was overriden" do
|
168
|
+
title = 'Code from Eloy Duran (alloy)'
|
169
|
+
@template.title = title
|
170
|
+
@template.title.should == title
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should return the description that was overriden" do
|
174
|
+
description = 'The Ruby libraries, from Eloy Duran, available as open-source projects'
|
175
|
+
@template.description = description
|
176
|
+
@template.description.should == description
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should return the `id' attribute for a repo" do
|
180
|
+
@template.id_for_repo(@repo).should == "#{@repo.name}-#{@repo.version}"
|
181
|
+
end
|
182
|
+
|
183
|
+
it "should return the `updated' attribute for a repo" do
|
184
|
+
@template.updated_for_repo(@repo).should == 'Right about NOW!'
|
68
185
|
end
|
69
186
|
|
70
|
-
|
187
|
+
it "should return the `title' attribute for a repo" do
|
188
|
+
@template.title_for_repo(@repo).should == "#{@repo.name.capitalize} (#{@repo.version})"
|
189
|
+
end
|
71
190
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
191
|
+
it "should return the `link' attribute for a repo" do
|
192
|
+
@template.link_for_repo(@repo).should == "http://google.com?q=#{@repo.name}"
|
193
|
+
end
|
194
|
+
|
195
|
+
it "should return the `summary' attribute for a repo" do
|
196
|
+
@template.summary_for_repo(@repo).should == "#{@repo.name.capitalize} is awesome!"
|
197
|
+
end
|
198
|
+
|
199
|
+
it "should return the `description' attribute for a repo" do
|
200
|
+
@template.description_for_repo(@repo).should == "#{@repo.name.capitalize} is awesome!"
|
201
|
+
end
|
202
|
+
|
203
|
+
it "should render the template" do
|
204
|
+
time = Time.now
|
205
|
+
Time.stubs(:now).returns(time)
|
206
|
+
expected = File.read(fixture('feed_with_options.xml')).gsub('TIME_NOW', time.iso8601)
|
207
|
+
|
208
|
+
@template.render.should == expected
|
76
209
|
end
|
77
210
|
end
|