nesta 0.11.1 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitmodules +6 -0
- data/.travis.yml +9 -4
- data/CHANGES +18 -2
- data/Gemfile +1 -1
- data/Gemfile.lock +70 -54
- data/LICENSE +1 -1
- data/RELEASING.md +5 -6
- data/Rakefile +20 -3
- data/lib/nesta/app.rb +4 -8
- data/lib/nesta/commands/command.rb +1 -2
- data/lib/nesta/commands/demo/content.rb +23 -5
- data/lib/nesta/commands/theme/install.rb +9 -7
- data/lib/nesta/helpers.rb +14 -0
- data/lib/nesta/models.rb +26 -22
- data/lib/nesta/navigation.rb +1 -1
- data/lib/nesta/version.rb +1 -1
- data/nesta.gemspec +10 -11
- data/templates/config/config.yml +1 -1
- data/{spec → test}/fixtures/nesta-plugin-test/Gemfile +0 -0
- data/{spec → test}/fixtures/nesta-plugin-test/Rakefile +0 -0
- data/{spec → test}/fixtures/nesta-plugin-test/lib/nesta-plugin-test.rb +0 -0
- data/{spec → test}/fixtures/nesta-plugin-test/lib/nesta-plugin-test/init.rb +0 -0
- data/{spec → test}/fixtures/nesta-plugin-test/lib/nesta-plugin-test/version.rb +0 -0
- data/{spec → test}/fixtures/nesta-plugin-test/nesta-plugin-test.gemspec +0 -0
- data/test/integration/atom_feed_test.rb +178 -0
- data/test/integration/commands/demo/content_test.rb +31 -0
- data/test/integration/commands/edit_test.rb +21 -0
- data/test/integration/commands/new_test.rb +120 -0
- data/test/integration/commands/plugin/create_test.rb +128 -0
- data/test/integration/commands/theme/create_test.rb +35 -0
- data/test/integration/commands/theme/enable_test.rb +22 -0
- data/test/integration/commands/theme/install_test.rb +62 -0
- data/test/integration/default_theme_test.rb +220 -0
- data/test/integration/overrides_test.rb +118 -0
- data/test/integration/route_handlers_test.rb +96 -0
- data/test/integration/sitemap_test.rb +85 -0
- data/test/integration_test_helper.rb +61 -0
- data/test/support/model_factory.rb +169 -0
- data/test/support/silence_commands_during_tests.rb +5 -0
- data/test/support/temporary_files.rb +33 -0
- data/test/support/test_configuration.rb +19 -0
- data/test/test_helper.rb +26 -0
- data/test/unit/commands_test.rb +23 -0
- data/test/unit/config_test.rb +138 -0
- data/test/unit/file_model_test.rb +71 -0
- data/test/unit/menu_test.rb +82 -0
- data/test/unit/page_test.rb +571 -0
- data/test/unit/path_test.rb +41 -0
- data/test/unit/plugin_test.rb +47 -0
- data/views/master.sass +1 -1
- metadata +81 -85
- data/smoke-test.sh +0 -107
- data/spec/atom_spec.rb +0 -141
- data/spec/commands/demo/content_spec.rb +0 -65
- data/spec/commands/edit_spec.rb +0 -27
- data/spec/commands/new_spec.rb +0 -88
- data/spec/commands/plugin/create_spec.rb +0 -97
- data/spec/commands/system_spec.rb +0 -25
- data/spec/commands/theme/create_spec.rb +0 -41
- data/spec/commands/theme/enable_spec.rb +0 -44
- data/spec/commands/theme/install_spec.rb +0 -56
- data/spec/config_spec.rb +0 -127
- data/spec/model_factory.rb +0 -92
- data/spec/models_spec.rb +0 -700
- data/spec/overrides_spec.rb +0 -132
- data/spec/page_spec.rb +0 -560
- data/spec/path_spec.rb +0 -28
- data/spec/plugin_spec.rb +0 -51
- data/spec/sitemap_spec.rb +0 -105
- data/spec/spec_helper.rb +0 -114
data/spec/atom_spec.rb
DELETED
@@ -1,141 +0,0 @@
|
|
1
|
-
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
2
|
-
require File.expand_path('model_factory', File.dirname(__FILE__))
|
3
|
-
|
4
|
-
describe "atom feed" do
|
5
|
-
include ModelFactory
|
6
|
-
include RequestSpecHelper
|
7
|
-
|
8
|
-
before(:each) do
|
9
|
-
stub_configuration
|
10
|
-
stub_config_key("author", {
|
11
|
-
"name" => "Fred Bloggs",
|
12
|
-
"uri" => "http://fredbloggs.com",
|
13
|
-
"email" => "fred@fredbloggs.com"
|
14
|
-
})
|
15
|
-
get "/articles.xml"
|
16
|
-
end
|
17
|
-
|
18
|
-
after(:each) do
|
19
|
-
remove_temp_directory
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should render successfully" do
|
23
|
-
last_response.should be_ok
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should use Atom's XML namespace" do
|
27
|
-
assert_xpath("//feed[@xmlns='http://www.w3.org/2005/Atom']")
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should have an ID element" do
|
31
|
-
assert_selector("id:contains('tag:example.org,2009:/')")
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should have an alternate link element" do
|
35
|
-
assert_xpath("//feed/link[@rel='alternate'][@href='http://example.org/']")
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should have a self link element" do
|
39
|
-
assert_xpath(
|
40
|
-
"//feed/link[@rel='self'][@href='http://example.org/articles.xml']")
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should have title and subtitle" do
|
44
|
-
assert_xpath("//feed/title[@type='text']", content: "My blog")
|
45
|
-
assert_xpath("//feed/subtitle[@type='text']", content: "about stuff")
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should include the author details" do
|
49
|
-
assert_xpath("//feed/author/name", content: "Fred Bloggs")
|
50
|
-
assert_xpath("//feed/author/uri", content: "http://fredbloggs.com")
|
51
|
-
assert_xpath("//feed/author/email", content: "fred@fredbloggs.com")
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "for article" do
|
55
|
-
before(:each) do
|
56
|
-
@heading = "Heading"
|
57
|
-
@articles = []
|
58
|
-
@category = create_category
|
59
|
-
11.times do |i|
|
60
|
-
@articles << create_article(
|
61
|
-
heading: "Article #{i + 1}",
|
62
|
-
path: "article-#{i + 1}",
|
63
|
-
metadata: {
|
64
|
-
"categories" => @category.path,
|
65
|
-
"date" => "#{i + 1} January 2009"
|
66
|
-
},
|
67
|
-
content: "Blah blah\n\n## #{@heading}\n\n[link](/foo)"
|
68
|
-
)
|
69
|
-
end
|
70
|
-
@article = @articles.last
|
71
|
-
get "/articles.xml"
|
72
|
-
end
|
73
|
-
|
74
|
-
it "should set title" do
|
75
|
-
assert_xpath("//entry/title", content: "Article 11")
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should link to the HTML version" do
|
79
|
-
url = "http://example.org/#{@article.path}"
|
80
|
-
assert_xpath(
|
81
|
-
"//entry/link[@href='#{url}'][@rel='alternate'][@type='text/html']")
|
82
|
-
end
|
83
|
-
|
84
|
-
it "should define unique ID" do
|
85
|
-
assert_xpath(
|
86
|
-
"//entry/id",
|
87
|
-
content: "tag:example.org,2009-01-11:#{@article.abspath}"
|
88
|
-
)
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should specify date published" do
|
92
|
-
assert_xpath("//entry/published", content: "2009-01-11T00:00:00+00:00")
|
93
|
-
end
|
94
|
-
|
95
|
-
it "should specify article categories" do
|
96
|
-
assert_xpath("//category[@term='#{@category.permalink}']")
|
97
|
-
end
|
98
|
-
|
99
|
-
it "should have article content" do
|
100
|
-
assert_xpath "//entry/content[@type='html']" do |a|
|
101
|
-
a.should contain "<h2>#{@heading}</h2>"
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should include hostname in URLs" do
|
106
|
-
assert_xpath("//entry/content") do |c|
|
107
|
-
c.should contain 'http://example.org/foo'
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
it "should not include article heading in content" do
|
112
|
-
body.should_not have_selector("summary:contains('#{@article.heading}')")
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should list the latest 10 articles" do
|
116
|
-
assert_selector("entry", count: 10)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
describe "page with no date" do
|
121
|
-
before(:each) do
|
122
|
-
create_category(path: "no-date")
|
123
|
-
get "/articles.xml"
|
124
|
-
end
|
125
|
-
|
126
|
-
it "should not appear in feed" do
|
127
|
-
body.should_not have_selector("entry id:contains('no-date')")
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
describe "article with atom ID" do
|
132
|
-
it "should use pre-defined ID" do
|
133
|
-
create_article(metadata: {
|
134
|
-
"date" => "1 January 2009",
|
135
|
-
"atom id" => "use-this-id"
|
136
|
-
})
|
137
|
-
get "/articles.xml"
|
138
|
-
assert_xpath("//entry/id", content: "use-this-id")
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require File.expand_path('../../spec_helper', File.dirname(__FILE__))
|
2
|
-
require File.expand_path('../../../lib/nesta/commands', File.dirname(__FILE__))
|
3
|
-
|
4
|
-
describe "nesta:demo:content" do
|
5
|
-
include_context "temporary working directory"
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
@config_path = project_path('config/config.yml')
|
9
|
-
FileUtils.mkdir_p(File.dirname(@config_path))
|
10
|
-
Nesta::Config.stub(:yaml_path).and_return(@config_path)
|
11
|
-
create_config_yaml('content: path/to/content')
|
12
|
-
Nesta::App.stub(:root).and_return(@project_path)
|
13
|
-
@repo_url = 'git://github.com/gma/nesta-demo-content.git'
|
14
|
-
@demo_path = project_path('content-demo')
|
15
|
-
@command = Nesta::Commands::Demo::Content.new
|
16
|
-
@command.stub(:run_process)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should clone the repository" do
|
20
|
-
@command.should_receive(:run_process).with(
|
21
|
-
'git', 'clone', @repo_url, @demo_path)
|
22
|
-
@command.execute
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should configure the content directory" do
|
26
|
-
@command.execute
|
27
|
-
File.read(@config_path).should match(/^content: content-demo/)
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "when repository already exists" do
|
31
|
-
before(:each) do
|
32
|
-
FileUtils.mkdir_p(@demo_path)
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should update the repository" do
|
36
|
-
@command.should_receive(:run_process).with(
|
37
|
-
'git', 'pull', 'origin', 'master')
|
38
|
-
@command.execute
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "when site versioned with git" do
|
43
|
-
before(:each) do
|
44
|
-
@exclude_path = project_path('.git/info/exclude')
|
45
|
-
FileUtils.mkdir_p(File.dirname(@exclude_path))
|
46
|
-
File.open(@exclude_path, 'w') { |file| file.puts '# Excludes' }
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should tell git to ignore content-demo" do
|
50
|
-
@command.execute
|
51
|
-
File.read(@exclude_path).should match(/content-demo/)
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "and content-demo already ignored" do
|
55
|
-
before(:each) do
|
56
|
-
File.open(@exclude_path, 'w') { |file| file.puts 'content-demo' }
|
57
|
-
end
|
58
|
-
|
59
|
-
it "shouldn't tell git to ignore it twice" do
|
60
|
-
@command.execute
|
61
|
-
File.read(@exclude_path).scan('content-demo').size.should == 1
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
data/spec/commands/edit_spec.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
2
|
-
require File.expand_path('../../lib/nesta/commands', File.dirname(__FILE__))
|
3
|
-
|
4
|
-
describe "nesta:edit" do
|
5
|
-
include_context "temporary working directory"
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
Nesta::Config.stub(:content_path).and_return('content')
|
9
|
-
@page_path = 'path/to/page.mdown'
|
10
|
-
@command = Nesta::Commands::Edit.new(@page_path)
|
11
|
-
@command.stub(:run_process)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should launch the editor" do
|
15
|
-
ENV['EDITOR'] = 'vi'
|
16
|
-
full_path = File.join('content/pages', @page_path)
|
17
|
-
@command.should_receive(:run_process).with(ENV['EDITOR'], full_path)
|
18
|
-
@command.execute
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should not try and launch an editor if environment not setup" do
|
22
|
-
ENV.delete('EDITOR')
|
23
|
-
@command.should_not_receive(:run_process)
|
24
|
-
$stderr.stub(:puts)
|
25
|
-
@command.execute
|
26
|
-
end
|
27
|
-
end
|
data/spec/commands/new_spec.rb
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
2
|
-
require File.expand_path('../../lib/nesta/commands', File.dirname(__FILE__))
|
3
|
-
|
4
|
-
describe "nesta:new" do
|
5
|
-
include_context "temporary working directory"
|
6
|
-
|
7
|
-
def gemfile_source
|
8
|
-
File.read(project_path('Gemfile'))
|
9
|
-
end
|
10
|
-
|
11
|
-
def rakefile_source
|
12
|
-
File.read(project_path('Rakefile'))
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "without options" do
|
16
|
-
before(:each) do
|
17
|
-
Nesta::Commands::New.new(@project_path).execute
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should create the content directories" do
|
21
|
-
should_exist('content/attachments')
|
22
|
-
should_exist('content/pages')
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should create the home page" do
|
26
|
-
should_exist('content/pages/index.haml')
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should create the rackup file" do
|
30
|
-
should_exist('config.ru')
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should create the config.yml file" do
|
34
|
-
should_exist('config/config.yml')
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should add a Gemfile" do
|
38
|
-
should_exist('Gemfile')
|
39
|
-
gemfile_source.should match(/gem 'nesta'/)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "--git" do
|
44
|
-
before(:each) do
|
45
|
-
@command = Nesta::Commands::New.new(@project_path, 'git' => '')
|
46
|
-
@command.stub(:run_process)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should create a .gitignore file" do
|
50
|
-
@command.execute
|
51
|
-
File.read(project_path('.gitignore')).should match(/\.bundle/)
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should create a git repo" do
|
55
|
-
@command.should_receive(:run_process).with('git', 'init')
|
56
|
-
@command.execute
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should commit the blank project" do
|
60
|
-
@command.should_receive(:run_process).with('git', 'add', '.')
|
61
|
-
@command.should_receive(:run_process).with(
|
62
|
-
'git', 'commit', '-m', 'Initial commit')
|
63
|
-
@command.execute
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe "--vlad" do
|
68
|
-
before(:each) do
|
69
|
-
Nesta::Commands::New.new(@project_path, 'vlad' => '').execute
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should add vlad to Gemfile" do
|
73
|
-
gemfile_source.should match(/gem 'vlad', '2.1.0'/)
|
74
|
-
gemfile_source.should match(/gem 'vlad-git', '2.2.0'/)
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should configure the vlad rake tasks" do
|
78
|
-
should_exist('Rakefile')
|
79
|
-
rakefile_source.should match(/require 'vlad'/)
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should create deploy.rb" do
|
83
|
-
should_exist('config/deploy.rb')
|
84
|
-
deploy_source = File.read(project_path('config/deploy.rb'))
|
85
|
-
deploy_source.should match(/set :application, 'mysite.com'/)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
@@ -1,97 +0,0 @@
|
|
1
|
-
require File.expand_path('../../spec_helper', File.dirname(__FILE__))
|
2
|
-
require File.expand_path('../../../lib/nesta/commands', File.dirname(__FILE__))
|
3
|
-
|
4
|
-
describe 'nesta:plugin:create' do
|
5
|
-
include_context 'temporary working directory'
|
6
|
-
|
7
|
-
def path_in_gem(path)
|
8
|
-
File.join(@gem_name, path)
|
9
|
-
end
|
10
|
-
|
11
|
-
def should_exist(path)
|
12
|
-
File.exist?(path_in_gem(path)).should be_true
|
13
|
-
end
|
14
|
-
|
15
|
-
def should_contain(path, pattern)
|
16
|
-
contents = File.read(path_in_gem(path))
|
17
|
-
contents.should match(pattern)
|
18
|
-
end
|
19
|
-
|
20
|
-
before(:each) do
|
21
|
-
@name = 'my-feature'
|
22
|
-
@gem_name = "nesta-plugin-#{@name}"
|
23
|
-
@plugins_path = temp_path('plugins')
|
24
|
-
@working_dir = Dir.pwd
|
25
|
-
Dir.mkdir(@plugins_path)
|
26
|
-
Dir.chdir(@plugins_path)
|
27
|
-
Nesta::Commands::Plugin::Create.any_instance.stub(:system)
|
28
|
-
Nesta::Commands::Plugin::Create.new(@name).execute
|
29
|
-
end
|
30
|
-
|
31
|
-
after(:each) do
|
32
|
-
Dir.chdir(@working_dir)
|
33
|
-
FileUtils.rm_r(@plugins_path)
|
34
|
-
end
|
35
|
-
|
36
|
-
it "creates the gem's directory" do
|
37
|
-
File.directory?(@gem_name).should be_true
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'creates a README.md file with installation instructions' do
|
41
|
-
should_exist('README.md')
|
42
|
-
should_contain('README.md', %r{echo 'gem "#{@gem_name}"' >> Gemfile})
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'creates .gitignore' do
|
46
|
-
should_exist('.gitignore')
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'creates the gemspec' do
|
50
|
-
path = "#{@gem_name}.gemspec"
|
51
|
-
should_exist(path)
|
52
|
-
should_contain(path, %r{require "#{@gem_name}/version"})
|
53
|
-
should_contain(path, %r{Nesta::Plugin::My::Feature::VERSION})
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'creates a Gemfile' do
|
57
|
-
should_exist('Gemfile')
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'creates Rakefile that helps with packaging the gem' do
|
61
|
-
should_exist("Rakefile")
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'creates default folder for Ruby files' do
|
65
|
-
code_directory = File.join(@gem_name, 'lib', @gem_name)
|
66
|
-
File.directory?(code_directory).should be_true
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'creates file required when gem loaded' do
|
70
|
-
path = "#{File.join('lib', @gem_name)}.rb"
|
71
|
-
should_exist(path)
|
72
|
-
should_contain(path, %r{require "#{@gem_name}/version"})
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'creates version.rb' do
|
76
|
-
path = File.join('lib', @gem_name, 'version.rb')
|
77
|
-
should_exist(path)
|
78
|
-
should_contain path, <<-EOF
|
79
|
-
module Nesta
|
80
|
-
module Plugin
|
81
|
-
module My
|
82
|
-
module Feature
|
83
|
-
VERSION = '0.1.0'
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
EOF
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'creates skeleton code for the plugin in init.rb' do
|
92
|
-
path = File.join('lib', @gem_name, 'init.rb')
|
93
|
-
should_exist(path)
|
94
|
-
should_contain(path, "module Nesta\n module Plugin\n module My::Feature")
|
95
|
-
should_contain(path, 'helpers Nesta::Plugin::My::Feature::Helpers')
|
96
|
-
end
|
97
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
2
|
-
require File.expand_path('../../lib/nesta/commands', File.dirname(__FILE__))
|
3
|
-
|
4
|
-
class TestCommand
|
5
|
-
include Nesta::Commands::Command
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "Nesta::Commands::Command.run_process" do
|
9
|
-
before do
|
10
|
-
@stderr = $stderr
|
11
|
-
$stderr = File.new('/dev/null', 'w')
|
12
|
-
end
|
13
|
-
|
14
|
-
after do
|
15
|
-
$stderr.close
|
16
|
-
$stderr = @stderr
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'can run an external process and catch errors' do
|
20
|
-
TestCommand.new.run_process('ls / >/dev/null')
|
21
|
-
expect {
|
22
|
-
TestCommand.new.run_process('ls /no-such-file 2>/dev/null')
|
23
|
-
}.to raise_error(SystemExit)
|
24
|
-
end
|
25
|
-
end
|