diff --git a/.gitignore b/.gitignore index 420aafa..f301dd4 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ jhw-test .jhw-cache/ _site/ jhw.*.html +coverage/ diff --git a/Gemfile b/Gemfile index 4896aec..59c357c 100644 --- a/Gemfile +++ b/Gemfile @@ -17,3 +17,5 @@ gem 'facter' gem 'jquery-rails' gem 'ejs' + +gem 'simplecov' diff --git a/lib/digest/jasmine_test.rb b/lib/digest/jasmine_test.rb new file mode 100644 index 0000000..f29e207 --- /dev/null +++ b/lib/digest/jasmine_test.rb @@ -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 + diff --git a/lib/jasmine-headless-webkit.rb b/lib/jasmine-headless-webkit.rb index 556c370..a99ab37 100644 --- a/lib/jasmine-headless-webkit.rb +++ b/lib/jasmine-headless-webkit.rb @@ -1,3 +1,7 @@ require 'jasmine/headless' require 'jasmine/headless/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3 +module Digest + autoload :JasmineTest, 'digest/jasmine_test' +end + diff --git a/lib/jasmine/headless/files_list.rb b/lib/jasmine/headless/files_list.rb index 37bc782..f533218 100644 --- a/lib/jasmine/headless/files_list.rb +++ b/lib/jasmine/headless/files_list.rb @@ -107,10 +107,6 @@ module Jasmine::Headless @sprockets_environment end - def path_searcher - @path_searcher ||= PathSearcher.new(self) - end - def has_spec_outside_scope? if is_outside_scope = !spec_filter.empty? is_outside_scope = spec_dir.any? do |dir| @@ -244,10 +240,6 @@ module Jasmine::Headless end end - def include_spec_file?(file) - spec_filter.empty? || spec_filter.include?(file) - end - def src_dir config_dir_or_pwd('src_dir') end diff --git a/lib/jasmine/headless/task.rb b/lib/jasmine/headless/task.rb index 78eec46..3368c6b 100644 --- a/lib/jasmine/headless/task.rb +++ b/lib/jasmine/headless/task.rb @@ -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 Headless class Task @@ -41,7 +21,6 @@ module Jasmine private def create_rails_compliant_task if Rails.respond_to?(:version) && Rails.version >= "3.1.0" - desc 'Force generate static assets without an MD5 hash, all assets end with -test.' task 'assets:precompile:for_testing' => :environment do $stderr.puts "This task is deprecated and will be removed after 2012-01-01" diff --git a/spec/lib/jasmine/headless/css_template_spec.rb b/spec/lib/jasmine/headless/css_template_spec.rb new file mode 100644 index 0000000..ca180e8 --- /dev/null +++ b/spec/lib/jasmine/headless/css_template_spec.rb @@ -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 == %{} } + end +end diff --git a/spec/lib/jasmine/headless/js_template_spec.rb b/spec/lib/jasmine/headless/js_template_spec.rb new file mode 100644 index 0000000..2f75b28 --- /dev/null +++ b/spec/lib/jasmine/headless/js_template_spec.rb @@ -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 == %{} } + end + + context 'jhw content' do + let(:data) { 'from="jhw"' } + + it { should == data } + end +end diff --git a/spec/lib/jasmine/headless/jst_template_spec.rb b/spec/lib/jasmine/headless/jst_template_spec.rb new file mode 100644 index 0000000..943a7e8 --- /dev/null +++ b/spec/lib/jasmine/headless/jst_template_spec.rb @@ -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(%{