|
1 | 1 | RSpec.describe(Jekyll::Compose::FileInfo) do |
2 | | - let(:open_and_closing_tag) { "---\n" } |
3 | | - let(:layout_content) { "post\n" } |
4 | | - |
5 | 2 | describe '#content' do |
6 | 3 | context 'with a title of only words' do |
7 | | - let(:expected_title) { "A test arg parser\n" } |
8 | | - subject { described_class.new Jekyll::Compose::ArgParser.new( |
| 4 | + let(:expected_result) {<<-CONTENT.gsub(/^\s+/, '') |
| 5 | + --- |
| 6 | + layout: post |
| 7 | + title: A test arg parser |
| 8 | + --- |
| 9 | + CONTENT |
| 10 | + } |
| 11 | + |
| 12 | + let(:parsed_args) { Jekyll::Compose::ArgParser.new( |
9 | 13 | ['A test arg parser'], |
10 | 14 | {} |
11 | 15 | ) |
12 | 16 | } |
13 | 17 |
|
14 | 18 | it 'does not wrap the title in quotes' do |
15 | | - expect(subject.content).to start_with(open_and_closing_tag) |
16 | | - expect(subject.content).to end_with(open_and_closing_tag) |
17 | | - expect(subject.content).to match(layout_content) |
18 | | - expect(subject.content).to match(expected_title) |
| 19 | + file_info = described_class.new parsed_args |
| 20 | + expect(file_info.content).to eq(expected_result) |
19 | 21 | end |
20 | 22 | end |
21 | 23 |
|
22 | 24 | context 'with a title that includes a colon' do |
23 | | - let(:expected_title) { "'A test: arg parser'\n" } |
24 | | - subject { described_class.new Jekyll::Compose::ArgParser.new( |
| 25 | + let(:expected_result) {<<-CONTENT.gsub(/^\s+/, '') |
| 26 | + --- |
| 27 | + layout: post |
| 28 | + title: 'A test: arg parser' |
| 29 | + --- |
| 30 | + CONTENT |
| 31 | + } |
| 32 | + |
| 33 | + let(:parsed_args) { Jekyll::Compose::ArgParser.new( |
25 | 34 | ['A test: arg parser'], |
26 | 35 | {} |
27 | 36 | ) |
28 | 37 | } |
29 | 38 |
|
30 | 39 | it 'does wrap the title in quotes' do |
31 | | - expect(subject.content).to start_with(open_and_closing_tag) |
32 | | - expect(subject.content).to end_with(open_and_closing_tag) |
33 | | - expect(subject.content).to match(layout_content) |
34 | | - expect(subject.content).to match(expected_title) |
| 40 | + file_info = described_class.new parsed_args |
| 41 | + expect(file_info.content).to eq(expected_result) |
35 | 42 | end |
36 | 43 | end |
37 | 44 | end |
|
0 commit comments