usmu 0.3.2-java → 0.3.3-java

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.
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Usmu
3
3
  # The current version string for the gem
4
- VERSION = '0.3.2'
4
+ VERSION = '0.3.3'
5
5
  end
@@ -133,6 +133,30 @@ RSpec.describe Usmu::Configuration do
133
133
  end
134
134
  end
135
135
 
136
+ context '#source_metadata' do
137
+ it 'should return a new metadata service for the source folder' do
138
+ ms = {fake: 'success'}
139
+ expect(Usmu::MetadataService).to receive(:new).with(empty_configuration.source_path).and_return(ms)
140
+ expect(empty_configuration.source_metadata).to eq(ms)
141
+ end
142
+ end
143
+
144
+ context '#layouts_metadata' do
145
+ it 'should return a new metadata service for the layouts folder' do
146
+ ms = {fake: 'success'}
147
+ expect(Usmu::MetadataService).to receive(:new).with(empty_configuration.layouts_path).and_return(ms)
148
+ expect(empty_configuration.layouts_metadata).to eq(ms)
149
+ end
150
+ end
151
+
152
+ context '#includes_metadata' do
153
+ it 'should return a new metadata service for the layouts folder' do
154
+ ms = {fake: 'success'}
155
+ expect(Usmu::MetadataService).to receive(:new).with(empty_configuration.includes_path).and_return(ms)
156
+ expect(empty_configuration.includes_metadata).to eq(ms)
157
+ end
158
+ end
159
+
136
160
  context '#exclude' do
137
161
  it 'returns the exclude option in the configuration array' do
138
162
  expect(Usmu::Configuration.from_hash({'exclude' => ['test.md']}).exclude).to eq(['test.md'])
@@ -4,123 +4,109 @@ require 'ostruct'
4
4
  require 'digest'
5
5
 
6
6
  RSpec.describe Usmu::Deployment::DirectoryDiff do
7
+ let (:configuration) { Usmu::Configuration.from_hash({}) }
8
+
9
+ context '#initialize' do
10
+ it 'initializes variables' do
11
+ remote_files = OpenStruct.new {}
12
+ diff = Usmu::Deployment::DirectoryDiff.new(configuration, remote_files)
13
+
14
+ expect(diff.send :configuration).to eq(configuration)
15
+ expect(diff.send :remote_files).to eq(remote_files)
16
+ end
17
+ end
18
+
7
19
  context '#get_diffs' do
8
- let (:configuration) { Usmu::Configuration.from_hash({}) }
20
+ it 'returns file changes' do
21
+ remote_files = Usmu::MockRemoteFiles.new({ 'index.html' => {}, 'articles.html' => {}, 'remote.html' => {} })
22
+ allow(Dir).to receive(:'[]').with('site/**/{*,.??*}').and_return(%w(site/index.html site/articles.html site/local.html))
23
+ diff = Usmu::Deployment::DirectoryDiff.new(configuration, remote_files)
24
+ expect(diff).to receive(:filter_files).with('articles.html').and_return(false)
25
+ expect(diff).to receive(:filter_files).with('index.html').and_return(true)
26
+
27
+ expect(diff.get_diffs).to eq({
28
+ local: %w{local.html},
29
+ remote: %w{remote.html},
30
+ updated: %w{index.html},
31
+ })
32
+ end
33
+ end
34
+
35
+ context '#filter_files' do
36
+ let (:now) { Time.now }
9
37
  let (:file) { 'Hello world!' }
10
- let (:now) { Time.at(1420875742) }
11
38
 
12
39
  before do
13
- allow(File).to receive(:stat).with('site/index.html').and_return(OpenStruct.new({mtime: now}))
14
- allow(File).to receive(:read).with('site/index.html').and_return(file)
40
+ expect(File).to receive(:stat).with('site/index.html').and_return(OpenStruct.new mtime: now)
41
+ expect(File).to receive(:read).with('site/index.html').and_return(file)
15
42
  end
16
43
 
17
- it 'returns remote only files' do
18
- allow(Dir).to receive(:'[]').with('site/**/{*,.??*}').and_return(%w())
19
- remote_files = Usmu::MockRemoteFiles.new(
20
- {
21
- 'index.html' => {
22
- :mtime => now + 100,
23
- },
24
- }
25
- )
44
+ it 'rejects identical files' do
45
+ remote_files = Usmu::MockRemoteFiles.new({ 'index.html' => {mtime: now} })
26
46
  diff = Usmu::Deployment::DirectoryDiff.new(configuration, remote_files)
47
+ expect(diff).to receive(:check_hash).with(file, {mtime: now}).and_return(true)
27
48
 
28
- expect(diff.get_diffs).to eq({remote: ['index.html'], local: [], updated: []})
49
+ expect(diff.send :filter_files, 'index.html').to eq(false)
29
50
  end
30
51
 
31
- it 'returns local only files' do
32
- allow(Dir).to receive(:'[]').with('site/**/{*,.??*}').and_return(%w(site/index.html))
33
- remote_files = Usmu::MockRemoteFiles.new({})
52
+ it 'rejects files newer on remote' do
53
+ remote_files = Usmu::MockRemoteFiles.new({ 'index.html' => {mtime: now + 200} })
34
54
  diff = Usmu::Deployment::DirectoryDiff.new(configuration, remote_files)
55
+ expect(diff).to receive(:check_hash).with(file, {mtime: now + 200}).and_return(true)
35
56
 
36
- expect(diff.get_diffs).to eq({local: ['index.html'], remote: [], updated: []})
57
+ expect(diff.send :filter_files, 'index.html').to eq(false)
37
58
  end
38
59
 
39
- it 'hides identical files' do
40
- allow(Dir).to receive(:'[]').with('site/**/{*,.??*}').and_return(%w(site/index.html))
41
- remote_files = Usmu::MockRemoteFiles.new(
42
- {
43
- 'index.html' => {
44
- :mtime => now,
45
- },
46
- }
47
- )
60
+ it 'allows files newer on local' do
61
+ remote_files = Usmu::MockRemoteFiles.new({ 'index.html' => {mtime: now - 200} })
48
62
  diff = Usmu::Deployment::DirectoryDiff.new(configuration, remote_files)
63
+ expect(diff).to receive(:check_hash).with(file, {mtime: now - 200}).and_return(true)
49
64
 
50
- expect(diff.get_diffs).to eq({local: [], remote: [], updated: []})
65
+ expect(diff.send :filter_files, 'index.html').to eq(true)
51
66
  end
52
67
 
53
- it 'hides files newer on remote' do
54
- allow(Dir).to receive(:'[]').with('site/**/{*,.??*}').and_return(%w(site/index.html))
55
- remote_files = Usmu::MockRemoteFiles.new(
56
- {
57
- 'index.html' => {
58
- :mtime => now + 100,
59
- },
60
- }
61
- )
68
+ it 'allows files with different hashes' do
69
+ remote_files = Usmu::MockRemoteFiles.new({ 'index.html' => {mtime: now} })
62
70
  diff = Usmu::Deployment::DirectoryDiff.new(configuration, remote_files)
71
+ expect(diff).to receive(:check_hash).with(file, {mtime: now}).and_return(false)
63
72
 
64
- expect(diff.get_diffs).to eq({local: [], remote: [], updated: []})
73
+ expect(diff.send :filter_files, 'index.html').to eq(true)
65
74
  end
66
75
 
67
- it 'returns files newer on local' do
68
- allow(Dir).to receive(:'[]').with('site/**/{*,.??*}').and_return(%w(site/index.html))
69
- remote_files = Usmu::MockRemoteFiles.new(
70
- {
71
- 'index.html' => {
72
- :mtime => now - 100,
73
- },
74
- }
75
- )
76
+ it 'allows files with different hashes and newer remote file' do
77
+ remote_files = Usmu::MockRemoteFiles.new({ 'index.html' => {mtime: now + 200} })
76
78
  diff = Usmu::Deployment::DirectoryDiff.new(configuration, remote_files)
79
+ expect(diff).to receive(:check_hash).with(file, {mtime: now + 200}).and_return(false)
77
80
 
78
- expect(diff.get_diffs).to eq({local: [], remote: [], updated: ['index.html']})
81
+ expect(diff.send :filter_files, 'index.html').to eq(true)
79
82
  end
83
+ end
80
84
 
81
- it 'returns files with different md5 hashes' do
82
- allow(Dir).to receive(:'[]').with('site/**/{*,.??*}').and_return(%w(site/index.html))
83
- remote_files = Usmu::MockRemoteFiles.new(
84
- {
85
- 'index.html' => {
86
- :mtime => now,
87
- :md5 => Digest::MD5.hexdigest(file + 'foo'),
88
- },
89
- }
90
- )
91
- diff = Usmu::Deployment::DirectoryDiff.new(configuration, remote_files)
85
+ context '#check_hash' do
86
+ let (:contents) { 'Hello world!' }
87
+ let (:diff) { Usmu::Deployment::DirectoryDiff.new(configuration, nil) }
92
88
 
93
- expect(diff.get_diffs).to eq({local: [], remote: [], updated: ['index.html']})
89
+ it 'can validate an MD5 hash' do
90
+ expect(diff.send :check_hash, contents, {md5: '86fb269d190d2c85f6e0468ceca42a20'}).to eq(true)
91
+ expect(diff.send :check_hash, contents, {md5: '02a24acec8640e6f58c2d091d962bf68'}).to eq(false)
94
92
  end
95
93
 
96
- it 'returns files with different sha1 hashes' do
97
- allow(Dir).to receive(:'[]').with('site/**/{*,.??*}').and_return(%w(site/index.html))
98
- remote_files = Usmu::MockRemoteFiles.new(
99
- {
100
- 'index.html' => {
101
- :mtime => now,
102
- :sha1 => Digest::SHA1.hexdigest(file + 'foo'),
103
- },
104
- }
105
- )
106
- diff = Usmu::Deployment::DirectoryDiff.new(configuration, remote_files)
94
+ it 'can validate a SHA1 hash' do
95
+ expect(diff.send :check_hash, contents, {sha1: 'd3486ae9136e7856bc42212385ea797094475802'}).to eq(true)
96
+ expect(diff.send :check_hash, contents, {sha1: '208574490797ae58321224cb6587e6319ea6843d'}).to eq(false)
97
+ end
107
98
 
108
- expect(diff.get_diffs).to eq({local: [], remote: [], updated: ['index.html']})
99
+ it 'can validate a remote file with no hash' do
100
+ expect(diff.send :check_hash, contents, {}).to eq(true)
109
101
  end
102
+ end
110
103
 
111
- it 'returns files with different hashes and newer remote file' do
112
- allow(Dir).to receive(:'[]').with('site/**/{*,.??*}').and_return(%w(site/index.html))
113
- remote_files = Usmu::MockRemoteFiles.new(
114
- {
115
- 'index.html' => {
116
- :mtime => now + 100,
117
- :md5 => Digest::MD5.hexdigest(file + 'foo'),
118
- },
119
- }
120
- )
121
- diff = Usmu::Deployment::DirectoryDiff.new(configuration, remote_files)
104
+ context '#local_files_list' do
105
+ it 'returns a list of files in the local output directory' do
106
+ expect(Dir).to receive(:[]).with('site/**/{*,.??*}').and_return(%w{site/index.html})
107
+ diff = Usmu::Deployment::DirectoryDiff.new(configuration, nil)
122
108
 
123
- expect(diff.get_diffs).to eq({local: [], remote: [], updated: ['index.html']})
109
+ expect(diff.send :local_files_list).to eq(%w{index.html})
124
110
  end
125
111
  end
126
112
  end
@@ -0,0 +1,75 @@
1
+ require 'usmu/metadata_service'
2
+
3
+ RSpec.describe Usmu::MetadataService do
4
+ let (:service) { Usmu::MetadataService.new('test') }
5
+
6
+ context '#initialize' do
7
+ it 'stores a base directory for checks' do
8
+ expect(service.send :base).to eq('test')
9
+ end
10
+ end
11
+
12
+ context '#metadata' do
13
+ it 'returns an empty hash if no metadata available' do
14
+ expect(File).to receive(:exist?).with('test/test.meta.yml').and_return(false)
15
+ allow(File).to receive(:directory?).and_return(false)
16
+ expect(service.metadata('test.md')).to eq({})
17
+ end
18
+
19
+ it 'returns metadata for files in the root folder' do
20
+ expect(File).to receive(:exist?).with('test/a.meta.yml').and_return(true)
21
+ expect(YAML).to receive(:load_file).with('test/a.meta.yml').and_return({test: 'success'})
22
+ allow(File).to receive(:directory?).and_return(false)
23
+ expect(service.metadata('a.md')).to eq({test: 'success'})
24
+ end
25
+
26
+ it 'looks for dotfile metadata using the entire filename' do
27
+ expect(File).to receive(:exist?).with('test/.dotfile.meta.yml').and_return(true)
28
+ expect(YAML).to receive(:load_file).with('test/.dotfile.meta.yml').and_return({test: 'success'})
29
+ allow(File).to receive(:directory?).and_return(false)
30
+ expect(service.metadata('.dotfile')).to eq({test: 'success'})
31
+ end
32
+
33
+ it 'looks for metadata using the entire filename if file has no extension' do
34
+ expect(File).to receive(:exist?).with('test/dotfile.meta.yml').and_return(true)
35
+ expect(YAML).to receive(:load_file).with('test/dotfile.meta.yml').and_return({test: 'success'})
36
+ allow(File).to receive(:directory?).and_return(false)
37
+ expect(service.metadata('dotfile')).to eq({test: 'success'})
38
+ end
39
+
40
+ it 'merges metadata from parent folders' do
41
+ expect(File).to receive(:exist?).with('test/foo/test.meta.yml').and_return(true)
42
+ expect(YAML).to receive(:load_file).with('test/foo/test.meta.yml').and_return({test: 'success'})
43
+ expect(File).to receive(:exist?).with('test/foo/meta.yml').and_return(true)
44
+ expect(YAML).to receive(:load_file).with('test/foo/meta.yml').and_return({dir: 'success'})
45
+
46
+ expect(File).to receive(:directory?).with('test/foo').and_return(true)
47
+ allow(File).to receive(:directory?).and_return(false)
48
+
49
+ expect(service.metadata('foo/test.md')).to eq({dir: 'success', test: 'success'})
50
+ end
51
+
52
+ it 'only searches for a file extension in the filename' do
53
+ expect(File).to receive(:exist?).with('test/te.st/meta.yml').and_return(false)
54
+ expect(File).to receive(:exist?).with('test/te.st/dotfile.meta.yml').and_return(true)
55
+ expect(YAML).to receive(:load_file).with('test/te.st/dotfile.meta.yml').and_return({test: 'success'})
56
+
57
+ expect(File).to receive(:directory?).with('test/te.st').and_return(true)
58
+ allow(File).to receive(:directory?).and_return(false)
59
+
60
+ expect(service.metadata('te.st/dotfile')).to eq({test: 'success'})
61
+ end
62
+
63
+ it 'favours metadata from objects to metadata from parent objects' do
64
+ expect(File).to receive(:exist?).with('test/foo/test.meta.yml').and_return(true)
65
+ expect(YAML).to receive(:load_file).with('test/foo/test.meta.yml').and_return({test: 'success'})
66
+ expect(File).to receive(:exist?).with('test/foo/meta.yml').and_return(true)
67
+ expect(YAML).to receive(:load_file).with('test/foo/meta.yml').and_return({test: 'directory'})
68
+
69
+ expect(File).to receive(:directory?).with('test/foo').and_return(true)
70
+ allow(File).to receive(:directory?).and_return(false)
71
+
72
+ expect(service.metadata('foo/test.md')).to eq({test: 'success'})
73
+ end
74
+ end
75
+ end
@@ -11,7 +11,7 @@ RSpec.describe Usmu::SiteGenerator do
11
11
 
12
12
  it 'should have a list of renderable items' do
13
13
  expect(generator.respond_to? :renderables).to eq(true)
14
- expect(generator.renderables.map {|r| r.name}.sort).to eq(%w{.dotfiletest.txt css/app.scss default.md embedded.md index.md posts/test-post.md robots.txt})
14
+ expect(generator.renderables.map {|r| r.name}.sort).to eq(%w{.dotfiletest.txt assets/external.scss css/app.scss default.md embedded.md index.md posts/test-post.md robots.txt})
15
15
  end
16
16
 
17
17
  it 'should have pages' do
@@ -21,7 +21,7 @@ RSpec.describe Usmu::SiteGenerator do
21
21
 
22
22
  it 'should have files' do
23
23
  expect(generator.respond_to? :files).to eq(true)
24
- expect(generator.files.map {|f| f.name}.sort).to eq(%w{.dotfiletest.txt robots.txt})
24
+ expect(generator.files.map {|f| f.name}.sort).to eq(%w{.dotfiletest.txt assets/external.scss robots.txt})
25
25
  end
26
26
 
27
27
  it 'should not list directories' do
@@ -3,13 +3,13 @@ RSpec.shared_examples 'a renderable file' do
3
3
  let(:empty_configuration) { Usmu::Configuration.from_hash({}) }
4
4
 
5
5
  it 'and has a name' do
6
- layout = described_class.new(empty_configuration, 'body.slim', 'slim', '', {})
6
+ layout = described_class.new(empty_configuration, 'body.slim', {}, 'slim', '')
7
7
  expect(layout.respond_to? :name).to eq(true)
8
8
  expect(layout.name).to eq('body.slim')
9
9
  end
10
10
 
11
11
  it 'and can be rendered' do
12
- layout = described_class.new(empty_configuration, 'body.slim', 'slim', '', {})
12
+ layout = described_class.new(empty_configuration, 'body.slim', {}, 'slim', '')
13
13
  expect(layout.respond_to? :render).to eq(true)
14
14
  expect(layout.method(:render).arity).to eq(-1)
15
15
  expect(layout.method(:render).parameters.length).to eq(1)
@@ -24,13 +24,13 @@ RSpec.shared_examples 'a layout' do
24
24
  let(:content) { "title \#{title}\nbody\n #container\n | \#{{content}}" }
25
25
 
26
26
  it 'and has a type' do
27
- layout = described_class.new(empty_configuration, 'body.slim', 'slim', content, meta_with_title)
27
+ layout = described_class.new(empty_configuration, 'body.slim', meta_with_title, 'slim', content)
28
28
  expect(layout.respond_to? :type).to eq(true)
29
29
  expect(layout.type).to eq('slim')
30
30
  end
31
31
 
32
32
  it 'and it renders a template' do
33
- layout = described_class.new(empty_configuration, 'body.slim', 'slim', content, {})
33
+ layout = described_class.new(empty_configuration, 'body.slim', {}, 'slim', content)
34
34
  expect(layout.render({'title' => 'title', 'content' => 'test'})).to eq(<<-EOF)
35
35
  <title>title</title><body><div id="container">test</div></body>
36
36
  EOF
@@ -38,66 +38,66 @@ RSpec.shared_examples 'a layout' do
38
38
 
39
39
  context 'and when it\'s type' do
40
40
  it 'is invalid' do
41
- expect {described_class.new(empty_configuration, 'body.foo', nil, '', {})}.to raise_error()
41
+ expect {described_class.new(empty_configuration, 'body.foo', {}, nil, '')}.to raise_error()
42
42
  end
43
43
 
44
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', '', {})
45
+ layout = described_class.new(empty_configuration, 'body.txt.erb', {}, 'erb', '')
46
46
  expect(layout.output_filename).to eq('body.txt')
47
47
  end
48
48
 
49
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', '', {})
50
+ layout = described_class.new(empty_configuration, 'body.txt.rhtml', {}, 'rhtml', '')
51
51
  expect(layout.output_filename).to eq('body.txt')
52
52
  end
53
53
 
54
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', '', {})
55
+ layout = described_class.new(empty_configuration, 'body.txt.erubis', {}, 'erubis', '')
56
56
  expect(layout.output_filename).to eq('body.txt')
57
57
  end
58
58
 
59
59
  it 'is markdown then it\'s output type should be html' do
60
- layout = described_class.new(empty_configuration, 'body.markdown', 'markdown', '', {})
60
+ layout = described_class.new(empty_configuration, 'body.markdown', {}, 'markdown', '')
61
61
  expect(layout.output_filename).to eq('body.html')
62
62
  end
63
63
 
64
64
  it 'is mkd then it\'s output type should be html' do
65
- layout = described_class.new(empty_configuration, 'body.mkd', 'mkd', '', {})
65
+ layout = described_class.new(empty_configuration, 'body.mkd', {}, 'mkd', '')
66
66
  expect(layout.output_filename).to eq('body.html')
67
67
  end
68
68
 
69
69
  it 'is md then it\'s output type should be html' do
70
- layout = described_class.new(empty_configuration, 'body.md', 'md', '', {})
70
+ layout = described_class.new(empty_configuration, 'body.md', {}, 'md', '')
71
71
  expect(layout.output_filename).to eq('body.html')
72
72
  end
73
73
 
74
74
  it 'is coffee then it\'s output type should be js' do
75
- layout = described_class.new(empty_configuration, 'body.coffee', 'coffee', '', {})
75
+ layout = described_class.new(empty_configuration, 'body.coffee', {}, 'coffee', '')
76
76
  expect(layout.output_filename).to eq('body.js')
77
77
  end
78
78
 
79
79
  it 'is less then it\'s output type should be css' do
80
- layout = described_class.new(empty_configuration, 'body.less', 'less', '', {})
80
+ layout = described_class.new(empty_configuration, 'body.less', {}, 'less', '')
81
81
  expect(layout.output_filename).to eq('body.css')
82
82
  end
83
83
 
84
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', '', {})
85
+ layout = described_class.new(empty_configuration, 'body.txt.liquid', {}, 'liquid', '')
86
86
  expect(layout.output_filename).to eq('body.txt')
87
87
  end
88
88
 
89
89
  it 'is sass then it\'s output type should be scss' do
90
- layout = described_class.new(empty_configuration, 'body.sass', 'sass', '', {})
90
+ layout = described_class.new(empty_configuration, 'body.sass', {}, 'sass', '')
91
91
  expect(layout.output_filename).to eq('body.css')
92
92
  end
93
93
 
94
94
  it 'is scss then it\'s output type should be css' do
95
- layout = described_class.new(empty_configuration, 'body.scss', 'scss', '', {})
95
+ layout = described_class.new(empty_configuration, 'body.scss', {}, 'scss', '')
96
96
  expect(layout.output_filename).to eq('body.css')
97
97
  end
98
98
 
99
99
  it 'is slim then it\'s output type should be html' do
100
- layout = described_class.new(empty_configuration, 'body.slim', 'slim', '', {})
100
+ layout = described_class.new(empty_configuration, 'body.slim', {}, 'slim', '')
101
101
  expect(layout.output_filename).to eq('body.html')
102
102
  end
103
103
  end
@@ -107,13 +107,13 @@ RSpec.shared_examples 'a layout with metadata' do
107
107
  include_examples 'a layout'
108
108
 
109
109
  it 'and has metadata' do
110
- layout = described_class.new(empty_configuration, 'body.slim', 'slim', content, meta_with_title)
110
+ layout = described_class.new(empty_configuration, 'body.slim', meta_with_title, 'slim', content)
111
111
  expect(layout.respond_to? :metadata).to eq(true)
112
112
  expect(layout.metadata).to eq(meta_with_title)
113
113
  end
114
114
 
115
115
  it 'and respects default meta from configuration' do
116
- layout = described_class.new(title_configuration, 'body.slim', 'slim', content, {})
116
+ layout = described_class.new(title_configuration, 'body.slim', {}, 'slim', content)
117
117
  expect(layout.render({'content' => 'test'})).to eq(<<-EOF)
118
118
  <title>title</title><body><div id="container">test</div></body>
119
119
  EOF
@@ -121,14 +121,14 @@ RSpec.shared_examples 'a layout with metadata' do
121
121
 
122
122
  context 'and prioritises' do
123
123
  it 'variables over metadata' do
124
- layout = described_class.new(empty_configuration, 'body.slim', 'slim', content, meta_with_title)
124
+ layout = described_class.new(empty_configuration, 'body.slim', meta_with_title, 'slim', content)
125
125
  expect(layout.render({'content' => 'test', 'title' => 'overridden title'})).to eq(<<-EOF)
126
126
  <title>overridden title</title><body><div id="container">test</div></body>
127
127
  EOF
128
128
  end
129
129
 
130
130
  it 'metadata over default metadata' do
131
- layout = described_class.new(title_configuration, 'body.slim', 'slim', content, meta_with_title)
131
+ layout = described_class.new(title_configuration, 'body.slim', meta_with_title, 'slim', content)
132
132
  expect(layout.render({'content' => 'test'})).to eq(<<-EOF)
133
133
  <title>meta title</title><body><div id="container">test</div></body>
134
134
  EOF
@@ -136,7 +136,7 @@ RSpec.shared_examples 'a layout with metadata' do
136
136
  end
137
137
 
138
138
  it 'and it has a html output filename' do
139
- layout = described_class.new(empty_configuration, 'index.md', 'md', content, {})
139
+ layout = described_class.new(empty_configuration, 'index.md', {}, 'md', content)
140
140
  expect(layout.output_filename).to eq('index.html')
141
141
  end
142
142
  end
@@ -147,8 +147,8 @@ RSpec.shared_examples 'an embeddable layout' do
147
147
  let(:wrapper) { "html\n | \#{{content}}"}
148
148
 
149
149
  it 'and respects parent templates' do
150
- parent = described_class.new(empty_configuration, 'html.slim', 'slim', wrapper, {})
151
- layout = described_class.new(empty_configuration, 'body.slim', 'slim', content, {'layout' => parent, 'title' => 'test title'})
150
+ parent = described_class.new(empty_configuration, 'html.slim', {}, 'slim', wrapper)
151
+ layout = described_class.new(empty_configuration, 'body.slim', {'layout' => parent, 'title' => 'test title'}, 'slim', content)
152
152
  expect(layout.render({'content' => 'test'})).to eq(<<-EOF)
153
153
  <html><title>test title</title><body><div id="container">test</div></body>
154
154
  </html>
@@ -156,9 +156,9 @@ RSpec.shared_examples 'an embeddable layout' do
156
156
  end
157
157
 
158
158
  it 'and respects templates from default metadata' do
159
- parent = described_class.new(empty_configuration, 'html.slim', 'slim', wrapper, {})
159
+ parent = described_class.new(empty_configuration, 'html.slim', {}, 'slim', wrapper)
160
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'})
161
+ layout = described_class.new(default_layout_configuration, 'body.slim', {'title' => 'test title'}, 'slim', content)
162
162
  expect(layout.render({'content' => 'test'})).to eq(<<-EOF)
163
163
  <html><title>test title</title><body><div id="container">test</div></body>
164
164
  </html>
@@ -167,15 +167,15 @@ RSpec.shared_examples 'an embeddable layout' do
167
167
 
168
168
  it 'and uses a template of "none" to explicitly disable the parent template' do
169
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'})
170
+ layout = described_class.new(default_layout_configuration, 'body.slim', {'layout' => 'none', 'title' => 'test title'}, 'slim', content)
171
171
  expect(layout.render({'content' => 'test'})).to eq(<<-EOF)
172
172
  <title>test title</title><body><div id="container">test</div></body>
173
173
  EOF
174
174
  end
175
175
 
176
176
  it 'only uses a wrapper layout if the output types match' do
177
- parent = described_class.new(empty_configuration, 'html.slim', 'slim', wrapper, {})
178
- layout = described_class.new(empty_configuration, 'app.scss', 'scss', 'body { color: #000; }', {'layout' => parent})
177
+ parent = described_class.new(empty_configuration, 'html.slim', {}, 'slim', wrapper)
178
+ layout = described_class.new(empty_configuration, 'app.scss', {'layout' => parent}, 'scss', 'body { color: #000; }')
179
179
  expect(layout.render({'content' => ''})).to eq(<<-EOF)
180
180
  body {
181
181
  color: #000; }
@@ -184,8 +184,8 @@ body {
184
184
 
185
185
  context 'and prioritises' do
186
186
  it 'metadata over parent metadata' do
187
- parent = described_class.new(empty_configuration, 'html.slim', 'slim', wrapper, {'title' => 'title'})
188
- layout = described_class.new(empty_configuration, 'body.slim', 'slim', content, {'layout' => parent, 'title' => 'overridden title'})
187
+ parent = described_class.new(empty_configuration, 'html.slim', {'title' => 'title'}, 'slim', wrapper)
188
+ layout = described_class.new(empty_configuration, 'body.slim', {'layout' => parent, 'title' => 'overridden title'}, 'slim', content)
189
189
  expect(layout.render({'content' => 'test'})).to eq(<<-EOF)
190
190
  <html><title>overridden title</title><body><div id="container">test</div></body>
191
191
  </html>
@@ -193,8 +193,8 @@ body {
193
193
  end
194
194
 
195
195
  it 'parent metadata over default metadata' do
196
- parent = described_class.new(title_configuration, 'html.slim', 'slim', wrapper, {'title' => 'overridden title'})
197
- layout = described_class.new(title_configuration, 'body.slim', 'slim', content, {'layout' => parent})
196
+ parent = described_class.new(title_configuration, 'html.slim', {'title' => 'overridden title'}, 'slim', wrapper)
197
+ layout = described_class.new(title_configuration, 'body.slim', {'layout' => parent}, 'slim', content)
198
198
  expect(layout.render({'content' => 'test'})).to eq(<<-EOF)
199
199
  <html><title>overridden title</title><body><div id="container">test</div></body>
200
200
  </html>