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