Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Add Individual Files per Entries Option #45

Merged
merged 1 commit into from
Apr 19, 2017

Conversation

dlitvakb
Copy link
Contributor

@dlitvakb dlitvakb commented Apr 14, 2017

Fixes #23
Fixes #10
Fixes #25

@dlitvakb dlitvakb force-pushed the dl/independent-files-per-entry branch from 062ed16 to 9f039b8 Compare April 17, 2017 13:52
@dlitvakb dlitvakb changed the title [WIP] Add Individual Files per Entries Option Add Individual Files per Entries Option Apr 17, 2017
Copy link
Contributor

@mariobodemann mariobodemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some typos, and a way of testing confusion.

module Contentful
# Single File Data Exporter Class
#
# Serializes Contentful data into a Single YAML File
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: Single vs single and File vs file.

expect(subject.base_directory).to eq(Dir.pwd)
end

it 'overriden directory' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overriden vs overridden.

subject.setup_directory(expected)
end

it 'overridden directory' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

it 'serializes entries' do
expect_any_instance_of(::Jekyll::Contentful::Serializer).to receive(:serialize) { {} }

subject.run
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that style of testing only validates, that no error/exception is thrown. Do you mind adding some more precise validations? Aka that the right entry got serialized to the right result?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are tests for the serializers just doing that, this here tests that the logic is followed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but I do not see how you test that the logic is followed. The only thing I can see is validating that nothing throws, unless I'm overlooking something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm testing that when the exporter is running it's calling the serializer.


expected_directory_path = File.join(Dir.pwd, '_data', 'contentful', 'spaces', 'foo', 'bar_ct')
expect(FileUtils).to receive(:mkdir_p).with(expected_directory_path)
expect(File).to receive(:open).with(File.join(expected_directory_path, 'bar.yaml'), 'w')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does not test, what the name suggest, right? I was expecting it to check the existence of all the files created, and not just one. Or I'm miss reading the test name ... :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a single entry, so it just checks for a single file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then, I'm confused by the naming ... ;) Should we call it creates a file or rather have the test create multiple files and validate that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at the setup for the subject I'm sending it a list with a single entry, therefore creating a single file for that entry is the expected behaviour. As it is creating a file for a specific entry with a path that looks like {base_dir}/_data/contentful/spaces/{space_alias}/{content_type_id}/{entry_id}.yaml. While the single_file_data_exporter creates a file for the space instead (and all content types and entries are inside that file).

@dlitvakb dlitvakb force-pushed the dl/independent-files-per-entry branch from 9f039b8 to 11b0b34 Compare April 18, 2017 14:45
@dlitvakb dlitvakb force-pushed the dl/independent-files-per-entry branch from 11b0b34 to 3ff0c3c Compare April 18, 2017 14:46
@dlitvakb dlitvakb merged commit b160a5e into master Apr 19, 2017
@dlitvakb dlitvakb deleted the dl/independent-files-per-entry branch April 19, 2017 10:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants