audrey2 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,110 @@
1
+ require 'helper'
2
+
3
+ class TestThemes < Test::Unit::TestCase
4
+ context "With an initialized Aggregator and a valid recipe" do
5
+ setup do
6
+ @config
7
+ File.stubs(:exist?).with('configfile').returns(true)
8
+ File.stubs(:readable?).with('configfile').returns(true)
9
+ YAML.stubs(:load_file).with('configfile').returns({
10
+ 'recipes_folder' => 'recipes_folder',
11
+ 'themes_folder' => 'themes_folder',
12
+ 'user_agent' => 'user_agent',
13
+ 'sort' => 'sort'
14
+ })
15
+ File.stubs(:exist?).with('recipes_folder').returns(true)
16
+ File.stubs(:readable?).with('recipes_folder').returns(true)
17
+ File.stubs(:exist?).with('themes_folder').returns(true)
18
+ File.stubs(:readable?).with('themes_folder').returns(true)
19
+ @aggregator = Audrey2::Aggregator.new('configfile')
20
+ recipefile = File.join('recipes_folder', 'recipe')
21
+ outputfile = File.join('output_folder', 'output_file')
22
+ File.stubs(:exist?).with(recipefile).returns(true)
23
+ File.stubs(:readable?).with(recipefile).returns(true)
24
+ YAML.stubs(:load_file).with(recipefile).returns({
25
+ 'feeds' => [{ 'name' => 'feed', 'url' => 'http://test.com/feed.xml' }],
26
+ 'theme' => 'theme',
27
+ 'output_file' => outputfile
28
+ })
29
+ File.stubs(:exist?).with('output_folder').returns(true)
30
+ File.stubs(:writable?).with('output_folder').returns(true)
31
+ File.stubs(:exist?).with(outputfile).returns(false)
32
+ end
33
+
34
+ context "and a nonexistent theme folder" do
35
+ should 'report error and exit' do
36
+ theme_path = File.join('themes_folder', 'theme')
37
+ File.expects(:exist?).with(theme_path).returns(false)
38
+ err = capture_stderr { assert_raise(SystemExit) { @aggregator.feed_me('recipe') } }
39
+ assert_match /ERROR: Theme #{theme_path} does not exist/, err.string
40
+ end
41
+ end
42
+
43
+ context "and an unreadable theme folder" do
44
+ should 'report error and exit' do
45
+ theme_path = File.join('themes_folder', 'theme')
46
+ File.stubs(:exist?).with(theme_path).returns(true)
47
+ File.expects(:readable?).with(theme_path).returns(false)
48
+ err = capture_stderr { assert_raise(SystemExit) { @aggregator.feed_me('recipe') } }
49
+ assert_match /ERROR: Theme #{theme_path} is not readable/, err.string
50
+ end
51
+ end
52
+
53
+ context "and a valid theme folder" do
54
+ setup do
55
+ @theme_path = File.join('themes_folder', 'theme')
56
+ File.stubs(:exist?).with(@theme_path).returns(true)
57
+ File.stubs(:readable?).with(@theme_path).returns(true)
58
+ @entry_template_path = File.join(@theme_path, 'entry.haml')
59
+ end
60
+
61
+ context "and a nonexistent entry template file" do
62
+ should 'report error and exit' do
63
+ File.expects(:exist?).with(@entry_template_path).returns(false)
64
+ err = capture_stderr { assert_raise(SystemExit) { @aggregator.feed_me('recipe') } }
65
+ assert_match /ERROR: Theme theme does not include an entry template \(entry\.haml\)/, err.string
66
+ end
67
+ end
68
+
69
+ context "and an unreadable entry template file" do
70
+ should 'report error and exit' do
71
+ File.stubs(:exist?).with(@entry_template_path).returns(true)
72
+ File.expects(:readable?).with(@entry_template_path).returns(false)
73
+ err = capture_stderr { assert_raise(SystemExit) { @aggregator.feed_me('recipe') } }
74
+ assert_match /ERROR: Entry template #{@entry_template_path} is not readable/, err.string
75
+ end
76
+ end
77
+
78
+ context "and an entry template file" do
79
+ setup do
80
+ File.stubs(:exist?).with(@entry_template_path).returns(true)
81
+ File.stubs(:readable?).with(@entry_template_path).returns(true)
82
+ @helpers_file_path = File.join(@theme_path, 'helpers.rb')
83
+ end
84
+
85
+ # Note: A stab at the following is being taken in test_parse.rb, but I'm really
86
+ # not sure it belongs there. The challenge is to test things like this which
87
+ # happen when everything is proceeding as it should, but without needing to test
88
+ # events which occur later (like the actual parsing, aggregation, and output).
89
+ # should "load the entry template" do
90
+ # File.expects(:read).with(@entry_template_path).returns('Template code')
91
+ # assert_equal 'Template code', @aggregator.instance_variable_get('@entry_template')
92
+ # end
93
+
94
+ context "and an unreadable helpers file" do
95
+ setup do
96
+ File.stubs(:read).with(@entry_template_path).returns('Template code')
97
+ end
98
+
99
+ should 'report error and exit' do
100
+ File.expects(:exist?).with(@helpers_file_path).returns(true)
101
+ File.expects(:readable?).with(@helpers_file_path).returns(false)
102
+ err = capture_stderr { assert_raise(SystemExit) { @aggregator.feed_me('recipe') } }
103
+ assert_match /ERROR: Helpers file #{@helpers_file_path} is not readable/, err.string
104
+ end
105
+ end
106
+ end
107
+
108
+ end
109
+ end
110
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: audrey2
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 1
10
- version: 0.2.1
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sven Aas
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-30 00:00:00 -04:00
18
+ date: 2010-08-17 00:00:00 -04:00
19
19
  default_executable: feedme
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -50,7 +50,39 @@ dependencies:
50
50
  version: 3.0.13
51
51
  type: :runtime
52
52
  version_requirements: *id002
53
- description: Gem for feed processing and aggregation
53
+ - !ruby/object:Gem::Dependency
54
+ name: shoulda
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 33
62
+ segments:
63
+ - 2
64
+ - 11
65
+ - 1
66
+ version: 2.11.1
67
+ type: :development
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: mocha
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 43
78
+ segments:
79
+ - 0
80
+ - 9
81
+ - 8
82
+ version: 0.9.8
83
+ type: :development
84
+ version_requirements: *id004
85
+ description: Audrey 2.0 is a command-line utility for customizable feed processing, aggregation, and output.
54
86
  email: sven.aas@gmail.com
55
87
  executables:
56
88
  - feedme
@@ -70,6 +102,15 @@ files:
70
102
  - audrey2.gemspec
71
103
  - bin/feedme
72
104
  - lib/audrey2.rb
105
+ - test/helper.rb
106
+ - test/test_config.rb
107
+ - test/test_email.rb
108
+ - test/test_misc.rb
109
+ - test/test_options.rb
110
+ - test/test_parse.rb
111
+ - test/test_recipes.rb
112
+ - test/test_sort.rb
113
+ - test/test_themes.rb
73
114
  has_rdoc: true
74
115
  homepage: http://github.com/svenaas/audrey2
75
116
  licenses: []
@@ -103,6 +144,14 @@ rubyforge_project:
103
144
  rubygems_version: 1.3.7
104
145
  signing_key:
105
146
  specification_version: 3
106
- summary: Gem for feed processing and aggregation
107
- test_files: []
108
-
147
+ summary: Feed processing and aggregation
148
+ test_files:
149
+ - test/helper.rb
150
+ - test/test_config.rb
151
+ - test/test_email.rb
152
+ - test/test_misc.rb
153
+ - test/test_options.rb
154
+ - test/test_parse.rb
155
+ - test/test_recipes.rb
156
+ - test/test_sort.rb
157
+ - test/test_themes.rb