diff --git a/Gemfile b/Gemfile
index 8926307..d11ddd7 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,3 +1,8 @@
source 'http://rubygems.org'
+gem 'rails', '3.1.1'
+gemspec
+gem 'test-unit'
+gem 'rack-test'
+gem 'actionpack'
+
-gemspec
\ No newline at end of file
diff --git a/Gemfile.lock b/Gemfile.lock
index 45c25a9..6575c76 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,102 +1,121 @@
PATH
remote: .
specs:
- vanna (0.1.0)
+ vanna (0.1.1)
json
+ minitest (>= 2.6.1)
rails (>= 3.0.0)
GEM
remote: http://rubygems.org/
specs:
- ParseTree (3.0.6)
+ ParseTree (3.0.8)
RubyInline (>= 3.7.0)
sexp_processor (>= 3.0.0)
- RubyInline (3.8.6)
+ RubyInline (3.11.0)
ZenTest (~> 4.3)
- ZenTest (4.4.1)
- abstract (1.0.0)
- actionmailer (3.0.3)
- actionpack (= 3.0.3)
- mail (~> 2.2.9)
- actionpack (3.0.3)
- activemodel (= 3.0.3)
- activesupport (= 3.0.3)
- builder (~> 2.1.2)
- erubis (~> 2.6.6)
- i18n (~> 0.4)
- rack (~> 1.2.1)
- rack-mount (~> 0.6.13)
- rack-test (~> 0.5.6)
- tzinfo (~> 0.3.23)
- activemodel (3.0.3)
- activesupport (= 3.0.3)
- builder (~> 2.1.2)
- i18n (~> 0.4)
- activerecord (3.0.3)
- activemodel (= 3.0.3)
- activesupport (= 3.0.3)
- arel (~> 2.0.2)
- tzinfo (~> 0.3.23)
- activeresource (3.0.3)
- activemodel (= 3.0.3)
- activesupport (= 3.0.3)
- activesupport (3.0.3)
- arel (2.0.4)
- builder (2.1.2)
- diff-lcs (1.1.2)
- erubis (2.6.6)
- abstract (>= 1.0.0)
- file-tail (1.0.5)
- spruz (>= 0.1.0)
- i18n (0.4.2)
- json (1.4.6)
- json (1.4.6-x86-mingw32)
- mail (2.2.10)
- activesupport (>= 2.3.6)
- i18n (~> 0.4.1)
+ ZenTest (4.6.2)
+ actionmailer (3.1.1)
+ actionpack (= 3.1.1)
+ mail (~> 2.3.0)
+ actionpack (3.1.1)
+ activemodel (= 3.1.1)
+ activesupport (= 3.1.1)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.2)
+ rack-cache (~> 1.1)
+ rack-mount (~> 0.8.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.0.2)
+ activemodel (3.1.1)
+ activesupport (= 3.1.1)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.1)
+ activemodel (= 3.1.1)
+ activesupport (= 3.1.1)
+ arel (~> 2.2.1)
+ tzinfo (~> 0.3.29)
+ activeresource (3.1.1)
+ activemodel (= 3.1.1)
+ activesupport (= 3.1.1)
+ activesupport (3.1.1)
+ multi_json (~> 1.0)
+ arel (2.2.1)
+ builder (3.0.0)
+ diff-lcs (1.1.3)
+ erubis (2.7.0)
+ file-tail (1.0.7)
+ tins (~> 0.3)
+ hike (1.2.1)
+ i18n (0.6.0)
+ json (1.6.1)
+ mail (2.3.0)
+ i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
- polyglot (0.3.1)
- predicated (0.2.2)
- rack (1.2.1)
- rack-mount (0.6.13)
+ minitest (2.6.1)
+ multi_json (1.0.3)
+ polyglot (0.3.2)
+ predicated (0.2.6)
+ rack (1.3.5)
+ rack-cache (1.1)
+ rack (>= 0.4)
+ rack-mount (0.8.3)
rack (>= 1.0.0)
- rack-test (0.5.6)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
rack (>= 1.0)
- rails (3.0.3)
- actionmailer (= 3.0.3)
- actionpack (= 3.0.3)
- activerecord (= 3.0.3)
- activeresource (= 3.0.3)
- activesupport (= 3.0.3)
+ rails (3.1.1)
+ actionmailer (= 3.1.1)
+ actionpack (= 3.1.1)
+ activerecord (= 3.1.1)
+ activeresource (= 3.1.1)
+ activesupport (= 3.1.1)
bundler (~> 1.0)
- railties (= 3.0.3)
- railties (3.0.3)
- actionpack (= 3.0.3)
- activesupport (= 3.0.3)
+ railties (= 3.1.1)
+ railties (3.1.1)
+ actionpack (= 3.1.1)
+ activesupport (= 3.1.1)
+ rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
- thor (~> 0.14.4)
- rake (0.8.7)
- ruby2ruby (1.2.5)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2)
+ rdoc (3.11)
+ json (~> 1.4)
+ ruby2ruby (1.3.1)
ruby_parser (~> 2.0)
sexp_processor (~> 3.0)
- ruby_parser (2.0.5)
+ ruby_parser (2.0.6)
sexp_processor (~> 3.0)
- sexp_processor (3.0.5)
- sourcify (0.4.0)
+ sexp_processor (3.0.7)
+ sourcify (0.5.0)
+ file-tail (>= 1.0.5)
ruby2ruby (>= 1.2.5)
+ ruby_parser (>= 2.0.5)
sexp_processor (>= 3.0.5)
- spruz (0.2.2)
- thor (0.14.4)
- treetop (1.4.9)
+ sprockets (2.0.3)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ test-unit (2.4.0)
+ thor (0.14.6)
+ tilt (1.3.3)
+ tins (0.3.1)
+ treetop (1.4.10)
+ polyglot
polyglot (>= 0.3.1)
- tzinfo (0.3.23)
- wrong (0.5.0)
+ tzinfo (0.3.30)
+ wrong (0.6.0)
ParseTree (~> 3.0)
diff-lcs (~> 1.1.2)
file-tail (~> 1.0)
- predicated (>= 0.2.2)
+ predicated (>= 0.2.3)
ruby2ruby (~> 1.2)
ruby_parser (~> 2.0.4)
sexp_processor (~> 3.0)
@@ -104,11 +123,11 @@ GEM
PLATFORMS
ruby
- x86-mingw32
DEPENDENCIES
- json
- rack-test (>= 0.5.6)
- rails (>= 3.0.0)
+ actionpack
+ rack-test
+ rails (= 3.1.1)
+ test-unit
vanna!
- wrong (>= 0.5.0)
+ wrong
diff --git a/Rakefile b/Rakefile
index 8fdca7d..f88c42c 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,8 +1,15 @@
+require 'rake/testtask'
task :default => :test
-desc 'run all tests (in current ruby)'
-task :test do
- sh "ruby test/basic_test.rb"
- sh "ruby test/personas_test.rb"
- sh "ruby test/weapons_test.rb"
+desc 'Generate test coverage report'
+task :rcov do
+ sh "rcov -Ilib:test test/*_test.rb"
end
+
+desc 'Run tests (default)'
+Rake::TestTask.new(:test) do |t|
+ t.test_files = FileList['test/*_test.rb']
+ t.ruby_opts = ['-Itest']
+ t.ruby_opts << '-rubygems' if defined? Gem
+end
+
diff --git a/lib/vanna.rb b/lib/vanna.rb
index 28fc288..6a83183 100644
--- a/lib/vanna.rb
+++ b/lib/vanna.rb
@@ -1,6 +1,7 @@
require 'action_controller'
require 'vanna/default_return_codes'
require 'vanna/default_redirects'
+require 'pp'
module Vanna
def self.included(klass)
raise "#{klass.name} does not inherit from ActionController::Metal" unless klass.ancestors.include?(ActionController::Metal)
@@ -75,7 +76,17 @@ def self.inherited(subclass)
super
subclass.send(:include, DefaultReturnCodes) unless subclass.ancestors.member? DefaultReturnCodes
subclass.send(:include, DefaultRedirects) unless subclass.ancestors.member? DefaultRedirects
- subclass.send(:include, Rails.application.routes.url_helpers)
+# pp Rails.application
+ if (Rails.application)
+ if (Rails.application.routes)
+# pp Rails.application.routes
+ subclass.send(:include, Rails.application.routes.url_helpers)
+ else
+# print "no rails application routes defined!\n"
+ end
+ else
+# print "no rails application defined!\n"
+ end
end
end
diff --git a/test/app/views/layouts/application.html.erb b/test/app/views/layouts/application.html.erb
index 88e9d66..a6a3018 100644
--- a/test/app/views/layouts/application.html.erb
+++ b/test/app/views/layouts/application.html.erb
@@ -2,7 +2,7 @@
<%= stylesheet_link_tag "application" %>
- <%= javascript_include_tag :defaults %>
+ <%= javascript_include_tag "application" %>
<%= csrf_meta_tag %>
Vanna Test
diff --git a/test/basic_test.rb b/test/basic_test.rb
index 28cea9b..b52d678 100644
--- a/test/basic_test.rb
+++ b/test/basic_test.rb
@@ -1,5 +1,8 @@
require './test/test_helper'
require 'welcome_controller'
+require 'pp' #
+
+
WelcomeController.append_view_path "test/app/views"
class BasicTest < Test::Unit::TestCase
@@ -12,11 +15,14 @@ def app
def test_gets_json
header "Accept", 'application/json'
get "/"
- assert{ JSON(last_response.body) == {"text" => "hello"} }
+ x = JSON(last_response.body)
+ y = {"text" => "hello"}
+ print "from response got:" +PP.pp(x, "") + " expected :" + PP.pp(y, "") + "\n"
+ assert (x == y)
end
def test_html_renders_template
get "/"
- assert{ last_response.body =~ /Here is some text: hello/ }
+ assert (last_response.body =~ /Here is some text: hello/ )
end
end
diff --git a/test/config/application.rb b/test/config/application.rb
index 8b27070..a1efb2e 100644
--- a/test/config/application.rb
+++ b/test/config/application.rb
@@ -1,25 +1,37 @@
-require 'rubygems'
-
gemfile = File.expand_path('../../Gemfile', __FILE__)
begin
ENV['BUNDLE_GEMFILE'] = gemfile
- require 'bundler'
Bundler.setup
rescue Bundler::GemNotFound => e
STDERR.puts e.message
STDERR.puts "Try running `bundle install`."
exit!
end if File.exist?(gemfile)
-Bundler.require(:default, Rails.env) if defined?(Bundler)
+#Bundler.require(:default, Rails.env) if defined?(Bundler)
+
-require "action_controller/railtie"
module ActionPresenter
+
+ class Controller < ApplicationController
+ def perform_caching
+ false
+ end
+ end
+
class Application < Rails::Application
+ # config.action_controller.perfom_caching=0
+ @c = Controller.new()
+ config.action_controller = @c
+
+# @c = View.new()
+# config.action_view = @v
+
config.active_support.deprecation = :stdout
config.secret_token = '8b9708cd5d4a96f541e04326467fc9c4b0c0a44c4d77b19632db2145fd1cf686d739f7d34a3ecce551c53dc8d31730e816cd332b3eececd95cc539b52e1aadde'
routes.draw do
root :to => "welcome#index"
match ':controller(/:action(/:id(.:format)))'
end
+
end
end
diff --git a/test/personas_test.rb b/test/personas_test.rb
index a777f58..463630d 100644
--- a/test/personas_test.rb
+++ b/test/personas_test.rb
@@ -26,72 +26,74 @@ def setup
def test_html_index_has_layout_template
get "/personas"
- assert{ last_response.body =~ /Vanna Test/}
+ assert ( last_response.body =~ /Vanna Test/)
end
def test_html_index_renders_layout_data_content
get "/personas"
- assert{ last_response.body =~/Nav bar here/}
+ assert ( last_response.body =~/Nav bar here/)
end
def test_json_index_has_no_layout
header "Accept", 'application/json'
get "/personas"
- assert{ JSON(last_response.body).keys.sort == ["personas"]}
+ assert ( JSON(last_response.body).keys.sort == ["personas"])
end
def test_data_only_json_method
header "Accept", 'application/json'
get "/personas/friend_catchphrases?personas=Mystical%20Gondola"
- assert{ JSON(last_response.body) == ["You're gonna get punted!"] }
+ assert ( JSON(last_response.body) == ["You're gonna get punted!"] )
end
def test_data_only_method_does_not_render_html
get "/personas/friend_catchphrases?personas=Mystical%20Gondola"
- assert {last_response.body =~ /Vanna::InvalidDictionary/}
+ assert (last_response.body =~ /Vanna::InvalidDictionary/)
end
def test_controller_can_call_other_controller_methods
header "Accept", 'application/json'
get "/personas/show?persona=The%20Fire%20Eater"
- assert{ JSON(last_response.body)["friend_catchphrases"] == ["You're gonna get punted!"] }
+ assert ( JSON(last_response.body)["friend_catchphrases"] == ["You're gonna get punted!"] )
end
def test_show_template_is_rendered
get "/personas/show?persona=The%20Fire%20Eater"
- assert{last_response.body =~/div id=sidebar/}
+ assert (last_response.body =~/div id=sidebar/)
end
def test_html_redirects_on_post_success
post "/personas/create", @linda_params
- assert { last_response.status == 302 }
- assert { last_response.location == "/personas/#{@linda_params[:persona][:name]}"}
+ assert ( last_response.status == 302 )
+ assert ( last_response.location == "/personas/#{@linda_params[:persona][:name]}")
end
def test_json_renders_on_post_success
header "Accept", 'application/json'
post "/personas/create", @linda_params
- assert { last_response.status == 201 }
- assert { JSON(last_response.body) == {"url" => "/personas/#{@linda_params[:persona][:name]}"}}
+ assert ( last_response.status == 201 )
+ assert ( JSON(last_response.body) == {"url" => "/personas/#{@linda_params[:persona][:name]}"})
end
def test_html_redirects_on_post_failure
post "/personas/create", @bad_params
- assert { last_response.status == 302 }
- assert { last_response.location == "/"}
+ assert ( last_response.status == 302 )
+ assert ( last_response.location == "/")
end
def test_json_rejects_on_post_failure
header "Accept", 'application/json'
post "/personas/create", @bad_params
- assert { last_response.status == 422 }
- assert { JSON(last_response.body) == {"message" => "Could not create Persona."}}
+ assert ( last_response.status == 422 )
+ assert ( JSON(last_response.body) == {"message" => "Could not create Persona."})
end
def test_js_tag_renders
get "/personas"
- assert {last_response.body =~ /javascript/}
+ assert (last_response.body =~ /javascript/)
end
def test_css_tag_renders
get "/personas"
- assert {last_response.body =~ /stylesheets/}
+
+ assert last_response.status != 500 , "should not fail"
+ assert last_response.body =~ /stylesheets/, "does not contain stylesheets:\n" + last_response.body
end
end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 14d0d1a..0fbcd35 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -1,15 +1,36 @@
ENV["RAILS_ENV"] = "test"
$LOAD_PATH.unshift './test'
$LOAD_PATH.unshift './test/app/controllers'
-require 'config/application'
-require 'rails/test_help'
+ # for application_controller
+require 'rubygems'
+#gem 'minitest' # ensures you're using the gem, and not the built in MT
+#gem 'test-unit'
+#gem 'wrong'
+
+#require 'minitest'
+#require 'minitest/autorun'
+require 'test/unit'
+require 'rails'
+require 'bundler'
+
+
+#require 'rails/test_help'
require 'json'
-require 'wrong'
-require 'wrong/adapters/test_unit'
-require "wrong/message/string_comparison"
+#require 'wrong' #
+#require "wrong/message/string_comparison"
+#require 'wrong/adapters/test_unit' ##You are using MiniTest's compatibility layer, not the real Test::Unit.
+#require "action_controller/railtie"
+
require "rack/test"
-Wrong.config[:color] = true
-ActionPresenter::Application.initialize!
require 'application_controller'
-ApplicationController.append_view_path "test/app/views"
+
+require 'config/application'
+
+#Wrong.config[:color] = true
require 'pp'
+
+#pp ActionPresenter
+#pp ActionPresenter::Application
+ActionPresenter::Application.initialize!
+ApplicationController.append_view_path "test/app/views"
+
diff --git a/test/weapons_test.rb b/test/weapons_test.rb
index 09c50e7..5d78bf5 100644
--- a/test/weapons_test.rb
+++ b/test/weapons_test.rb
@@ -14,19 +14,21 @@ def app
def test_creation
header "Accept", 'application/json'
post "/weapons/create", {:power => 10, :punch => 32}
- assert { last_response.status == 201 }
- assert { JSON(last_response.body)["id"] == 1}
+ print "last_response.status " + last_response.status.to_s() + "\n"
+ print last_response.body + "\n"
+ assert ( last_response.status == 201 )
+ assert ( JSON(last_response.body)["id"] == 1)
end
def test_creation_redirect
post "/weapons/create", {:power => 10, :punch => 32}
- assert { last_response.status == 301 }
- assert { last_response.location == "/weapons/1" }
+ assert ( last_response.status == 301 )
+ assert ( last_response.location == "/weapons/1" )
end
def test_update_redirect
post "/weapons/update", {:weapon => {:id => 1, :power => 100}}
- assert { last_response.status == 301 }
- assert { last_response.location == "/weapons" }
+ assert ( last_response.status == 301 )
+ assert ( last_response.location == "/weapons" )
end
end
diff --git a/vanna.gemspec b/vanna.gemspec
index e07a923..61262c8 100644
--- a/vanna.gemspec
+++ b/vanna.gemspec
@@ -18,8 +18,10 @@ explicitly override the params hash so you can construct dictionaries from other
s.add_dependency "json"
s.add_dependency 'rails', '>=3.0.0'
+ s.add_dependency 'minitest', '>= 2.6.1'
s.add_development_dependency 'rack-test', '>= 0.5.6'
- s.add_development_dependency 'wrong', ">=0.5.0"
+ s.add_development_dependency 'test-unit'
+ s.add_development_dependency 'actionpack'
end