test coverage and cleanup in anticipation of merge

This commit is contained in:
John Bintz 2011-11-23 09:35:44 -05:00
parent 634f60ffe6
commit edf5a49f27
10 changed files with 109 additions and 29 deletions

1
.gitignore vendored
View File

@ -14,3 +14,4 @@ jhw-test
.jhw-cache/ .jhw-cache/
_site/ _site/
jhw.*.html jhw.*.html
coverage/

View File

@ -17,3 +17,5 @@ gem 'facter'
gem 'jquery-rails' gem 'jquery-rails'
gem 'ejs' gem 'ejs'
gem 'simplecov'

View File

@ -0,0 +1,20 @@
module Digest
class JasmineTest
def self.file(file)
new
end
def file(file)
self
end
def hexdigest
'test'
end
def update(prefix)
self
end
end
end

View File

@ -1,3 +1,7 @@
require 'jasmine/headless' require 'jasmine/headless'
require 'jasmine/headless/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3 require 'jasmine/headless/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
module Digest
autoload :JasmineTest, 'digest/jasmine_test'
end

View File

@ -107,10 +107,6 @@ module Jasmine::Headless
@sprockets_environment @sprockets_environment
end end
def path_searcher
@path_searcher ||= PathSearcher.new(self)
end
def has_spec_outside_scope? def has_spec_outside_scope?
if is_outside_scope = !spec_filter.empty? if is_outside_scope = !spec_filter.empty?
is_outside_scope = spec_dir.any? do |dir| is_outside_scope = spec_dir.any? do |dir|
@ -244,10 +240,6 @@ module Jasmine::Headless
end end
end end
def include_spec_file?(file)
spec_filter.empty? || spec_filter.include?(file)
end
def src_dir def src_dir
config_dir_or_pwd('src_dir') config_dir_or_pwd('src_dir')
end end

View File

@ -1,23 +1,3 @@
module Digest
class JasmineTest
def self.file(file)
new
end
def file(file)
self
end
def hexdigest
'test'
end
def update(prefix)
self
end
end
end
module Jasmine module Jasmine
module Headless module Headless
class Task class Task
@ -41,7 +21,6 @@ module Jasmine
private private
def create_rails_compliant_task def create_rails_compliant_task
if Rails.respond_to?(:version) && Rails.version >= "3.1.0" if Rails.respond_to?(:version) && Rails.version >= "3.1.0"
desc 'Force generate static assets without an MD5 hash, all assets end with -test.<ext>'
task 'assets:precompile:for_testing' => :environment do task 'assets:precompile:for_testing' => :environment do
$stderr.puts "This task is deprecated and will be removed after 2012-01-01" $stderr.puts "This task is deprecated and will be removed after 2012-01-01"

View File

@ -0,0 +1,25 @@
require 'spec_helper'
describe Jasmine::Headless::CSSTemplate do
include FakeFS::SpecHelpers
let(:template) { described_class.new(file) { data } }
let(:file) { 'file' }
let(:data) { 'data' }
subject { template.render }
before do
File.open(file, 'wb') if file
end
context "no file'" do
let(:file) { nil }
it { should == data }
end
context 'file' do
it { should == %{<link rel="stylesheet" href="#{file}" type="text/css" />} }
end
end

View File

@ -0,0 +1,31 @@
require 'spec_helper'
describe Jasmine::Headless::JSTemplate do
include FakeFS::SpecHelpers
let(:template) { described_class.new(file) { data } }
let(:file) { 'file' }
let(:data) { 'data' }
subject { template.render }
before do
File.open(file, 'wb') if file
end
context "no file'" do
let(:file) { nil }
it { should == data }
end
context 'file' do
it { should == %{<script type="text/javascript" src="#{file}"></script>} }
end
context 'jhw content' do
let(:data) { 'from="jhw"' }
it { should == data }
end
end

View File

@ -0,0 +1,21 @@
require 'spec_helper'
describe Jasmine::Headless::JSTTemplate do
include FakeFS::SpecHelpers
let(:template) { described_class.new(file) }
let(:file) { 'file' }
let(:data) { 'data' }
let(:context) { stub(:logical_path => 'path') }
before do
File.open(file, 'wb') { |fh| fh.print data }
end
subject { template.render(context) }
it { should include(%{<script type="text/javascript">}) }
it { should include(data) }
end

View File

@ -1,3 +1,8 @@
if ENV['COVERAGE']
require 'simplecov'
SimpleCov.start
end
require 'jasmine-headless-webkit' require 'jasmine-headless-webkit'
require 'fakefs/spec_helpers' require 'fakefs/spec_helpers'