put test repos in a better location, fix other bugs

This commit is contained in:
Sami Samhuri 2014-10-18 02:34:58 -07:00
parent 3437b8f08a
commit 291e40f859
9 changed files with 33 additions and 9 deletions

2
.gitignore vendored
View file

@ -3,4 +3,4 @@ node_modules
public/feed.xml public/feed.xml
www www
server/auth.json server/auth.json
server/spec/test-blog* server/test-blog*

View file

@ -1,8 +1,12 @@
source 'https://rubygems.org' source 'https://rubygems.org'
gem 'builder' gem 'builder'
gem 'css_parser'
gem 'htmlentities' gem 'htmlentities'
gem 'mustache'
gem 'nokogiri'
gem 'rdiscount' gem 'rdiscount'
gem 'sinatra' gem 'sinatra'
gem 'rspec' gem 'rspec'
gem 'guard-rspec' gem 'guard-rspec'

View file

@ -1,10 +1,13 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
addressable (2.3.6)
builder (3.2.2) builder (3.2.2)
celluloid (0.16.0) celluloid (0.16.0)
timers (~> 4.0.0) timers (~> 4.0.0)
coderay (1.1.0) coderay (1.1.0)
css_parser (1.3.5)
addressable
diff-lcs (1.2.5) diff-lcs (1.2.5)
ffi (1.9.3) ffi (1.9.3)
formatador (0.2.5) formatador (0.2.5)
@ -25,6 +28,10 @@ GEM
rb-inotify (>= 0.9) rb-inotify (>= 0.9)
lumberjack (1.0.9) lumberjack (1.0.9)
method_source (0.8.2) method_source (0.8.2)
mini_portile (0.6.0)
mustache (0.99.6)
nokogiri (1.6.3.1)
mini_portile (= 0.6.0)
pry (0.10.1) pry (0.10.1)
coderay (~> 1.1.0) coderay (~> 1.1.0)
method_source (~> 0.8.1) method_source (~> 0.8.1)
@ -63,8 +70,11 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
builder builder
css_parser
guard-rspec guard-rspec
htmlentities htmlentities
mustache
nokogiri
rdiscount rdiscount
rspec rspec
sinatra sinatra

View file

@ -13,7 +13,10 @@ publish_beta: compile
./bin/publish.sh --beta --delete ./bin/publish.sh --beta --delete
test_blog: test_blog:
./bin/create-test-blog.sh server/spec/test-blog ./bin/create-test-blog.sh server/test-blog
clean:
rm -rf server/test-blog server/test-blog-origin.git
spec: spec:
cd server && rspec -f documentation cd server && rspec -f documentation

View file

@ -9,7 +9,7 @@ if [[ -e "$BLOG_PATH" ]]; then
else else
if [[ ! -e "$ORIGIN_BLOG_PATH" ]]; then if [[ ! -e "$ORIGIN_BLOG_PATH" ]]; then
echo ">>> Mirroring local origin..." echo ">>> Mirroring local origin..."
git clone --mirror https://github.com/samsonjs/samhuri.net.git "$ORIGIN_BLOG_PATH" git clone --mirror . "$ORIGIN_BLOG_PATH"
fi fi
echo ">>> Cloning test blog from local origin..." echo ">>> Cloning test blog from local origin..."
git clone "$ORIGIN_BLOG_PATH" "$BLOG_PATH" git clone "$ORIGIN_BLOG_PATH" "$BLOG_PATH"

View file

@ -11,7 +11,7 @@ require './harp_blog'
$config = { $config = {
auth: false, auth: false,
dry_run: false, dry_run: false,
path: File.expand_path('../spec/test-blog', __FILE__), path: File.expand_path('../test-blog', __FILE__),
host: '127.0.0.1', host: '127.0.0.1',
port: 6706, port: 6706,
} }

View file

@ -2,8 +2,8 @@ require 'json'
require_relative './helpers' require_relative './helpers'
require_relative '../harp_blog' require_relative '../harp_blog'
TEST_BLOG_PATH = File.expand_path('../test-blog', __FILE__) TEST_BLOG_PATH = File.expand_path('../../test-blog', __FILE__)
TEST_BLOG_ORIGIN_PATH = File.expand_path('../test-blog-origin.git', __FILE__) TEST_BLOG_ORIGIN_PATH = File.expand_path('../../test-blog-origin.git', __FILE__)
RSpec.configure do |c| RSpec.configure do |c|
c.include Helpers c.include Helpers
@ -238,6 +238,7 @@ RSpec.describe HarpBlog do
blog = HarpBlog.new(TEST_BLOG_PATH, dry_run, TitleFinder.new) blog = HarpBlog.new(TEST_BLOG_PATH, dry_run, TitleFinder.new)
post = blog.create_post(nil, nil, 'http://samhuri.net') post = blog.create_post(nil, nil, 'http://samhuri.net')
expect(post.title).to eq('fancy title') expect(post.title).to eq('fancy title')
blog.delete_post(post.time.year.to_s, post.padded_month, post.slug)
post = blog.create_post(" \t\n", nil, 'http://samhuri.net') post = blog.create_post(" \t\n", nil, 'http://samhuri.net')
expect(post.title).to eq('fancy title') expect(post.title).to eq('fancy title')
end end

View file

@ -16,7 +16,13 @@ module Helpers
end end
def git_bare?(dir) def git_bare?(dir)
!File.exist?(File.join(dir, '.git')) if File.exist?(File.join(dir, '.git'))
false
elsif File.exist?(File.join(dir, 'HEAD'))
true
else
raise "what is this dir? #{dir} #{Dir[dir + '/*'].join(', ')}"
end
end end
def git_sha(dir) def git_sha(dir)
@ -29,7 +35,7 @@ module Helpers
def git_reset_hard(dir, ref = nil) def git_reset_hard(dir, ref = nil)
if git_bare?(dir) if git_bare?(dir)
raise 'git_reset_hard does not support bare repos' raise 'git_reset_hard does not support bare repos ' + dir + ' -- ' + ref.to_s
else else
args = ref ? "'#{ref}'" : '' args = ref ? "'#{ref}'" : ''
`cd '#{dir}' && git reset --hard #{args}` `cd '#{dir}' && git reset --hard #{args}`