1
0
Fork 0
mirror of https://github.com/drapergem/draper synced 2023-03-27 23:21:17 -04:00
This commit is contained in:
Jeff Casimir 2011-08-16 21:08:52 -07:00
commit a49907fb2c
5 changed files with 57 additions and 17 deletions

View file

@ -1,19 +1,47 @@
require 'bundler/gem_tasks' require 'bundler/gem_tasks'
require 'rake'
require 'rspec/core/rake_task'
namespace :cover_me do RCOV = RUBY_VERSION.to_f == 1.8
desc "Generates and opens code coverage report." namespace :spec do
task :report do
require 'cover_me' RSpec::Core::RakeTask.new(:coverage) do |t|
CoverMe.complete! t.pattern = 'spec/**/*_spec.rb'
if RCOV
t.rcov = true
t.rcov_opts = '--exclude osx\/objc,spec,gems\/'
end
end
RSpec::Core::RakeTask.new(:normal) do |t|
t.pattern ='spec/**/*_spec.rb'
t.rcov = false
end
namespace :coverage do
desc "Cleanup coverage data"
task :cleanup do
rm_rf 'coverage.data'
rm_rf 'coverage'
end
desc "Browse the code coverage report."
task :report => ["spec:coverage:cleanup", "spec:coverage"] do
if RCOV
require "launchy"
Launchy.open("coverage/index.html")
else
require 'cover_me'
CoverMe.complete!
end
end
end end
end end
task :test do desc "RSpec tests"
Rake::Task['cover_me:report'].invoke task "spec" => "spec:normal"
end
task :spec do task "default" => "spec"
Rake::Task['cover_me:report'].invoke
end

View file

@ -22,9 +22,15 @@ Gem::Specification.new do |s|
s.add_development_dependency "rspec", "~> 2.0.1" s.add_development_dependency "rspec", "~> 2.0.1"
s.add_development_dependency "activesupport", "~> 3.0.9" s.add_development_dependency "activesupport", "~> 3.0.9"
s.add_development_dependency "actionpack", "~> 3.0.9" s.add_development_dependency "actionpack", "~> 3.0.9"
s.add_development_dependency "ruby-debug19"
s.add_development_dependency "guard" s.add_development_dependency "guard"
s.add_development_dependency "guard-rspec" s.add_development_dependency "guard-rspec"
s.add_development_dependency "rb-fsevent" s.add_development_dependency "rb-fsevent"
s.add_development_dependency 'cover_me', '>= 1.0.0.rc6' if RUBY_VERSION.to_f == 1.8
s.add_development_dependency "ruby-debug"
s.add_development_dependency "rcov"
s.add_development_dependency "launchy"
else
s.add_development_dependency "ruby-debug19"
s.add_development_dependency 'cover_me', '>= 1.0.0.rc6'
end
end end

View file

@ -31,7 +31,7 @@ module Draper
def url_for(*args) def url_for(*args)
if args.last.is_a?(Hash) && !args.last[:only_path] if args.last.is_a?(Hash) && !args.last[:only_path]
args = args.dup args = args.dup
args << args.pop.merge(host: ActionMailer::Base.default_url_options[:host]) args << args.pop.merge('host' => ActionMailer::Base.default_url_options[:host])
end end
super(*args) super(*args)
end end

View file

@ -60,8 +60,8 @@ module Draper
private private
def select_methods def select_methods
specified = self.allowed || (model.public_methods - denied) specified = self.allowed || (model.public_methods.map{|s| s.to_sym} - denied.map{|s| s.to_sym})
(specified - self.public_methods) + FORCED_PROXY (specified - self.public_methods.map{|s| s.to_sym}) + FORCED_PROXY
end end
def build_methods def build_methods

View file

@ -1,6 +1,12 @@
require 'rubygems' require 'rubygems'
require 'bundler' require 'bundler'
require 'cover_me'
require 'rspec'
begin
require 'cover_me'
rescue LoadError
# Silently fail
end
require './spec/samples/application_helper.rb' require './spec/samples/application_helper.rb'
Bundler.require Bundler.require
Dir.glob('./spec/samples/*') {|file| require file} Dir.glob('./spec/samples/*') {|file| require file}