Permalink
Browse files

Renamed FixtureHelper to TempFileHelper.

  • Loading branch information...
1 parent b1dfe20 commit af70a7ae0773285a04fddb99756929bb4e47dc14 @gma gma committed Sep 7, 2011
Showing with 37 additions and 34 deletions.
  1. +1 −0 .gitignore
  2. +4 −4 lib/nesta/plugins.rb
  3. +1 −1 spec/atom_spec.rb
  4. +5 −7 spec/commands_spec.rb
  5. +0 −2 spec/model_factory.rb
  6. +3 −3 spec/models_spec.rb
  7. +5 −5 spec/page_spec.rb
  8. +2 −2 spec/sitemap_spec.rb
  9. +16 −10 spec/spec_helper.rb
View
@@ -12,3 +12,4 @@ db/*.db
pkg/*
plugins
public/cache
+spec/tmp
View
@@ -2,14 +2,14 @@ module Nesta
module Plugins
def self.load_local_plugins
plugins = Dir.glob(File.expand_path('../plugins/*', File.dirname(__FILE__)))
- plugins.each { |plugin| require_plugin(plugin) }
+ plugins.each { |path| require_plugin(path) }
end
private
- def self.require_plugin(plugin)
- require File.join(plugin, 'lib', File.basename(plugin))
+ def self.require_plugin(path)
+ require File.join(path, 'lib', File.basename(path))
rescue LoadError => e
- $stderr.write("Couldn't load plugins/#{File.basename(plugin)}: #{e}\n")
+ $stderr.write("Couldn't load plugins/#{File.basename(path)}: #{e}\n")
end
end
end
View
@@ -17,7 +17,7 @@
end
after(:each) do
- remove_fixtures
+ remove_temp_directory
end
it "should render successfully" do
View
@@ -2,15 +2,13 @@
require File.expand_path("../lib/nesta/commands", File.dirname(__FILE__))
describe "nesta" do
- include FixtureHelper
-
before(:each) do
- create_fixtures_directory
- @project_path = File.join(FixtureHelper::FIXTURE_DIR, 'mysite.com')
+ create_temp_directory
+ @project_path = temp_path('mysite.com')
end
after(:each) do
- remove_fixtures
+ remove_temp_directory
end
def project_path(path)
@@ -221,7 +219,7 @@ def rakefile_source
describe "theme:enable" do
before(:each) do
- config = File.join(FixtureHelper::FIXTURE_DIR, 'config.yml')
+ config = temp_path('config.yml')
Nesta::Config.stub!(:yaml_path).and_return(config)
@name = 'mytheme'
@command = Nesta::Commands::Theme::Enable.new(@name)
@@ -265,7 +263,7 @@ def should_exist(file)
end
before(:each) do
- Nesta::App.stub!(:root).and_return(FixtureHelper::FIXTURE_DIR)
+ Nesta::App.stub!(:root).and_return(TempFileHelper::TEMP_DIR)
@name = 'my-new-theme'
Nesta::Commands::Theme::Create.new(@name).execute
end
View
@@ -1,6 +1,4 @@
module ModelFactory
- include FixtureHelper
-
def create_page(options)
extension = options[:ext] || :mdown
path = filename(Nesta::Config.page_path, options[:path], extension)
View
@@ -40,7 +40,7 @@ def create_page(options)
end
after(:each) do
- remove_fixtures
+ remove_temp_directory
Nesta::FileModel.purge_cache
end
@@ -462,7 +462,7 @@ def create_page(options)
end
after(:each) do
- remove_fixtures
+ remove_temp_directory
Nesta::FileModel.purge_cache
end
@@ -545,7 +545,7 @@ def create_page(options)
end
after(:each) do
- remove_fixtures
+ remove_temp_directory
Nesta::FileModel.purge_cache
end
View
@@ -93,7 +93,7 @@
end
after(:each) do
- remove_fixtures
+ remove_temp_directory
Nesta::FileModel.purge_cache
end
@@ -186,7 +186,7 @@ def do_get
end
after(:each) do
- remove_fixtures
+ remove_temp_directory
Nesta::FileModel.purge_cache
end
@@ -278,7 +278,7 @@ def do_get
end
after(:each) do
- remove_fixtures
+ remove_temp_directory
Nesta::FileModel.purge_cache
end
@@ -407,7 +407,7 @@ def do_get
end
after(:each) do
- remove_fixtures
+ remove_temp_directory
Nesta::FileModel.purge_cache
end
@@ -457,7 +457,7 @@ def create_attachment
end
after(:each) do
- remove_fixtures
+ remove_temp_directory
Nesta::FileModel.purge_cache
end
View
@@ -19,7 +19,7 @@
after(:each) do
Nesta::FileModel.purge_cache
- remove_fixtures
+ remove_temp_directory
end
it "should render successfully" do
@@ -71,7 +71,7 @@
end
after(:each) do
- remove_fixtures
+ remove_temp_directory
Nesta::FileModel.purge_cache
end
View
@@ -21,15 +21,19 @@ class App < Sinatra::Base
require File.expand_path('../lib/nesta/env', File.dirname(__FILE__))
require File.expand_path('../lib/nesta/app', File.dirname(__FILE__))
-module FixtureHelper
- FIXTURE_DIR = File.expand_path('fixtures', File.dirname(__FILE__))
+module TempFileHelper
+ TEMP_DIR = File.expand_path('tmp', File.dirname(__FILE__))
- def create_fixtures_directory
- FileUtils.mkdir_p(FixtureHelper::FIXTURE_DIR)
+ def create_temp_directory
+ FileUtils.mkdir_p(TempFileHelper::TEMP_DIR)
end
- def remove_fixtures
- FileUtils.rm_r(FixtureHelper::FIXTURE_DIR, :force => true)
+ def remove_temp_directory
+ FileUtils.rm_r(TempFileHelper::TEMP_DIR, :force => true)
+ end
+
+ def temp_path(base)
+ File.join(TempFileHelper::TEMP_DIR, base)
end
end
@@ -44,8 +48,6 @@ def body
end
module ConfigSpecHelper
- include FixtureHelper
-
def stub_yaml_config
@config = {}
Nesta::Config.stub!(:yaml_exists?).and_return(true)
@@ -65,7 +67,11 @@ def stub_config_key(key, value, options = {})
def stub_configuration(options = {})
stub_config_key('title', 'My blog', options)
stub_config_key('subtitle', 'about stuff', options)
- content_path = File.join(FixtureHelper::FIXTURE_DIR, 'content')
- stub_config_key('content', content_path, options.merge(:rack_env => true))
+ stub_config_key(
+ 'content', temp_path('content'), options.merge(:rack_env => true))
end
end
+
+Spec::Runner.configure do |config|
+ config.include(TempFileHelper)
+end

0 comments on commit af70a7a

Please sign in to comment.