usmu 0.1.0-java → 0.2.0-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,49 @@
1
+ require 'usmu/plugin'
2
+ require 'ostruct'
3
+
4
+ RSpec.describe Usmu::Plugin do
5
+ before(:each) do
6
+ # noinspection RubyStringKeysInHashInspection
7
+ allow(Gem::Specification).to receive(:find_all).and_return([OpenStruct.new({'name' => 'usmu-mock_plugin'})])
8
+ end
9
+
10
+ let(:plugins) { Usmu::Plugin.new }
11
+
12
+ it 'should load the core plugin' do
13
+ plugins.load_plugins
14
+ expect(plugins.plugins.select {|p| p.class.name == 'Usmu::Plugin::Core'}.length).to eq(1)
15
+ end
16
+
17
+ it 'should load plugins from gems' do
18
+ plugins.load_plugins
19
+ expect(plugins.plugins.select {|p| p.class.name == 'Usmu::MockPlugin'}.length).to eq(1)
20
+ end
21
+
22
+ it 'should avoid loading plugins more than once' do
23
+ # noinspection RubyStringKeysInHashInspection
24
+ allow(Gem::Specification).to receive(:find_all).and_return([
25
+ OpenStruct.new({'name' => 'usmu-mock_plugin'}),
26
+ OpenStruct.new({'name' => 'usmu-mock_plugin'}),
27
+ ])
28
+ plugins.load_plugins
29
+ expect(plugins.plugins.select {|p| p.class.name == 'Usmu::MockPlugin'}.length).to eq(1)
30
+ end
31
+
32
+ it 'should call methods by name when using #invoke' do
33
+ plugins.load_plugins
34
+ plugins.plugins.select {|p| p.class.name == 'Usmu::MockPlugin' }.each do |p|
35
+ allow(p).to receive(:test).with('Hello world!')
36
+ end
37
+
38
+ plugins.invoke :test, 'Hello world!'
39
+ end
40
+
41
+ it 'should aggregate information from plugins when using #invoke' do
42
+ plugins.load_plugins
43
+ plugins.plugins.select {|p| p.class.name == 'Usmu::MockPlugin' }.each do |p|
44
+ allow(p).to receive(:test).and_return(['Goodbye world!'])
45
+ end
46
+
47
+ expect(plugins.invoke :test).to eq([['Goodbye world!']])
48
+ end
49
+ end
@@ -1,4 +1,3 @@
1
- require 'rspec'
2
1
  require 'usmu/site_generator'
3
2
 
4
3
  RSpec.describe Usmu::SiteGenerator do
@@ -27,6 +26,5 @@ RSpec.describe Usmu::SiteGenerator do
27
26
 
28
27
  it 'should be able to generate a site' do
29
28
  expect(generator.respond_to? :generate).to eq(true)
30
- # Further testing is exercised at the system integration level in the cukes.
31
29
  end
32
30
  end
@@ -1,3 +1,8 @@
1
+ require 'simplecov'
2
+ SimpleCov.command_name 'RSpec'
3
+
4
+ require 'logging'
5
+
1
6
  # This file was generated by the `rspec --init` command. Conventionally, all
2
7
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
8
  # The generated `.rspec` file contains `--require spec_helper` which will cause this
@@ -54,7 +59,7 @@ RSpec.configure do |config|
54
59
 
55
60
  # This setting enables warnings. It's recommended, but in some cases may
56
61
  # be too noisy due to issues in dependencies.
57
- config.warnings = true
62
+ config.warnings = false
58
63
 
59
64
  # Many RSpec users commonly either run the entire suite or an individual
60
65
  # file, and it's useful to allow more verbose output when running an
@@ -83,3 +88,9 @@ RSpec.configure do |config|
83
88
  # as the one that triggered the failure.
84
89
  Kernel.srand config.seed
85
90
  end
91
+
92
+ # Load turnip step definitions
93
+ Dir['test/spec/**/*_steps.rb'].each {|f| require f[10..f.length] }
94
+
95
+ # Allow loading of mocks
96
+ $LOAD_PATH.unshift(File.realpath('./test/spec/mock'))
@@ -1,4 +1,3 @@
1
- require 'rspec'
2
1
  require 'support/shared_layout'
3
2
  require 'usmu/static_file'
4
3
 
@@ -13,6 +12,13 @@ RSpec.describe Usmu::StaticFile do
13
12
  expect(rendered).to eq(File.read('test/expected-site/robots.txt'))
14
13
  end
15
14
 
15
+ it 'has an input path' do
16
+ configuration = Usmu::Configuration.from_hash({})
17
+ page = Usmu::StaticFile.new(configuration, 'robots.txt', 'txt', '', {})
18
+ expect(page.respond_to? :input_path).to eq(true)
19
+ expect(page.input_path).to eq('src/robots.txt')
20
+ end
21
+
16
22
  it 'has an output filename that matches input' do
17
23
  file = Usmu::StaticFile.new(configuration, 'robots.txt')
18
24
  expect(file.output_filename).to eq('robots.txt')
@@ -20,7 +20,7 @@ RSpec.shared_examples 'a layout' do
20
20
  include_examples 'a renderable file'
21
21
 
22
22
  let(:title_configuration) { Usmu::Configuration.from_hash({'default meta' => {'title' => 'title'}}) }
23
- let(:meta_with_title) { {'title' => 'title'} }
23
+ let(:meta_with_title) { {'title' => 'meta title'} }
24
24
  let(:content) { "title \#{title}\nbody\n #container\n | \#{{content}}" }
25
25
 
26
26
  it 'and has a type' do
@@ -35,6 +35,72 @@ RSpec.shared_examples 'a layout' do
35
35
  <title>title</title><body><div id="container">test</div></body>
36
36
  EOF
37
37
  end
38
+
39
+ context 'and when it\'s type' do
40
+ it 'is invalid' do
41
+ expect {described_class.new(empty_configuration, 'body.foo', nil, '', {})}.to raise_error()
42
+ end
43
+
44
+ it 'is erb then it\'s output type should be taken from it\'s filename' do
45
+ layout = described_class.new(empty_configuration, 'body.txt.erb', 'erb', '', {})
46
+ expect(layout.output_filename).to eq('body.txt')
47
+ end
48
+
49
+ it 'is rhtml then it\'s output type should be taken from it\'s filename' do
50
+ layout = described_class.new(empty_configuration, 'body.txt.rhtml', 'rhtml', '', {})
51
+ expect(layout.output_filename).to eq('body.txt')
52
+ end
53
+
54
+ it 'is erubis then it\'s output type should be taken from it\'s filename' do
55
+ layout = described_class.new(empty_configuration, 'body.txt.erubis', 'erubis', '', {})
56
+ expect(layout.output_filename).to eq('body.txt')
57
+ end
58
+
59
+ it 'is markdown then it\'s output type should be html' do
60
+ layout = described_class.new(empty_configuration, 'body.markdown', 'markdown', '', {})
61
+ expect(layout.output_filename).to eq('body.html')
62
+ end
63
+
64
+ it 'is mkd then it\'s output type should be html' do
65
+ layout = described_class.new(empty_configuration, 'body.mkd', 'mkd', '', {})
66
+ expect(layout.output_filename).to eq('body.html')
67
+ end
68
+
69
+ it 'is md then it\'s output type should be html' do
70
+ layout = described_class.new(empty_configuration, 'body.md', 'md', '', {})
71
+ expect(layout.output_filename).to eq('body.html')
72
+ end
73
+
74
+ it 'is coffee then it\'s output type should be js' do
75
+ layout = described_class.new(empty_configuration, 'body.coffee', 'coffee', '', {})
76
+ expect(layout.output_filename).to eq('body.js')
77
+ end
78
+
79
+ it 'is less then it\'s output type should be css' do
80
+ layout = described_class.new(empty_configuration, 'body.less', 'less', '', {})
81
+ expect(layout.output_filename).to eq('body.css')
82
+ end
83
+
84
+ it 'is liquid then it\'s output type should be taken from it\'s filename' do
85
+ layout = described_class.new(empty_configuration, 'body.txt.liquid', 'liquid', '', {})
86
+ expect(layout.output_filename).to eq('body.txt')
87
+ end
88
+
89
+ it 'is sass then it\'s output type should be scss' do
90
+ layout = described_class.new(empty_configuration, 'body.sass', 'sass', '', {})
91
+ expect(layout.output_filename).to eq('body.css')
92
+ end
93
+
94
+ it 'is scss then it\'s output type should be css' do
95
+ layout = described_class.new(empty_configuration, 'body.scss', 'scss', '', {})
96
+ expect(layout.output_filename).to eq('body.css')
97
+ end
98
+
99
+ it 'is slim then it\'s output type should be html' do
100
+ layout = described_class.new(empty_configuration, 'body.slim', 'slim', '', {})
101
+ expect(layout.output_filename).to eq('body.html')
102
+ end
103
+ end
38
104
  end
39
105
 
40
106
  RSpec.shared_examples 'a layout with metadata' do
@@ -61,10 +127,10 @@ RSpec.shared_examples 'a layout with metadata' do
61
127
  EOF
62
128
  end
63
129
 
64
- it 'variables over default metadata' do
65
- layout = described_class.new(empty_configuration, 'body.slim', 'slim', content, {})
66
- expect(layout.render({'content' => 'test', 'title' => 'overridden title'})).to eq(<<-EOF)
67
- <title>overridden title</title><body><div id="container">test</div></body>
130
+ it 'metadata over default metadata' do
131
+ layout = described_class.new(title_configuration, 'body.slim', 'slim', content, meta_with_title)
132
+ expect(layout.render({'content' => 'test'})).to eq(<<-EOF)
133
+ <title>meta title</title><body><div id="container">test</div></body>
68
134
  EOF
69
135
  end
70
136
  end
@@ -89,6 +155,24 @@ RSpec.shared_examples 'an embeddable layout' do
89
155
  EOF
90
156
  end
91
157
 
158
+ it 'and respects templates from default metadata' do
159
+ parent = described_class.new(empty_configuration, 'html.slim', 'slim', wrapper, {})
160
+ default_layout_configuration = Usmu::Configuration.from_hash({'default meta' => {'layout' => parent}})
161
+ layout = described_class.new(default_layout_configuration, 'body.slim', 'slim', content, {'title' => 'test title'})
162
+ expect(layout.render({'content' => 'test'})).to eq(<<-EOF)
163
+ <html><title>test title</title><body><div id="container">test</div></body>
164
+ </html>
165
+ EOF
166
+ end
167
+
168
+ it 'and uses a template of "none" to explicitly disable the parent template' do
169
+ default_layout_configuration = Usmu::Configuration.from_hash({'default meta' => {'layout' => 'html'}})
170
+ layout = described_class.new(default_layout_configuration, 'body.slim', 'slim', content, {'layout' => 'none', 'title' => 'test title'})
171
+ expect(layout.render({'content' => 'test'})).to eq(<<-EOF)
172
+ <title>test title</title><body><div id="container">test</div></body>
173
+ EOF
174
+ end
175
+
92
176
  context 'and prioritises' do
93
177
  it 'metadata over parent metadata' do
94
178
  parent = described_class.new(empty_configuration, 'html.slim', 'slim', wrapper, {'title' => 'title'})
@@ -0,0 +1,20 @@
1
+ require 'usmu/ui/console'
2
+
3
+ Usmu.disable_stdout_logging
4
+
5
+ RSpec.describe Usmu::Ui::Console do
6
+ it 'supports --quiet' do
7
+ expect(Usmu).to receive(:quiet_logging)
8
+ Usmu::Ui::Console.new(%w{--quiet --config test/site/usmu.yml})
9
+ end
10
+
11
+ it 'supports --log' do
12
+ expect(Usmu).to receive(:add_file_logger).with('test.log')
13
+ Usmu::Ui::Console.new(%w{--log test.log --config test/site/usmu.yml})
14
+ end
15
+
16
+ it 'supports --verbose' do
17
+ expect(Usmu).to receive(:verbose_logging)
18
+ Usmu::Ui::Console.new(%w{--verbose --config test/site/usmu.yml})
19
+ end
20
+ end
data/usmu-jruby.gemspec CHANGED
@@ -22,13 +22,16 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency 'tilt', '~> 2.0'
23
23
  spec.add_dependency 'kramdown', '~> 1.5'
24
24
  spec.add_dependency 'deep_merge', '~> 1.0'
25
- spec.add_dependency 'trollop', '~> 2.0'
26
- spec.add_dependency 'highline', '~> 1.6'
25
+ spec.add_dependency 'commander', '~> 4.2'
26
+ spec.add_dependency 'logging', '~> 1.8'
27
27
 
28
28
  spec.add_development_dependency 'bundler', '~> 1.6'
29
29
  spec.add_development_dependency 'rake', '~> 10.0'
30
30
  spec.add_development_dependency 'rspec', '~> 3.1'
31
- spec.add_development_dependency 'cucumber', '~> 1.3'
32
31
  spec.add_development_dependency 'yard', '~> 0.8'
33
32
  spec.add_development_dependency 'cane', '~> 2.6'
33
+ spec.add_development_dependency 'simplecov', '~> 0.9'
34
+ spec.add_development_dependency 'guard', '~> 2.8'
35
+ spec.add_development_dependency 'guard-rspec', '~> 4.3'
36
+ spec.add_development_dependency 'turnip', '~> 1.2'
34
37
  end
data/usmu.gemspec CHANGED
@@ -19,17 +19,18 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.add_dependency 'slim', '~> 2.1'
21
21
  spec.add_dependency 'tilt', '~> 2.0'
22
- # For now yard requires redcarpet < 3.2
23
- # See: https://github.com/lsegal/yard/issues/812
24
- spec.add_dependency 'redcarpet', '~> 3.1', '< 3.2'
22
+ spec.add_dependency 'redcarpet', '~> 3.2', '>= 3.2.1'
25
23
  spec.add_dependency 'deep_merge', '~> 1.0'
26
- spec.add_dependency 'trollop', '~> 2.0'
27
- spec.add_dependency 'highline', '~> 1.6'
24
+ spec.add_dependency 'commander', '~> 4.2'
25
+ spec.add_dependency 'logging', '~> 1.8'
28
26
 
29
27
  spec.add_development_dependency 'bundler', '~> 1.6'
30
28
  spec.add_development_dependency 'rake', '~> 10.0'
31
29
  spec.add_development_dependency 'rspec', '~> 3.1'
32
- spec.add_development_dependency 'cucumber', '~> 1.3'
33
30
  spec.add_development_dependency 'yard', '~> 0.8'
34
31
  spec.add_development_dependency 'cane', '~> 2.6'
32
+ spec.add_development_dependency 'simplecov', '~> 0.9'
33
+ spec.add_development_dependency 'guard', '~> 2.8'
34
+ spec.add_development_dependency 'guard-rspec', '~> 4.3'
35
+ spec.add_development_dependency 'turnip', '~> 1.2'
35
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usmu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: java
6
6
  authors:
7
7
  - Matthew Scharley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-11 00:00:00.000000000 Z
11
+ date: 2014-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slim
@@ -67,33 +67,33 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: trollop
70
+ name: commander
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '2.0'
75
+ version: '4.2'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '2.0'
82
+ version: '4.2'
83
83
  - !ruby/object:Gem::Dependency
84
- name: highline
84
+ name: logging
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.6'
89
+ version: '1.8'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.6'
96
+ version: '1.8'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: bundler
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -137,47 +137,89 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: '3.1'
139
139
  - !ruby/object:Gem::Dependency
140
- name: cucumber
140
+ name: yard
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '1.3'
145
+ version: '0.8'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '1.3'
152
+ version: '0.8'
153
153
  - !ruby/object:Gem::Dependency
154
- name: yard
154
+ name: cane
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '0.8'
159
+ version: '2.6'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: '0.8'
166
+ version: '2.6'
167
167
  - !ruby/object:Gem::Dependency
168
- name: cane
168
+ name: simplecov
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: '2.6'
173
+ version: '0.9'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: '2.6'
180
+ version: '0.9'
181
+ - !ruby/object:Gem::Dependency
182
+ name: guard
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '2.8'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '2.8'
195
+ - !ruby/object:Gem::Dependency
196
+ name: guard-rspec
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '4.3'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '4.3'
209
+ - !ruby/object:Gem::Dependency
210
+ name: turnip
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '1.2'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '1.2'
181
223
  description:
182
224
  email:
183
225
  - matt.scharley@gmail.com
@@ -189,10 +231,13 @@ files:
189
231
  - ".cane"
190
232
  - ".gitignore"
191
233
  - ".rspec"
234
+ - ".simplecov"
192
235
  - ".travis.yml"
193
236
  - ".yardopts"
237
+ - CONTRIBUTING.md
194
238
  - Gemfile
195
239
  - Gemfile-jruby
240
+ - Guardfile
196
241
  - LICENSE.md
197
242
  - README.md
198
243
  - Rakefile
@@ -202,6 +247,8 @@ files:
202
247
  - lib/usmu/configuration.rb
203
248
  - lib/usmu/layout.rb
204
249
  - lib/usmu/page.rb
250
+ - lib/usmu/plugin.rb
251
+ - lib/usmu/plugin/core.rb
205
252
  - lib/usmu/site_generator.rb
206
253
  - lib/usmu/static_file.rb
207
254
  - lib/usmu/ui.rb
@@ -211,8 +258,6 @@ files:
211
258
  - test/expected-site/embedded.html
212
259
  - test/expected-site/index.html
213
260
  - test/expected-site/robots.txt
214
- - test/features/generator.feature
215
- - test/features/step_definitions/step_general.rb
216
261
  - test/site/content/default.md
217
262
  - test/site/content/embedded.md
218
263
  - test/site/content/embedded.meta.yml
@@ -224,13 +269,19 @@ files:
224
269
  - test/site/layouts/html.meta.yml
225
270
  - test/site/layouts/html.slim
226
271
  - test/site/usmu.yml
272
+ - test/spec/acceptance/full_site_build.feature
273
+ - test/spec/acceptance/steps/full_site_build_steps.rb
227
274
  - test/spec/configuration_spec.rb
228
275
  - test/spec/layout_spec.rb
276
+ - test/spec/mock/usmu/mock_plugin.rb
229
277
  - test/spec/page_spec.rb
278
+ - test/spec/plugin/core_spec.rb
279
+ - test/spec/plugin_spec.rb
230
280
  - test/spec/site_generator_spec.rb
231
281
  - test/spec/spec_helper.rb
232
282
  - test/spec/static_file_spec.rb
233
283
  - test/spec/support/shared_layout.rb
284
+ - test/spec/ui/console_spec.rb
234
285
  - usmu-jruby.gemspec
235
286
  - usmu.gemspec
236
287
  homepage: https://github.com/usmu/usmu
@@ -262,8 +313,6 @@ test_files:
262
313
  - test/expected-site/embedded.html
263
314
  - test/expected-site/index.html
264
315
  - test/expected-site/robots.txt
265
- - test/features/generator.feature
266
- - test/features/step_definitions/step_general.rb
267
316
  - test/site/content/default.md
268
317
  - test/site/content/embedded.md
269
318
  - test/site/content/embedded.meta.yml
@@ -275,11 +324,17 @@ test_files:
275
324
  - test/site/layouts/html.meta.yml
276
325
  - test/site/layouts/html.slim
277
326
  - test/site/usmu.yml
327
+ - test/spec/acceptance/full_site_build.feature
328
+ - test/spec/acceptance/steps/full_site_build_steps.rb
278
329
  - test/spec/configuration_spec.rb
279
330
  - test/spec/layout_spec.rb
331
+ - test/spec/mock/usmu/mock_plugin.rb
280
332
  - test/spec/page_spec.rb
333
+ - test/spec/plugin/core_spec.rb
334
+ - test/spec/plugin_spec.rb
281
335
  - test/spec/site_generator_spec.rb
282
336
  - test/spec/spec_helper.rb
283
337
  - test/spec/static_file_spec.rb
284
338
  - test/spec/support/shared_layout.rb
339
+ - test/spec/ui/console_spec.rb
285
340
  has_rdoc: