nesta 0.9.13 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/{spec/spec.opts → .rspec} +0 -0
  3. data/.travis.yml +3 -2
  4. data/CHANGES +130 -1
  5. data/Gemfile +1 -8
  6. data/Gemfile.lock +68 -51
  7. data/LICENSE +1 -1
  8. data/README.md +38 -6
  9. data/Rakefile +2 -5
  10. data/bin/nesta +59 -3
  11. data/config.ru +3 -0
  12. data/lib/nesta.rb +1 -1
  13. data/lib/nesta/app.rb +20 -17
  14. data/lib/nesta/commands.rb +6 -3
  15. data/lib/nesta/config.rb +52 -15
  16. data/lib/nesta/helpers.rb +30 -3
  17. data/lib/nesta/models.rb +48 -30
  18. data/lib/nesta/navigation.rb +32 -12
  19. data/lib/nesta/overrides.rb +5 -5
  20. data/lib/nesta/version.rb +1 -1
  21. data/nesta.gemspec +9 -10
  22. data/smoke-test.sh +102 -0
  23. data/spec/atom_spec.rb +52 -49
  24. data/spec/commands_spec.rb +22 -16
  25. data/spec/config_spec.rb +66 -6
  26. data/spec/fixtures/nesta-plugin-test/lib/nesta-plugin-test/init.rb +1 -3
  27. data/spec/model_factory.rb +16 -16
  28. data/spec/models_spec.rb +197 -144
  29. data/spec/overrides_spec.rb +21 -21
  30. data/spec/page_spec.rb +182 -136
  31. data/spec/sitemap_spec.rb +48 -43
  32. data/spec/spec_helper.rb +32 -17
  33. data/templates/Gemfile +5 -2
  34. data/templates/config/config.yml +13 -13
  35. data/templates/config/deploy.rb +2 -2
  36. data/templates/index.haml +2 -0
  37. data/templates/themes/app.rb +1 -1
  38. data/templates/themes/views/layout.haml +7 -0
  39. data/templates/themes/views/master.sass +3 -0
  40. data/templates/themes/views/page.haml +1 -0
  41. data/views/atom.haml +3 -3
  42. data/views/comments.haml +1 -1
  43. data/views/error.haml +1 -1
  44. data/views/feed.haml +1 -1
  45. data/views/layout.haml +6 -3
  46. data/views/master.sass +143 -133
  47. data/views/mixins.sass +53 -28
  48. data/views/normalize.scss +396 -0
  49. data/views/page_meta.haml +2 -2
  50. data/views/sitemap.haml +2 -2
  51. data/views/summaries.haml +2 -2
  52. metadata +155 -202
  53. data/lib/nesta/cache.rb +0 -138
@@ -7,8 +7,8 @@ describe "Rendering" do
7
7
 
8
8
  def create_fixture(type, name, content)
9
9
  base_path = {
10
- :local => Nesta::Path.local,
11
- :theme => Nesta::Path.themes(@theme)
10
+ local: Nesta::Path.local,
11
+ theme: Nesta::Path.themes(@theme)
12
12
  }[type]
13
13
  path = File.join(base_path, name)
14
14
  @fixtures << path
@@ -20,7 +20,7 @@ describe "Rendering" do
20
20
  create_fixture(type, File.join('views', 'layout.haml'), '= yield')
21
21
  create_fixture(type, File.join('views', name), content)
22
22
  end
23
-
23
+
24
24
  def create_app_file(type)
25
25
  create_fixture(type, 'app.rb', "DEFINED_IN_#{type.to_s.upcase}_FILE = true")
26
26
  end
@@ -32,12 +32,12 @@ describe "Rendering" do
32
32
  @fixtures = []
33
33
  stub_configuration
34
34
  end
35
-
35
+
36
36
  after(:each) do
37
37
  @fixtures.each { |path| FileUtils.rm(path) if File.exist?(path) }
38
38
  Nesta::App.root = @app_root
39
39
  end
40
-
40
+
41
41
  describe "when rendering stylesheets" do
42
42
  it "should render Sass stylesheets" do
43
43
  create_template(:local, 'master.sass', "body\n width: 10px * 2")
@@ -61,57 +61,57 @@ describe "Rendering" do
61
61
  before(:each) do
62
62
  create_template(:local, 'page.haml', '%p Local template')
63
63
  end
64
-
64
+
65
65
  it "should use local application files" do
66
66
  create_app_file(:local)
67
67
  Nesta::Overrides.load_local_app
68
68
  Object.const_get(:DEFINED_IN_LOCAL_FILE).should be_true
69
69
  end
70
-
70
+
71
71
  it "should use local template in place of default" do
72
72
  get create_category.abspath
73
- body.should have_tag("p", "Local template")
73
+ body.should have_selector("p:contains('Local template')")
74
74
  end
75
75
  end
76
-
76
+
77
77
  describe "when theme installed" do
78
78
  before(:each) do
79
79
  create_template(:theme, 'page.haml', '%p Theme template')
80
80
  end
81
-
81
+
82
82
  it "should not require theme application file automatically" do
83
83
  create_app_file(:theme)
84
84
  lambda {
85
85
  Object.const_get(:DEFINED_IN_THEME_FILE)
86
86
  }.should raise_error(NameError)
87
87
  end
88
-
88
+
89
89
  it "should not use theme templates automatically" do
90
90
  get create_category.abspath
91
- body.should_not have_tag("p", "Theme template")
91
+ body.should_not have_selector("p:contains('Theme template')")
92
92
  end
93
-
93
+
94
94
  describe "and configured" do
95
95
  before(:each) do
96
96
  stub_config_key("theme", @theme)
97
97
  end
98
-
98
+
99
99
  it "should require theme application file" do
100
100
  create_app_file(:theme)
101
101
  Nesta::Overrides.load_theme_app
102
102
  Object.const_get(:DEFINED_IN_THEME_FILE).should be_true
103
103
  end
104
-
104
+
105
105
  it "should use theme's template in place of default" do
106
106
  get create_category.abspath
107
- body.should have_tag("p", "Theme template")
107
+ body.should have_selector("p:contains('Theme template')")
108
108
  end
109
-
109
+
110
110
  context "and local files exist" do
111
111
  before(:each) do
112
112
  create_template(:local, "page.haml", "%p Local template")
113
113
  end
114
-
114
+
115
115
  it "should require local and theme application files" do
116
116
  create_app_file(:local)
117
117
  create_app_file(:theme)
@@ -120,11 +120,11 @@ describe "Rendering" do
120
120
  Object.const_get(:DEFINED_IN_LOCAL_FILE).should be_true
121
121
  Object.const_get(:DEFINED_IN_THEME_FILE).should be_true
122
122
  end
123
-
123
+
124
124
  it "should use local template" do
125
125
  get create_category.abspath
126
- body.should_not have_tag("p", "Theme template")
127
- body.should have_tag("p", "Local template")
126
+ body.should_not have_selector("p:contains('Theme template')")
127
+ body.should have_selector("p:contains('Local template')")
128
128
  end
129
129
  end
130
130
  end
@@ -1,22 +1,23 @@
1
1
  require File.expand_path('spec_helper', File.dirname(__FILE__))
2
2
  require File.expand_path('model_factory', File.dirname(__FILE__))
3
3
 
4
- describe "page with keyword and description", :shared => true do
4
+ shared_examples_for "page with keyword and description" do
5
5
  it "should set the keywords meta tag" do
6
6
  do_get
7
- body.should have_tag("meta[@name=keywords][@content='#{@keywords}']")
7
+ assert_xpath "//meta[@name='keywords'][@content='#{@keywords}']"
8
8
  end
9
9
 
10
10
  it "should set description meta tag" do
11
11
  do_get
12
- body.should have_tag("meta[@name=description][@content='#{@description}']")
12
+ assert_xpath "//meta[@name='description'][@content='#{@description}']"
13
13
  end
14
14
  end
15
15
 
16
- describe "page that can display menus", :shared => true do
16
+ shared_examples_for "page that can display menus" do
17
17
  it "should not display menu by default" do
18
18
  do_get
19
- body.should_not have_tag("#sidebar ul.menu")
19
+ last_response.should be_ok
20
+ assert_not_selector "#sidebar ul.menu"
20
21
  end
21
22
 
22
23
  describe "and simple menu configured" do
@@ -26,15 +27,17 @@ describe "page that can display menus", :shared => true do
26
27
 
27
28
  it "should link to top level menu items" do
28
29
  do_get
29
- body.should have_tag(
30
- "ul.menu a[@href$=#{@category.abspath}]", Regexp.new(@category.heading))
30
+ link_text = @category.link_text
31
+ href = @category.abspath
32
+ assert_selector "ul.menu a[@href$='#{href}']:contains('#{link_text}')"
31
33
  end
32
34
  end
33
-
35
+
34
36
  describe "and nested menu configured" do
35
37
  before(:each) do
36
- @level2 = create_category(:path => "level-2", :heading => "Level 2")
37
- @level3 = create_category(:path => "level-3", :heading => "Level 3")
38
+ @level2 = create_category(path: "level-2", heading: "Level 2",
39
+ metadata: {'link text' => "Level 2 link"})
40
+ @level3 = create_category(path: "level-3", heading: "Level 3")
38
41
  text = <<-EOF
39
42
  #{@category.abspath}
40
43
  #{@level2.abspath}
@@ -45,12 +48,57 @@ describe "page that can display menus", :shared => true do
45
48
 
46
49
  it "should display first level of nested sub menus" do
47
50
  do_get
48
- body.should have_tag("ul.menu li ul li a", Regexp.new(@level2.heading))
51
+ assert_selector "ul.menu li ul li a:contains('#{@level2.link_text}')"
49
52
  end
50
53
 
51
54
  it "should not display nested menus to arbitrary depth" do
52
55
  do_get
53
- body.should_not have_tag("ul.menu li ul li ul")
56
+ last_response.should be_ok
57
+ assert_not_selector "ul.menu li ul li ul"
58
+ end
59
+ end
60
+
61
+ describe "and menu links to home page" do
62
+ before(:each) do
63
+ text = <<-EOF
64
+ /
65
+ #{@category.abspath}
66
+ EOF
67
+ create_menu(text)
68
+ template_path = File.expand_path(
69
+ 'templates', File.dirname(File.dirname(__FILE__)))
70
+ @default_homepage_content = File.read(File.join(template_path,
71
+ 'index.haml'))
72
+ end
73
+
74
+ it "should use 'Home' as the home page link if not otherwise specified" do
75
+ create_page(
76
+ path: 'index',
77
+ ext: :haml,
78
+ content: @default_homepage_content)
79
+ do_get
80
+ assert_selector "ul.menu a[@href='/']:contains('Home')"
81
+ end
82
+
83
+ it "should use the heading if it exists" do
84
+ create_page(
85
+ path: 'index',
86
+ ext: :haml,
87
+ heading: 'My heading',
88
+ content: @default_homepage_content)
89
+ do_get
90
+ assert_selector "ul.menu a[@href='/']:contains('My heading')"
91
+ end
92
+
93
+ it "should use the link text if specified" do
94
+ create_page(
95
+ path: 'index',
96
+ ext: :haml,
97
+ heading: 'My heading',
98
+ content: @default_homepage_content,
99
+ metadata: {'link text'=>'My link text'})
100
+ do_get
101
+ assert_selector "ul.menu a[@href='/']:contains('My link text')"
54
102
  end
55
103
  end
56
104
  end
@@ -58,38 +106,38 @@ end
58
106
  describe "The layout" do
59
107
  include ModelFactory
60
108
  include RequestSpecHelper
61
-
109
+
62
110
  it "should not include GA JavaScript by default" do
63
111
  stub_configuration
64
112
  get "/"
65
- body.should_not have_tag("script", /'_setAccount', 'UA-1234'/)
113
+ assert_not_selector "script", content: "'_setAccount', 'UA-1234'"
66
114
  end
67
-
115
+
68
116
  it "should include GA JavaScript if configured" do
69
- stub_config_key('google_analytics_code', 'UA-1234', :rack_env => true)
117
+ stub_config_key('google_analytics_code', 'UA-1234', rack_env: true)
70
118
  stub_configuration
71
- get '/'
72
- body.should have_tag('script', /'_setAccount', 'UA-1234'/)
119
+ get "/"
120
+ assert_selector 'script', content: "'_setAccount', 'UA-1234'"
73
121
  end
74
122
  end
75
123
 
76
124
  describe "The home page" do
77
125
  include ModelFactory
78
126
  include RequestSpecHelper
79
-
127
+
80
128
  before(:each) do
81
129
  stub_configuration
82
130
  template_path = File.expand_path(
83
131
  'templates', File.dirname(File.dirname(__FILE__)))
84
132
  create_category(
85
- :path => 'index',
86
- :ext => :haml,
87
- :heading => 'Home',
88
- :content => File.read(File.join(template_path, 'index.haml'))
133
+ path: 'index',
134
+ ext: :haml,
135
+ heading: 'Home',
136
+ content: File.read(File.join(template_path, 'index.haml'))
89
137
  )
90
138
  create_category
91
139
  end
92
-
140
+
93
141
  after(:each) do
94
142
  remove_temp_directory
95
143
  Nesta::FileModel.purge_cache
@@ -98,43 +146,43 @@ describe "The home page" do
98
146
  def do_get
99
147
  get "/"
100
148
  end
101
-
149
+
102
150
  describe "when categories exist" do
103
151
  before(:each) do
104
152
  @category = create_category
105
153
  end
106
-
154
+
107
155
  it_should_behave_like "page that can display menus"
108
156
  end
109
-
157
+
110
158
  it "should render successfully" do
111
159
  do_get
112
160
  last_response.should be_ok
113
161
  end
114
-
162
+
115
163
  it "should display site title in hgroup tag" do
116
- pending "Hpricot doesn't support HTML5"
117
- body.should have_tag('hgroup h1', /My blog/)
164
+ do_get
165
+ assert_selector 'hgroup h1', content: "My blog"
118
166
  end
119
-
167
+
120
168
  it "should display site subtitle in hgroup tag" do
121
- pending "Hpricot doesn't support HTML5"
122
169
  do_get
123
- body.should have_tag('hgroup h2', /about stuff/)
170
+ assert_selector 'hgroup h2', content: "about stuff"
124
171
  end
125
-
172
+
126
173
  describe "when articles have no summary" do
127
174
  before(:each) do
128
175
  create_article
129
176
  do_get
130
177
  end
131
-
178
+
132
179
  it "should display full content of article" do
133
- body.should have_tag("p", "Content goes here")
180
+ assert_selector "p", content: "Content goes here"
134
181
  end
135
-
182
+
136
183
  it "should not display read more link" do
137
- body.should_not have_tag("a", /continue/i)
184
+ last_response.should be_ok
185
+ assert_not_selector "a", content: 'continue'
138
186
  end
139
187
  end
140
188
 
@@ -142,24 +190,25 @@ describe "The home page" do
142
190
  before(:each) do
143
191
  @summary = 'Multiline\n\nsummary'
144
192
  @read_more = "Continue at your leisure"
145
- @article = create_article(:metadata => {
193
+ @article = create_article(metadata: {
146
194
  "summary" => @summary,
147
195
  "read more" => @read_more
148
196
  })
149
197
  do_get
150
198
  end
151
-
199
+
152
200
  it "should display link to article in h2 tag" do
153
- body.should have_tag(
154
- "h1 a[@href$=#{@article.abspath}]", /^\s*#{@article.heading}$/)
201
+ link_text = @article.link_text
202
+ href = @article.abspath
203
+ assert_selector "h1 a[@href$='#{href}']:contains('#{link_text}')"
155
204
  end
156
-
205
+
157
206
  it "should display article summary if available" do
158
- body.should have_tag('p', @summary.split('\n\n').first)
207
+ assert_selector 'p', content: @summary.split('\n\n').first
159
208
  end
160
-
209
+
161
210
  it "should display read more link" do
162
- body.should have_tag("a[@href$=#{@article.abspath}]", @read_more)
211
+ assert_selector "a[@href$='#{@article.abspath}']", content: @read_more
163
212
  end
164
213
  end
165
214
  end
@@ -167,26 +216,28 @@ end
167
216
  describe "An article" do
168
217
  include ModelFactory
169
218
  include RequestSpecHelper
170
-
219
+
171
220
  before(:each) do
172
221
  stub_configuration
173
222
  @date = '07 September 2009'
174
223
  @keywords = 'things, stuff'
175
224
  @description = 'Page about stuff'
176
225
  @summary = 'Multiline\n\nsummary'
177
- @article = create_article(:metadata => {
226
+ @link_text = 'Link to page about stuff'
227
+ @article = create_article(metadata: {
178
228
  'date' => @date.gsub('September', 'Sep'),
179
229
  'description' => @description,
180
230
  'keywords' => @keywords,
181
- 'summary' => @summary
231
+ 'summary' => @summary,
232
+ 'link text' => @link_text
182
233
  })
183
234
  end
184
-
235
+
185
236
  after(:each) do
186
237
  remove_temp_directory
187
238
  Nesta::FileModel.purge_cache
188
239
  end
189
-
240
+
190
241
  def do_get
191
242
  get @article.abspath
192
243
  end
@@ -197,7 +248,7 @@ describe "An article" do
197
248
  before(:each) do
198
249
  @category = create_category
199
250
  end
200
-
251
+
201
252
  it_should_behave_like "page that can display menus"
202
253
  end
203
254
 
@@ -208,59 +259,69 @@ describe "An article" do
208
259
 
209
260
  it "should display the heading" do
210
261
  do_get
211
- body.should have_tag('h1', 'My article')
262
+ assert_selector 'h1', content: 'My article'
212
263
  end
213
264
 
214
- it "should use heading for title tag" do
265
+ it "should use link text for title tag" do
215
266
  do_get
216
- body.should have_tag('title', 'My article - My blog')
267
+ assert_selector 'title', content: @link_text
217
268
  end
218
269
 
219
270
  it "should display the date" do
220
271
  do_get
221
- body.should have_tag('time', @date)
272
+ assert_selector 'time', content: @date
222
273
  end
223
274
 
224
275
  it "should display the content" do
225
276
  do_get
226
- body.should have_tag('p', 'Content goes here')
277
+ assert_selector 'p', content: 'Content goes here'
227
278
  end
228
-
279
+
229
280
  describe "that is assigned to categories" do
230
281
  before(:each) do
231
- create_category(:heading => 'Apple', :path => 'the-apple')
232
- @category = create_category(:heading => 'Banana', :path => 'banana')
282
+ create_category(heading: 'Apple', path: 'the-apple')
283
+ @category = create_category(heading: 'Banana', path: 'banana')
233
284
  @article = create_article(
234
- :path => "#{@category.path}/article",
235
- :metadata => { 'categories' => 'banana, the-apple' }
285
+ path: "#{@category.path}/article",
286
+ metadata: { 'categories' => 'banana, the-apple' }
236
287
  )
237
288
  end
238
-
289
+
239
290
  it "should render successfully" do
240
291
  do_get
241
292
  last_response.should be_ok
242
293
  end
243
-
294
+
244
295
  it "should link to each category" do
245
- pending "Hpricot doesn't support HTML5"
246
296
  do_get
247
- body.should have_tag("nav.categories") do |categories|
248
- categories.should have_tag("a[@href=/banana]", "Banana")
249
- categories.should have_tag("a[@href=/the-apple]", "Apple")
250
- end
297
+ assert_selector "p.meta a[href='/banana']", content: "Banana"
298
+ assert_selector "p.meta a[href='/the-apple']", content: "Apple"
251
299
  end
252
300
 
253
301
  it "should link to a category in breadcrumb" do
254
- pending "Hpricot doesn't support HTML5"
255
302
  do_get
256
- body.should have_tag(
257
- "nav.breadcrumb/a[@href=#{@category.abspath}]", @category.heading)
303
+ href = @category.abspath
304
+ link_text = @category.link_text
305
+ assert_selector "nav.breadcrumb a[href='#{href}']", content: link_text
306
+ end
307
+
308
+ it "should not include Disqus comments by default" do
309
+ do_get
310
+ last_response.should be_ok
311
+ assert_not_selector '#disqus_thread'
258
312
  end
259
-
260
- it "should contain category name in page title" do
313
+ end
314
+
315
+ describe "that is configured to show Disqus comments" do
316
+ before(:each) do
317
+ stub_config_key("disqus_short_name", "mysite")
318
+ @category = create_category
319
+ end
320
+
321
+ it "should display Disqus comments" do
261
322
  do_get
262
- body.should_not have_tag("title", /My blog/)
263
- body.should have_tag("title", /- #{@category.heading}$/)
323
+ assert_selector '#disqus_thread'
324
+ assert_selector 'script[@src*="mysite.disqus.com/embed.js"]'
264
325
  end
265
326
  end
266
327
  end
@@ -268,7 +329,7 @@ end
268
329
  describe "A page" do
269
330
  include ModelFactory
270
331
  include RequestSpecHelper
271
-
332
+
272
333
  before(:each) do
273
334
  stub_configuration
274
335
  end
@@ -277,7 +338,7 @@ describe "A page" do
277
338
  remove_temp_directory
278
339
  Nesta::FileModel.purge_cache
279
340
  end
280
-
341
+
281
342
  def do_get
282
343
  get @category.abspath
283
344
  end
@@ -285,7 +346,7 @@ describe "A page" do
285
346
  describe "that doesn't exist" do
286
347
  it "should render the 404 page" do
287
348
  get "/no-such-page"
288
- last_response.should_not be_ok
349
+ last_response.should be_not_found
289
350
  end
290
351
  end
291
352
 
@@ -297,8 +358,8 @@ describe "A page" do
297
358
  @keywords = "things, stuff"
298
359
  @articles_heading = "Posts about this stuff"
299
360
  @category = create_category(
300
- :content => "# My category\n\n#{@content}",
301
- :metadata => {
361
+ content: "# My category\n\n#{@content}",
362
+ metadata: {
302
363
  'title' => @title,
303
364
  'description' => @description,
304
365
  'keywords' => @keywords,
@@ -324,32 +385,32 @@ describe "A page" do
324
385
 
325
386
  it "should display the heading" do
326
387
  do_get
327
- body.should have_tag('h1', @category.heading)
388
+ assert_selector 'h1', content: @category.heading
328
389
  end
329
390
 
330
391
  it "should use title metadata to set heading" do
331
392
  do_get
332
- body.should have_tag('title', @title)
393
+ assert_selector 'title', content: @title
333
394
  end
334
395
 
335
396
  it "should display the content" do
336
397
  do_get
337
- body.should have_tag("p", @content)
398
+ assert_selector "p", content: @content
338
399
  end
339
400
 
340
401
  describe "with associated pages" do
341
402
  before(:each) do
342
403
  @category1 = create_category(
343
- :path => 'category1',
344
- :heading => 'Category 1',
345
- :metadata => {
404
+ path: 'category1',
405
+ heading: 'Category 1',
406
+ metadata: {
346
407
  'categories' => 'category-prefix/my-category:-1'
347
408
  }
348
409
  )
349
410
  @category2 = create_category(
350
- :path => 'category2',
351
- :heading => 'Category 2',
352
- :metadata => {
411
+ path: 'category2',
412
+ heading: 'Category 2',
413
+ metadata: {
353
414
  'categories' => 'category-prefix/my-category:1'
354
415
  }
355
416
  )
@@ -357,53 +418,37 @@ describe "A page" do
357
418
 
358
419
  it "should list highest priority pages at the top" do
359
420
  do_get
360
- body.should have_tag('li:nth-child(1) h1 a', 'Category 2')
361
- body.should have_tag('li:nth-child(2) h1 a', 'Category 1')
421
+ assert_selector 'li:nth-child(1) h1 a', content: 'Category 2'
422
+ assert_selector 'li:nth-child(2) h1 a', content: 'Category 1'
362
423
  end
363
424
  end
364
425
 
365
426
  describe "with associated articles" do
366
427
  before(:each) do
367
428
  @article = create_article(
368
- :path => "another-page",
369
- :heading => "Categorised",
370
- :metadata => { :categories => @category.path },
371
- :content => "Article content"
429
+ path: "another-page",
430
+ heading: "Categorised",
431
+ metadata: { categories: @category.path,
432
+ 'link text' => 'Categorised link'},
433
+ content: "Article content"
372
434
  )
373
435
  @article2 = create_article(
374
- :path => "second-article", :heading => "Second article")
436
+ path: "second-article", heading: "Second article")
375
437
  end
376
438
 
377
439
  it "should display links to articles" do
378
440
  do_get
379
- body.should have_tag(
380
- "h1 a[@href$='#{@article.abspath}']", /^\s*#{@article.heading}$/)
381
- body.should_not have_tag("h3", @article2.heading)
441
+ href = @article.abspath
442
+ link_text = @article.link_text
443
+ assert_selector "h1 a[@href$='#{href}']", content: link_text
444
+ assert_not_selector "h3", content: @article2.link_text
382
445
  end
383
446
 
384
447
  it "should display the article heading" do
385
448
  do_get
386
- body.should have_tag('h1', @articles_heading)
449
+ assert_selector 'h1', content: @articles_heading
387
450
  end
388
451
  end
389
-
390
- it "should not include Disqus comments by default" do
391
- do_get
392
- body.should_not have_tag('#disqus_thread')
393
- end
394
- end
395
-
396
- describe "that is configured to show Disqus comments" do
397
- before(:each) do
398
- stub_config_key("disqus_short_name", "mysite")
399
- @category = create_category
400
- end
401
-
402
- it "should display Disqus comments" do
403
- do_get
404
- body.should have_tag('#disqus_thread')
405
- body.should have_tag('script[@src*="mysite.disqus.com/embed.js"]')
406
- end
407
452
  end
408
453
  end
409
454
 
@@ -422,29 +467,30 @@ describe "A Haml page" do
422
467
 
423
468
  it "should be able to access helper methods" do
424
469
  create_page(
425
- :path => "a-page",
426
- :ext => :haml,
427
- :content => "%div= format_date(Date.new(2010, 11, 23))"
470
+ path: "a-page",
471
+ ext: :haml,
472
+ content: "%div= format_date(Date.new(2010, 11, 23))",
473
+ heading: "A Page"
428
474
  )
429
475
  get "/a-page"
430
- body.should have_tag("div", "23 November 2010")
476
+ assert_selector "div", content: "23 November 2010"
431
477
  end
432
478
 
433
479
  it "should access helpers when rendering articles on a category page" do
434
480
  category = create_page(
435
- :path => "a-page",
436
- :heading => "First heading",
437
- :content => "Blah blah"
481
+ path: "a-page",
482
+ heading: "First heading",
483
+ content: "Blah blah"
438
484
  )
439
485
  create_article(
440
- :path => "an-article",
441
- :ext => :haml,
442
- :heading => "First heading",
443
- :metadata => { :categories => category.path },
444
- :content => "%h1 Second heading\n\n%div= format_date(Date.new(2010, 11, 23))"
486
+ path: "an-article",
487
+ ext: :haml,
488
+ heading: "First heading",
489
+ metadata: { categories: category.path },
490
+ content: "%h1 Second heading\n\n%div= format_date(Date.new(2010, 11, 23))"
445
491
  )
446
492
  get "/a-page"
447
- body.should have_tag("div", "23 November 2010")
493
+ assert_selector "div", content: "23 November 2010"
448
494
  end
449
495
  end
450
496
 
@@ -461,23 +507,23 @@ describe "attachments" do
461
507
  remove_temp_directory
462
508
  Nesta::FileModel.purge_cache
463
509
  end
464
-
510
+
465
511
  describe "in the attachments folder" do
466
512
  before(:each) do
467
513
  path = File.join(Nesta::Config.attachment_path, 'test.txt')
468
514
  File.open(path, 'w') { |file| file.write("I'm a test attachment") }
469
515
  end
470
-
516
+
471
517
  it "should be served successfully" do
472
518
  get "/attachments/test.txt"
473
519
  last_response.should be_ok
474
520
  end
475
-
521
+
476
522
  it "should be sent to the client" do
477
523
  get "/attachments/test.txt"
478
524
  body.should include("I'm a test attachment")
479
525
  end
480
-
526
+
481
527
  it "should set the appropriate MIME type" do
482
528
  get "/attachments/test.txt"
483
529
  last_response.headers["Content-Type"].should =~ Regexp.new("^text/plain")