Skip to content

Commit

Permalink
Add feature for packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
Arjan van der Gaag authored and Arjan van der Gaag committed Jul 11, 2012
1 parent 901520f commit 275eff6
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
30 changes: 30 additions & 0 deletions features/package.feature
@@ -0,0 +1,30 @@
Feature: packaging
As an author
I want to package my book and other files into a single archive
So I can easily distribute it over the internet

Background:
Given a basic project

Scenario: compressing book
When I successfully run `rpub package`
Then a file named "untitled_book.zip" should exist
And the archive "untitled_book.zip" should contain file "untitled-book-0.0.0.epub"

Scenario: custom package filename
Given the default "config.yml" file with "package_file" set to "my_book.zip"
When I successfully run `rpub package`
Then a file named "my_book.zip" should exist

Scenario: uncompiled book
When I successfully run `rpub package`
Then a file named "untitled-book-0.0.0.epub" should exist

Scenario: help
When I successfully run `rpub package -h`
Then the output should contain "Compile your ebook to an ePub file and package it into an archive"

Scenario: additional files
When I successfully run `rpub package`
Then a file named "untitled_book.zip" should exist
And the archive "untitled_book.zip" should contain file "README.md"
30 changes: 30 additions & 0 deletions features/step_definitions/general_steps.rb
Expand Up @@ -11,7 +11,37 @@ def read_support_file(filename)
write_file filename, read_support_file(filename)
end

Given /^the default "(.*?)" file with "(.*?)" set to "(.*?)"$/ do |filename, key, value|
config = YAML.load(read_support_file(filename))
config[key] = value
write_file filename, YAML.dump(config)
end

Then /^the default file "(.*?)" should exist$/ do |filename|
step %Q{a file named "#{filename}" should exist}
step %Q{the file "#{filename}" should contain exactly:}, read_support_file(filename)
end

Then /^the archive "(.*?)" should contain file "(.*?)"$/ do |filename, entry|
in_current_dir do
Zip::ZipFile.open(filename, Zip::ZipFile::CREATE) do |zipfile|
zipfile.get_entry(entry)
end
end
end

Given /^a basic project$/ do
steps %Q{
Given a file named "README.md" with:
"""
README file
"""
And the default "layout.html" file
And the default "styles.css" file
And the default "config.yml" file
And a file named "chapter1.md" with:
"""
Hello, world
"""
}
end
1 change: 1 addition & 0 deletions features/support/env.rb
@@ -1,2 +1,3 @@
require 'aruba/cucumber'
require 'zip/zip'
SUPPORT_PATH = File.expand_path(File.join(*%w[.. .. .. support]), __FILE__)
1 change: 1 addition & 0 deletions support/config.yml
Expand Up @@ -11,5 +11,6 @@ toc: true
max_level: 2
ignore:
- README.md
package_file: 'untitled_book.zip'
package:
- README.md

0 comments on commit 275eff6

Please sign in to comment.