pith 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,48 +0,0 @@
1
- Feature: incremental rebuilding
2
-
3
- I want to reload any altered Ruby code
4
- So that I can quickly iterate config and support libraries
5
-
6
- @wip
7
- Scenario: change a helper
8
-
9
- Given input file "_pith/config.rb" contains
10
- """
11
- lib_dir = File.expand_path("../lib", __FILE__)
12
- $: << lib_dir unless $:.member?(lib_dir)
13
-
14
- require 'stuff'
15
-
16
- project.helpers do
17
- include Stuff
18
- end
19
- """
20
-
21
- And input file "_pith/lib/stuff.rb" contains
22
-
23
- """
24
- module Stuff
25
- def greet(subject)
26
- "Hello, #{subject}"
27
- end
28
- end
29
- """
30
-
31
- And input file "index.html.haml" contains "= greet('mate')"
32
-
33
- When I build the site
34
-
35
- Then output file "index.html" should contain "Hello, mate"
36
-
37
- When I change input file "_pith/lib/stuff.rb" to contain
38
- """
39
- module Stuff
40
- def greet(subject)
41
- "Hola, #{subject}"
42
- end
43
- end
44
- """
45
-
46
- And I rebuild the site
47
-
48
- Then output file "index.html" should contain "Hola, mate"
@@ -1,46 +0,0 @@
1
- require 'spec_helper'
2
- require 'stringio'
3
-
4
- require 'pith/metadata'
5
-
6
- describe Pith::Metadata do
7
-
8
- def metadata
9
- Pith::Metadata.extract_from(StringIO.new(@input))
10
- end
11
-
12
- describe "with input containing no YAML metadata" do
13
-
14
- before do
15
- @input = "%p Blah blah"
16
- end
17
-
18
- it "returns an empty Hash" do
19
- metadata.should == {}
20
- end
21
-
22
- end
23
-
24
- describe "with input containing YAML metadata" do
25
-
26
- before do
27
- @input = <<-HAML.gsub(/^ +/, '')
28
- -# ---
29
- -# x: 1
30
- -# y: "2"
31
- -# ...
32
- -# other stuff
33
- HAML
34
- end
35
-
36
- it "extracts the metadata" do
37
- metadata.should == {
38
- "x" => 1,
39
- "y" => "2"
40
- }
41
- end
42
-
43
- end
44
-
45
- end
46
-
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
- require "pith/plugins/publication"
3
-
4
- describe Pith::Plugins::Publication::TemplateMethods do
5
-
6
- before do
7
- @template = OpenStruct.new(:meta => {})
8
- @template.extend(Pith::Plugins::Publication::TemplateMethods)
9
- end
10
-
11
- describe "#published_at" do
12
-
13
- it "defaults to nil" do
14
- @template.published_at.should be_nil
15
- end
16
-
17
- it "is derived by parsing the 'published' meta-field" do
18
- @template.meta["published"] = "25 Dec 1999 22:30"
19
- @template.published_at.should == Time.local(1999, 12, 25, 22, 30)
20
- end
21
-
22
- end
23
-
24
- describe "#updated_at" do
25
-
26
- it "defaults to #published_at" do
27
- @template.meta["published"] = "25 Dec 1999 22:30"
28
- @template.updated_at.should == Time.local(1999, 12, 25, 22, 30)
29
- end
30
-
31
- it "can be overridden with an 'updated' meta-field" do
32
- @template.meta["published"] = "25 Dec 1999 22:30"
33
- @template.meta["published"] = "1 Jan 2000 03:00"
34
- @template.updated_at.should == Time.local(2000, 1, 1, 3, 0)
35
- end
36
-
37
- end
38
-
39
- end
@@ -1,137 +0,0 @@
1
- require 'spec_helper'
2
- require 'pith/project'
3
-
4
- describe Pith::Project do
5
-
6
- before do
7
- $input_dir.mkpath
8
- @project = Pith::Project.new(:input_dir => $input_dir)
9
- end
10
-
11
- describe "#input" do
12
-
13
- describe "(with a non-template input path)" do
14
-
15
- before do
16
- @input_file = $input_dir + "input.txt"
17
- @input_file.touch
18
- end
19
-
20
- it "constructs an Resource object" do
21
- @input = @project.input("input.txt")
22
- @input.should be_kind_of(Pith::Input::Resource)
23
- @input.file.should == @input_file
24
- end
25
-
26
- end
27
-
28
- describe "(with a template input path)" do
29
-
30
- before do
31
- @input_file = $input_dir + "input.html.haml"
32
- @input_file.touch
33
- end
34
-
35
- it "constructs an Template object" do
36
- @input = @project.input("input.html.haml")
37
- @input.should be_kind_of(Pith::Input::Template)
38
- @input.file.should == @input_file
39
- end
40
-
41
- end
42
-
43
- describe "(with a template ouput path)" do
44
-
45
- before do
46
- @input_file = $input_dir + "input.html.haml"
47
- @input_file.touch
48
- end
49
-
50
- it "can also be used to locate the Template" do
51
- @project.input("input.html").should == @project.input("input.html.haml")
52
- end
53
-
54
- end
55
-
56
- describe "(with an invalid input path)" do
57
-
58
- it "returns nil" do
59
- @project.input("bogus.path").should be_nil
60
- end
61
-
62
- end
63
-
64
- end
65
-
66
- describe "when an input file is unchanged" do
67
-
68
- before do
69
- @input_file = $input_dir + "input.html.haml"
70
- @input_file.touch
71
- end
72
-
73
- describe "a second call to #input" do
74
- it "returns the same Input object" do
75
-
76
- first_time = @project.input("input.html.haml")
77
- first_time.should_not be_nil
78
-
79
- @project.refresh
80
- second_time = @project.input("input.html.haml")
81
- second_time.should equal(first_time)
82
-
83
- end
84
- end
85
-
86
- end
87
-
88
- describe "when an input file is changed" do
89
-
90
- before do
91
- @input_file = $input_dir + "input.html.haml"
92
- @input_file.touch(Time.now - 10)
93
- end
94
-
95
- describe "a second call to #input" do
96
- it "returns a different Input object" do
97
-
98
- first_time = @project.input("input.html.haml")
99
- first_time.should_not be_nil
100
-
101
- @input_file.touch(Time.now)
102
-
103
- @project.refresh
104
- second_time = @project.input("input.html.haml")
105
- second_time.should_not be_nil
106
- second_time.should_not equal(first_time)
107
-
108
- end
109
- end
110
-
111
- end
112
-
113
- describe "when an input file is removed" do
114
-
115
- before do
116
- @input_file = $input_dir + "input.html.haml"
117
- @input_file.touch(Time.now - 10)
118
- end
119
-
120
- describe "a second call to #input" do
121
- it "returns nil" do
122
-
123
- first_time = @project.input("input.html.haml")
124
- first_time.should_not be_nil
125
-
126
- FileUtils.rm(@input_file)
127
-
128
- @project.refresh
129
- second_time = @project.input("input.html.haml")
130
- second_time.should be_nil
131
-
132
- end
133
- end
134
-
135
- end
136
-
137
- end
data/spec/spec_helper.rb~ DELETED
@@ -1,18 +0,0 @@
1
- require "rubygems"
2
-
3
- require "fileutils"
4
-
5
- $project_dir = Pathname(__FILE__).expand_path.parent.parent
6
- $tmp_dir = $project_dir + "tmp"
7
- $input_dir = $tmp_dir + "input"
8
- $output_dir = $tmp_dir + "output"
9
-
10
- Spec::Runner.configure do |config|
11
-
12
- config.before(:suite) do
13
- [$input_dir, $output_dir].each do |dir|
14
- dir.rmtree if dir.exist?
15
- end
16
- end
17
-
18
- end