public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
convert tests to use test/spec instead of simply bdd [Chris McGrath]

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2857 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Thu May 03 02:31:22 -0700 2007
commit  f4dfc290b682b46b544d2a5a33a33519ebd91fd4
tree    0df98571c068ba2cfad82d1fd816e8268cc402a9
parent  379aa413f7f07bb1d8a5f10445b0049d580bf36f
...
1
2
 
 
 
 
3
4
5
...
1
2
3
4
5
6
7
8
9
0
@@ -1,5 +1,9 @@
0
 * SVN *
0
 
0
+* convert tests to use test/spec instead of simply bdd [Chris McGrath]
0
+
0
+* move xmlrpc stuff to plugin. rails doesn't include AWS anymore. May need some simple autodetection so the plugin just prints a warning if AWS isn't found.
0
+
0
 * turn off session for mephisto controller. sorry, caused way too many problems.
0
 
0
 * fix url_for calls with symbolized controllers/actions.
...
4
5
6
7
 
8
9
10
 
11
12
13
...
115
116
117
118
 
119
120
121
...
4
5
6
 
7
8
9
 
10
11
12
13
...
115
116
117
 
118
119
120
121
0
@@ -4,10 +4,10 @@ require 'admin/articles_controller'
0
 # Re-raise errors caught by the controller.
0
 class Admin::ArticlesController; def rescue_action(e) raise e end; end
0
 
0
-class Admin::ArticlesControllerAssetsTest < Test::Unit::TestCase
0
+context "Admin Articles Controller Assets" do
0
   fixtures :contents, :content_versions, :sections, :assigned_sections, :users, :sites, :tags, :taggings, :memberships, :assigned_assets, :assets
0
 
0
- def setup
0
+ setup do
0
     @controller = Admin::ArticlesController.new
0
     @request = ActionController::TestRequest.new
0
     @response = ActionController::TestResponse.new
0
@@ -115,7 +115,7 @@ class Admin::ArticlesControllerAssetsTest < Test::Unit::TestCase
0
     assert_models_equal [assets(:gif)], contents(:welcome).assets
0
   end
0
 
0
- def teardown
0
+ teardown do
0
     FileUtils.rm_rf ASSET_PATH
0
   end
0
 end
...
4
5
6
7
 
8
9
 
 
10
11
12
...
4
5
6
 
7
8
 
9
10
11
12
13
0
@@ -4,9 +4,10 @@ require 'admin/themes_controller'
0
 # Re-raise errors caught by the controller.
0
 class Admin::ThemesController; def rescue_action(e) raise e end; end
0
 
0
-class Admin::ThemesControllerTest < Test::Unit::TestCase
0
+context "Admin Themes Controller" do
0
   fixtures :users, :sections, :sites, :memberships
0
- def setup
0
+
0
+ setup do
0
     @controller = Admin::ThemesController.new
0
     @request = ActionController::TestRequest.new
0
     @response = ActionController::TestResponse.new
...
3
4
5
 
6
7
8
...
3
4
5
6
7
8
9
0
@@ -3,6 +3,7 @@ ENV['TZ'] = 'US/Central'
0
 
0
 require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
0
 require 'test_help'
0
+require 'test/spec'
0
 require File.expand_path(File.dirname(__FILE__) + "/actor")
0
 ASSET_PATH = File.join(RAILS_ROOT, 'test/fixtures/tmp/assets') unless Object.const_defined?(:ASSET_PATH)
0
 require File.join(File.dirname(__FILE__), 'referenced_caching_test_helper')
...
1
2
3
 
4
5
6
 
7
8
9
...
1
2
 
3
4
5
 
6
7
8
9
0
@@ -1,9 +1,9 @@
0
 require File.dirname(__FILE__) + '/../test_helper'
0
 
0
-class ArticleDropTest < Test::Unit::TestCase
0
+context "Article Drop" do
0
   fixtures :sites, :sections, :contents, :assigned_sections, :users, :tags, :taggings, :assigned_assets, :assets
0
   
0
- def setup
0
+ setup do
0
     @context = mock_context('site' => sites(:first).to_liquid)
0
     @article = contents(:welcome).to_liquid(:mode => :single)
0
     @article.context = @context
...
3
4
5
6
 
7
8
9
...
101
102
103
104
105
 
 
106
107
108
...
3
4
5
 
6
7
8
9
...
101
102
103
 
 
104
105
106
107
108
0
@@ -3,7 +3,7 @@ context "Drop Filters" do
0
   fixtures :sites, :sections, :contents, :assigned_sections, :assigned_assets, :assets
0
   include DropFilters, CoreFilters
0
 
0
- def setup
0
+ setup do
0
     @site = sites(:first).to_liquid
0
     @context = mock_context 'site' => @site, 'section' => sections(:about).to_liquid
0
   end
0
@@ -101,8 +101,8 @@ context "Drop Filters" do
0
     assert_models_equal [assets(:word), assets(:pdf)], assets_by_type('other').collect(&:source)
0
   end
0
 
0
- specify "should find assets by tag" do
0
- assert_models_equal [contents(:welcome)], tagged_articles("rails").collect(&:source)
0
+ specify "should find articles by tag" do
0
+ assert_models_equal [contents(:future), contents(:another)], tagged_articles("rails").collect(&:source)
0
   end
0
 
0
   specify "should find assets by tag" do
...
1
2
3
 
4
5
6
...
1
2
 
3
4
5
6
0
@@ -1,6 +1,6 @@
0
 require File.dirname(__FILE__) + '/../test_helper'
0
 
0
-class SectionTest < Test::Unit::TestCase
0
+context "Section" do
0
   fixtures :sections, :contents, :assigned_sections, :sites, :users
0
 
0
   def test_find_or_create_sanity_check
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
0
@@ -1,30 +0,0 @@
0
-SimplyBdd
0
-=========
0
-
0
-Allows you to use context and specify macros for creating TestCase classes
0
-
0
-context "New User" do
0
- def setup
0
- @user = User.new
0
- end
0
-
0
- specify "should be invalid without a username" do
0
- assert !@user.valid?
0
- @user.username = 'someusername'
0
- assert_valid @user
0
- end
0
-end
0
-
0
-This (dynamically) generates a class like:
0
-
0
-class NewUserTest < Test::Unit::TestCase
0
- def setup
0
- @user = User.new
0
- end
0
-
0
- def test_should_be_invalid_without_a_username
0
- assert !@user.valid?
0
- @user.username = 'someusername'
0
- assert_valid @user
0
- end
0
-end
0
\ No newline at end of file
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,22 +0,0 @@
0
-require 'rake'
0
-require 'rake/testtask'
0
-require 'rake/rdoctask'
0
-
0
-desc 'Default: run unit tests.'
0
-task :default => :test
0
-
0
-desc 'Test the simply_bdd plugin.'
0
-Rake::TestTask.new(:test) do |t|
0
- t.libs << 'lib'
0
- t.pattern = 'test/**/*_test.rb'
0
- t.verbose = true
0
-end
0
-
0
-desc 'Generate documentation for the simply_bdd plugin.'
0
-Rake::RDocTask.new(:rdoc) do |rdoc|
0
- rdoc.rdoc_dir = 'rdoc'
0
- rdoc.title = 'SimplyBdd'
0
- rdoc.options << '--line-numbers' << '--inline-source'
0
- rdoc.rdoc_files.include('README')
0
- rdoc.rdoc_files.include('lib/**/*.rb')
0
-end
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
0
@@ -1,20 +0,0 @@
0
-if RAILS_ENV == 'test'
0
- Object.class_eval do
0
- def context(name, &block)
0
- # create class first so it has a name before evaling the block. this is so fixtures work correctly.
0
- returning self.class.const_set(self.class.convert_bdd_name(name).camelize + 'Test', Class.new(Test::Unit::TestCase)) do |klass|
0
- klass.class_eval &block
0
- end
0
- end
0
-
0
- def self.convert_bdd_name(name)
0
- name.to_s.gsub(/[^\w ]+/, '').gsub(/ +/, '_')
0
- end
0
- end
0
-
0
- class << Test::Unit::TestCase
0
- def specify(name, &block)
0
- define_method 'test_' + convert_bdd_name(name), &block
0
- end
0
- end
0
-end
0
\ No newline at end of file

Comments

    No one has commented yet.