Permalink
Browse files

+ Ruby 1.9 compatibility

  • Loading branch information...
1 parent 57a7099 commit 4e06e1837aae99ea3c39dc50320c75d1790e4f40 @floere committed Oct 5, 2010
View
@@ -1,4 +1,9 @@
-gem 'activesupport', '>=2.2.0'
+gem 'rake'
+gem 'rack', '1.1.0'
+gem 'rspec', :require => 'spec'
+gem 'actionpack', '<3.0.0'
+gem 'activesupport', '<3.0.0'
+gem 'padrino'
# group :padrino do
# gem 'padrino', '>=0.9.14'
View
@@ -3,11 +3,7 @@ def require_if task, name
end
require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
-
require 'spec/rake/spectask'
-require 'spec/rake/verify_rcov'
require_if :metrics, 'metric_fu'
@@ -23,35 +19,7 @@ task :'rails:spec' => [:'rails2:spec'] # TODO Add Rails 3 here
Spec::Rake::SpecTask.new(:spec) do |t|
t.spec_opts = %w{--colour --format progress --loadby mtime --reverse}
t.spec_files = Dir.glob("spec/#{framework}/**/*_spec.rb")
- t.warning = false
- end
-
- # run with rake rcov
- Spec::Rake::SpecTask.new(:rcov) do |t|
- t.spec_opts = %w{--colour --format progress --loadby mtime --reverse}
- t.spec_files = Dir.glob("spec/#{framework}/**/*_spec.rb")
- t.warning = false
- t.rcov = true
end
end
-end
-
-begin
- require 'jeweler'
- Jeweler::Tasks.new do |gemspec|
- gemspec.name = "view_models"
- gemspec.summary = "A model proxy for Rails views. Helps you keep the representation of a model and the model itself separate."
- gemspec.email = "florian.hanke@gmail.com"
- gemspec.homepage = "http://floere.github.com/view_models"
- gemspec.description = "For Padrino and Rails 2 views. Adds the missing R (Representation) to Rails' MVC. Provides simple proxy functionality for your models, thus helps you keep the model and view representation separate. Define focused helper methods on the (view) model, more quickly understood and more easily testable. Also: Hierarchical rendering for your hierarchical models. So, in a nutshell: Polymorphism not just in the model, but also in the view. Have fun!"
- gemspec.authors = ["Florian Hanke", "Kaspar Schiess", "Niko Dittmann", "Andreas Schacke"]
- gemspec.rdoc_options = ["--inline-source", "--charset=UTF-8"]
- gemspec.files = FileList["lib/*", "lib/{shared,padrino,rails2}/**/*"]
- gemspec.add_dependency 'activesupport', '>=2.2.0' # Padrino and Rails 2 omitted.
- gemspec.add_development_dependency 'rspec', '>=1.2.9'
- end
- Jeweler::GemcutterTasks.new
-rescue LoadError => e
- puts "Jeweler not available (#{e}). Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
end
@@ -88,7 +88,7 @@ def reader_definition_for attribute
# Combines left parentheses and filters.
#
def filtered_left_parentheses
- filters.zip(left_parentheses).to_s
+ filters.zip(left_parentheses).join
end
# Generates the needed amount of parentheses to match the left parentheses.
@@ -14,6 +14,7 @@ module Mapping
# Rails 2: context is either a view instance or a controller instance.
#
def view_model_for model, context = self
+ # p [:view_model_for, view_model_class_for(model)]
view_model_class_for(model).new model, context
end
@@ -1,12 +1,13 @@
-require File.join(File.dirname(__FILE__), '../spec_helper')
+dir = File.dirname __FILE__
+require File.expand_path '../spec_helper', dir
-require File.join(File.dirname(__FILE__), 'models/subclass')
-require File.join(File.dirname(__FILE__), 'models/sub_subclass')
+require File.expand_path 'models/subclass', dir
+require File.expand_path 'models/sub_subclass', dir
-require File.join(File.dirname(__FILE__), 'view_models/project')
-require File.join(File.dirname(__FILE__), 'view_models/subclass')
-require File.join(File.dirname(__FILE__), 'view_models/sub_subclass')
-require File.join(File.dirname(__FILE__), 'view_models/module_for_rendering')
+require File.expand_path 'view_models/project', dir
+require File.expand_path 'view_models/subclass', dir
+require File.expand_path 'view_models/sub_subclass', dir
+require File.expand_path 'view_models/module_for_rendering', dir
class TestApp < Padrino::Application
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '../../spec_helper')
+require File.expand_path '../../spec_helper', File.dirname(__FILE__)
describe ViewModels::Helpers::Mapping::Collection do
include ViewModels::Helpers::Mapping
@@ -5,4 +5,4 @@
# Load the init.
#
-require File.join(File.dirname(__FILE__), '/../../lib/padrino/init')
+require File.expand_path File.join(File.dirname(__FILE__), '/../../lib/padrino/init')
@@ -1,14 +1,14 @@
this = File.dirname(__FILE__)
-require File.join(this, '/../spec_helper')
+require File.expand_path File.join(this, '/../spec_helper')
-require File.join(this, 'models/subclass')
-require File.join(this, 'models/sub_subclass')
+require File.expand_path File.join(this, 'models/subclass')
+require File.expand_path File.join(this, 'models/sub_subclass')
-require File.join(this, 'view_models/project')
-require File.join(this, 'view_models/subclass')
-require File.join(this, 'view_models/sub_subclass')
-require File.join(this, 'view_models/module_for_rendering')
+require File.expand_path File.join(this, 'view_models/project')
+require File.expand_path File.join(this, 'view_models/subclass')
+require File.expand_path File.join(this, 'view_models/sub_subclass')
+require File.expand_path File.join(this, 'view_models/module_for_rendering')
require 'action_controller'
require 'action_controller/test_process'
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '/../../spec_helper')
+require File.expand_path File.join(File.dirname(__FILE__), '../../spec_helper')
describe ViewModels::Extensions::ActiveRecord do
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '/../../spec_helper')
+require File.expand_path File.join(File.dirname(__FILE__), '/../../spec_helper')
describe ViewModels::Extensions::ModelReader do
@@ -25,7 +25,7 @@ def b(s); s << 'b' end
@view_model.some_model_value.should == 's'
end
it "should call filters in a given pattern" do
- @view_model.class.model_reader [:some_model_value], :filter_through => [:a, :b, :a, :a]
+ @view_model.class.model_reader :some_model_value, :filter_through => [:a, :b, :a, :a]
@view_model.some_model_value.should == 'sabaa'
end
@@ -35,7 +35,7 @@ def b(s); s << 'b' end
lambda { @view_model.some_model_value }.should_not raise_error
end
it "should handle an array of readers" do
- @view_model.class.model_reader [:some_model_value, :some_other_model_value], :filter_through => :a
+ @view_model.class.model_reader :some_model_value, :some_other_model_value, :filter_through => :a
lambda { @view_model.some_model_value }.should_not raise_error
end
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '/../../spec_helper')
+require File.expand_path '../../spec_helper', File.dirname(__FILE__)
describe ViewModels::Helpers::Mapping::Collection do
include ViewModels::Helpers::Mapping
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '/../../spec_helper')
+require File.expand_path File.join(File.dirname(__FILE__), '/../../spec_helper')
describe ViewModels::Helpers::View do
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '/../../spec_helper')
+require File.expand_path File.join(File.dirname(__FILE__), '/../../spec_helper')
describe ViewModels::Base do
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '/../../spec_helper')
+require File.expand_path File.join(File.dirname(__FILE__), '/../../spec_helper')
describe ViewModels::View do
@@ -3,7 +3,7 @@
require 'spec'
require 'action_controller'
-require File.join(File.dirname(__FILE__), '/../../lib/rails2/init')
+require File.expand_path File.join(File.dirname(__FILE__), '/../../lib/rails2/init')
-require File.join(File.dirname(__FILE__), 'spec_helper_extensions')
+require File.expand_path 'spec_helper_extensions', File.dirname(__FILE__)
include SpecHelperExtensions
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '../../spec_helper')
+require File.expand_path '../../spec_helper', File.dirname(__FILE__)
describe ViewModels::Helpers::Mapping::Collection do
include ViewModels::Helpers::Mapping
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '../../spec_helper')
+require File.expand_path File.join(File.dirname(__FILE__), '../../spec_helper')
describe ViewModels::Helpers::Mapping do
include ViewModels::Helpers::Mapping
@@ -19,12 +19,10 @@ class ViewModels::SomeModelClazz < ViewModels::Base; end
it "should return an empty hash by default" do
specific_view_model_mapping.should == {}
end
- it "should raise an ArgumentError on an non-mapped model" do
+ it "should raise an ArgumentError on a mapped model" do
class SomeViewModelClass; end
specific_view_model_mapping[String] = SomeViewModelClass
- lambda {
- view_model_for("Some String")
- }.should raise_error(ArgumentError, "wrong number of arguments (2 for 0)")
+ view_model_for("Some String").should be_kind_of(SomeViewModelClass)
end
end
describe "no specific mapping" do
@@ -3,4 +3,4 @@
require 'active_support'
-require File.join(File.dirname(__FILE__), '/../../lib/shared/init')
+require File.expand_path File.join(File.dirname(__FILE__), '../../lib/shared/init')

0 comments on commit 4e06e18

Please sign in to comment.