Skip to content
This repository
Browse code

Complete Config renaming

- Files, locals for RunnerConfig, Config renamed
  • Loading branch information...
commit c5d39ff4d2c225f817df0add3361df0645a003ef 1 parent 196607e
Rajan Agaskar authored July 12, 2012
2  lib/jasmine.rb
... ...
@@ -1,7 +1,7 @@
1 1
 jasmine_files = ['base',
2 2
                  'dependencies',
  3
+                 'runner_config',
3 4
                  'config',
4  
-                 'user_config',
5 5
                  'server',
6 6
                  'selenium_driver',
7 7
                  'spec_builder',
104  lib/jasmine/config.rb
... ...
@@ -1,47 +1,109 @@
1 1
 module Jasmine
2  
-  class RunnerConfig
3  
-    def initialize(user_config)
4  
-      @user_config = user_config
  2
+  class Config
  3
+    require 'yaml'
  4
+    require 'erb'
  5
+
  6
+    def match_files(dir, patterns)
  7
+      dir = File.expand_path(dir)
  8
+      negative, positive = patterns.partition {|pattern| /^!/ =~ pattern}
  9
+      chosen, negated = [positive, negative].collect do |patterns|
  10
+        patterns.collect do |pattern|
  11
+          matches = Dir.glob(File.join(dir, pattern.gsub(/^!/,'')))
  12
+          matches.empty? && !(pattern =~ /\*|^\!/) ? pattern : matches.collect {|f| f.sub("#{dir}/", "")}.sort
  13
+        end.flatten.uniq
  14
+      end
  15
+      chosen - negated
5 16
     end
6 17
 
7  
-    def css_files
8  
-      @user_config.jasmine_stylesheets + @user_config.user_stylesheets
  18
+    def simple_config
  19
+      config = File.exist?(simple_config_file) ? YAML::load(ERB.new(File.read(simple_config_file)).result(binding)) : false
  20
+      config || {}
9 21
     end
10 22
 
11  
-    def jasmine_files
12  
-      @user_config.jasmine_javascripts
  23
+
  24
+    def spec_path
  25
+      "/__spec__"
13 26
     end
14 27
 
15  
-    def js_files
16  
-      @user_config.js_files
  28
+    def root_path
  29
+      "/__root__"
17 30
     end
18 31
 
19  
-    def spec_files
20  
-      @user_config.spec_files
  32
+    def js_files(spec_filter = nil)
  33
+      spec_files_to_include = spec_filter.nil? ? spec_files : match_files(spec_dir, [spec_filter])
  34
+      src_files.collect {|f| "/" + f } + helpers.collect {|f| File.join(spec_path, f) } + spec_files_to_include.collect {|f| File.join(spec_path, f) }
  35
+    end
  36
+
  37
+    def user_stylesheets
  38
+      stylesheets.collect {|f| "/" + f }
21 39
     end
22 40
 
23 41
     def spec_files_full_paths
24  
-      @user_config.spec_files_full_paths
  42
+      spec_files.collect {|spec_file| File.join(spec_dir, spec_file) }
25 43
     end
26 44
 
27  
-    def spec_path
28  
-      @user_config.spec_path
  45
+    def project_root
  46
+      Dir.pwd
29 47
     end
30 48
 
31  
-    def spec_dir
32  
-      @user_config.spec_dir
  49
+    def simple_config_file
  50
+      File.join(project_root, 'spec/javascripts/support/jasmine.yml')
33 51
     end
34 52
 
35 53
     def src_dir
36  
-      @user_config.src_dir
  54
+      if simple_config['src_dir']
  55
+        File.join(project_root, simple_config['src_dir'])
  56
+      else
  57
+        project_root
  58
+      end
37 59
     end
38 60
 
39  
-    def project_root
40  
-      @user_config.project_root
  61
+    def spec_dir
  62
+      if simple_config['spec_dir']
  63
+        File.join(project_root, simple_config['spec_dir'])
  64
+      else
  65
+        File.join(project_root, 'spec/javascripts')
  66
+      end
41 67
     end
42 68
 
43  
-    def root_path
44  
-      @user_config.root_path
  69
+    def helpers
  70
+      if simple_config['helpers']
  71
+        match_files(spec_dir, simple_config['helpers'])
  72
+      else
  73
+        match_files(spec_dir, ["helpers/**/*.js"])
  74
+      end
  75
+    end
  76
+
  77
+    def src_files
  78
+      if simple_config['src_files']
  79
+        match_files(src_dir, simple_config['src_files'])
  80
+      else
  81
+        []
  82
+      end
  83
+    end
  84
+
  85
+    def spec_files
  86
+      if simple_config['spec_files']
  87
+        match_files(spec_dir, simple_config['spec_files'])
  88
+      else
  89
+        match_files(spec_dir, ["**/*[sS]pec.js"])
  90
+      end
  91
+    end
  92
+
  93
+    def stylesheets
  94
+      if simple_config['stylesheets']
  95
+        match_files(src_dir, simple_config['stylesheets'])
  96
+      else
  97
+        []
  98
+      end
  99
+    end
  100
+
  101
+    def jasmine_stylesheets
  102
+      ::Jasmine::Core.css_files.map {|f| "/__JASMINE_ROOT__/#{f}"}
  103
+    end
  104
+
  105
+    def jasmine_javascripts
  106
+      ::Jasmine::Core.js_files.map {|f| "/__JASMINE_ROOT__/#{f}" }
45 107
     end
46 108
   end
47 109
 end
4  lib/jasmine/runner.rb
@@ -10,8 +10,8 @@
10 10
   require 'spec'
11 11
 end
12 12
 
13  
-jasmine_config = Jasmine::RunnerConfig.new(Jasmine::Config.new)
14  
-spec_builder = Jasmine::SpecBuilder.new(jasmine_config)
  13
+jasmine_runner_config = Jasmine::RunnerConfig.new(Jasmine::Config.new)
  14
+spec_builder = Jasmine::SpecBuilder.new(jasmine_runner_config)
15 15
 
16 16
 should_stop = false
17 17
 
47  lib/jasmine/runner_config.rb
... ...
@@ -0,0 +1,47 @@
  1
+module Jasmine
  2
+  class RunnerConfig
  3
+    def initialize(config)
  4
+      @config = config
  5
+    end
  6
+
  7
+    def css_files
  8
+      @config.jasmine_stylesheets + @config.user_stylesheets
  9
+    end
  10
+
  11
+    def jasmine_files
  12
+      @config.jasmine_javascripts
  13
+    end
  14
+
  15
+    def js_files
  16
+      @config.js_files
  17
+    end
  18
+
  19
+    def spec_files
  20
+      @config.spec_files
  21
+    end
  22
+
  23
+    def spec_files_full_paths
  24
+      @config.spec_files_full_paths
  25
+    end
  26
+
  27
+    def spec_path
  28
+      @config.spec_path
  29
+    end
  30
+
  31
+    def spec_dir
  32
+      @config.spec_dir
  33
+    end
  34
+
  35
+    def src_dir
  36
+      @config.src_dir
  37
+    end
  38
+
  39
+    def project_root
  40
+      @config.project_root
  41
+    end
  42
+
  43
+    def root_path
  44
+      @config.root_path
  45
+    end
  46
+  end
  47
+end
14  lib/jasmine/server.rb
@@ -8,8 +8,8 @@
8 8
 require 'ostruct'
9 9
 
10 10
 module Jasmine
11  
-  def self.app(config)
12  
-    page = Jasmine::Page.new(config)
  11
+  def self.app(runner_config)
  12
+    page = Jasmine::Page.new(runner_config)
13 13
     Rack::Builder.app do
14 14
       use Rack::Head
15 15
       use Rack::Jasmine::CacheControl
@@ -20,16 +20,16 @@ def self.app(config)
20 20
       end
21 21
 
22 22
       map('/run.html')         { run Rack::Jasmine::Redirect.new('/') }
23  
-      map('/__suite__')        { run Rack::Jasmine::FocusedSuite.new(config) }
  23
+      map('/__suite__')        { run Rack::Jasmine::FocusedSuite.new(runner_config) }
24 24
 
25  
-      #TODO: These path mappings should come from the config.
  25
+      #TODO: These path mappings should come from the runner_config.
26 26
       map('/__JASMINE_ROOT__') { run Rack::File.new(Jasmine::Core.path) }
27  
-      map(config.spec_path)    { run Rack::File.new(config.spec_dir) }
28  
-      map(config.root_path)    { run Rack::File.new(config.project_root) }
  27
+      map(runner_config.spec_path)    { run Rack::File.new(runner_config.spec_dir) }
  28
+      map(runner_config.root_path)    { run Rack::File.new(runner_config.project_root) }
29 29
 
30 30
       map('/') do
31 31
         run Rack::Cascade.new([
32  
-          Rack::URLMap.new('/' => Rack::File.new(config.src_dir)),
  32
+          Rack::URLMap.new('/' => Rack::File.new(runner_config.src_dir)),
33 33
           Rack::Jasmine::Runner.new(page)
34 34
         ])
35 35
       end
109  lib/jasmine/user_config.rb
... ...
@@ -1,109 +0,0 @@
1  
-module Jasmine
2  
-  class Config
3  
-    require 'yaml'
4  
-    require 'erb'
5  
-
6  
-    def match_files(dir, patterns)
7  
-      dir = File.expand_path(dir)
8  
-      negative, positive = patterns.partition {|pattern| /^!/ =~ pattern}
9  
-      chosen, negated = [positive, negative].collect do |patterns|
10  
-        patterns.collect do |pattern|
11  
-          matches = Dir.glob(File.join(dir, pattern.gsub(/^!/,'')))
12  
-          matches.empty? && !(pattern =~ /\*|^\!/) ? pattern : matches.collect {|f| f.sub("#{dir}/", "")}.sort
13  
-        end.flatten.uniq
14  
-      end
15  
-      chosen - negated
16  
-    end
17  
-
18  
-    def simple_config
19  
-      config = File.exist?(simple_config_file) ? YAML::load(ERB.new(File.read(simple_config_file)).result(binding)) : false
20  
-      config || {}
21  
-    end
22  
-
23  
-
24  
-    def spec_path
25  
-      "/__spec__"
26  
-    end
27  
-
28  
-    def root_path
29  
-      "/__root__"
30  
-    end
31  
-
32  
-    def js_files(spec_filter = nil)
33  
-      spec_files_to_include = spec_filter.nil? ? spec_files : match_files(spec_dir, [spec_filter])
34  
-      src_files.collect {|f| "/" + f } + helpers.collect {|f| File.join(spec_path, f) } + spec_files_to_include.collect {|f| File.join(spec_path, f) }
35  
-    end
36  
-
37  
-    def user_stylesheets
38  
-      stylesheets.collect {|f| "/" + f }
39  
-    end
40  
-
41  
-    def spec_files_full_paths
42  
-      spec_files.collect {|spec_file| File.join(spec_dir, spec_file) }
43  
-    end
44  
-
45  
-    def project_root
46  
-      Dir.pwd
47  
-    end
48  
-
49  
-    def simple_config_file
50  
-      File.join(project_root, 'spec/javascripts/support/jasmine.yml')
51  
-    end
52  
-
53  
-    def src_dir
54  
-      if simple_config['src_dir']
55  
-        File.join(project_root, simple_config['src_dir'])
56  
-      else
57  
-        project_root
58  
-      end
59  
-    end
60  
-
61  
-    def spec_dir
62  
-      if simple_config['spec_dir']
63  
-        File.join(project_root, simple_config['spec_dir'])
64  
-      else
65  
-        File.join(project_root, 'spec/javascripts')
66  
-      end
67  
-    end
68  
-
69  
-    def helpers
70  
-      if simple_config['helpers']
71  
-        match_files(spec_dir, simple_config['helpers'])
72  
-      else
73  
-        match_files(spec_dir, ["helpers/**/*.js"])
74  
-      end
75  
-    end
76  
-
77  
-    def src_files
78  
-      if simple_config['src_files']
79  
-        match_files(src_dir, simple_config['src_files'])
80  
-      else
81  
-        []
82  
-      end
83  
-    end
84  
-
85  
-    def spec_files
86  
-      if simple_config['spec_files']
87  
-        match_files(spec_dir, simple_config['spec_files'])
88  
-      else
89  
-        match_files(spec_dir, ["**/*[sS]pec.js"])
90  
-      end
91  
-    end
92  
-
93  
-    def stylesheets
94  
-      if simple_config['stylesheets']
95  
-        match_files(src_dir, simple_config['stylesheets'])
96  
-      else
97  
-        []
98  
-      end
99  
-    end
100  
-
101  
-    def jasmine_stylesheets
102  
-      ::Jasmine::Core.css_files.map {|f| "/__JASMINE_ROOT__/#{f}"}
103  
-    end
104  
-
105  
-    def jasmine_javascripts
106  
-      ::Jasmine::Core.js_files.map {|f| "/__JASMINE_ROOT__/#{f}" }
107  
-    end
108  
-  end
109  
-end
6  lib/rack/jasmine/focused_suite.rb
@@ -2,12 +2,12 @@ module Rack
2 2
   module Jasmine
3 3
 
4 4
     class FocusedSuite
5  
-      def initialize(config)
6  
-        @config = config
  5
+      def initialize(runner_config)
  6
+        @runner_config = runner_config
7 7
       end
8 8
 
9 9
       def call(env)
10  
-        run_adapter = Rack::Jasmine::RunAdapter.new(@config)
  10
+        run_adapter = Rack::Jasmine::RunAdapter.new(@runner_config)
11 11
         run_adapter.run(env["PATH_INFO"])
12 12
       end
13 13
     end
299  spec/config_spec.rb
... ...
@@ -1,86 +1,257 @@
1 1
 require 'spec_helper'
2 2
 require 'selenium-webdriver'
3 3
 
4  
-describe Jasmine::RunnerConfig do
5  
-  describe "css_files" do
6  
-    it "should return the jasmine stylesheets and any user defined stylesheets" do
7  
-      jasmine_stylesheets = ['some/css/file']
8  
-      user_stylesheets = ['some/user/file']
9  
-      user_config = double("config", :jasmine_stylesheets => jasmine_stylesheets, :user_stylesheets => user_stylesheets)
10  
-      Jasmine::RunnerConfig.new(user_config).css_files.should == jasmine_stylesheets + user_stylesheets
11  
-    end
12  
-  end
  4
+describe Jasmine::Config do
  5
+  describe "configuration" do
  6
+    before :each do
  7
+      temp_dir_before
13 8
 
14  
-  describe "jasmine_files" do
15  
-    it "should return the jasmine files from the config" do
16  
-      jasmine_files = ['some/file']
17  
-      user_config = double('config', :jasmine_javascripts => jasmine_files)
18  
-      Jasmine::RunnerConfig.new(user_config).jasmine_files.should == jasmine_files
19  
-    end
20  
-  end
  9
+      Dir::chdir @tmp
  10
+      dir_name = "test_js_project"
  11
+      `mkdir -p #{dir_name}`
  12
+      Dir::chdir dir_name
  13
+      `#{@root}/bin/jasmine init .`
21 14
 
22  
-  describe "js_files" do
23  
-    it "should return the user js files from the config" do
24  
-      js_files = ['some/file']
25  
-      user_config = double('config', :js_files => js_files)
26  
-      Jasmine::RunnerConfig.new(user_config).js_files.should == js_files
27  
-    end
28  
-  end
  15
+      @project_dir  = Dir.pwd
29 16
 
30  
-  describe "spec_files" do
31  
-    it "should return the user spec_files from the config" do
32  
-      spec_files = ['some/file']
33  
-      user_config = double('config', :spec_files => spec_files)
34  
-      Jasmine::RunnerConfig.new(user_config).spec_files.should == spec_files
  17
+      @template_dir = File.expand_path(File.join(@root, "generators/jasmine/templates"))
  18
+      @config       = Jasmine::Config.new
35 19
     end
36  
-  end
37 20
 
38  
-  describe "spec_files_full_paths" do
39  
-    it "should return the user spec_files_full_paths from the config" do
40  
-      spec_files_full_paths = ['some/file_path']
41  
-      user_config = double('config', :spec_files_full_paths => spec_files_full_paths)
42  
-      Jasmine::RunnerConfig.new(user_config).spec_files_full_paths.should == spec_files_full_paths
  21
+    after(:each) do
  22
+      temp_dir_after
43 23
     end
44  
-  end
45 24
 
46  
-  describe "spec_path" do
47  
-    it "should return the user spec_path from the config" do
48  
-      spec_path = ['some/path']
49  
-      user_config = double('config', :spec_path => spec_path)
50  
-      Jasmine::RunnerConfig.new(user_config).spec_path.should == spec_path
51  
-    end
52  
-  end
  25
+    describe "defaults" do
  26
+      it "src_dir uses root when src dir is blank" do
  27
+        @config.stub!(:project_root).and_return('some_project_root')
  28
+        @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml'))
  29
+        YAML.stub!(:load).and_return({'src_dir' => nil})
  30
+        @config.src_dir.should == 'some_project_root'
  31
+      end
53 32
 
54  
-  describe "spec_dir" do
55  
-    it "should return the user spec_dir from the config" do
56  
-      spec_dir = ['some/dir']
57  
-      user_config = double('config', :spec_dir => spec_dir)
58  
-      Jasmine::RunnerConfig.new(user_config).spec_dir.should == spec_dir
  33
+      it "should use correct default yaml config" do
  34
+        @config.stub!(:project_root).and_return('some_project_root')
  35
+        @config.simple_config_file.should == (File.join('some_project_root', 'spec/javascripts/support/jasmine.yml'))
  36
+      end
59 37
     end
60  
-  end
61 38
 
62  
-  describe "src_dir" do
63  
-    it "should return the user src_dir from the config" do
64  
-      src_dir = ['some/dir']
65  
-      user_config = double('config', :src_dir => src_dir)
66  
-      Jasmine::RunnerConfig.new(user_config).src_dir.should == src_dir
  39
+    describe "simple_config" do
  40
+      before(:each) do
  41
+        @config.stub!(:src_dir).and_return(File.join(@project_dir, "."))
  42
+        @config.stub!(:spec_dir).and_return(File.join(@project_dir, "spec/javascripts"))
  43
+      end
  44
+
  45
+      describe "using default jasmine.yml" do
  46
+        before(:each) do
  47
+          @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml'))
  48
+        end
  49
+
  50
+        it "should find the source files" do
  51
+          @config.src_files.should =~ ['public/javascripts/Player.js', 'public/javascripts/Song.js']
  52
+        end
  53
+
  54
+        it "should find the stylesheet files" do
  55
+          @config.stylesheets.should == []
  56
+        end
  57
+
  58
+        it "should find the spec files" do
  59
+          @config.spec_files.should == ['PlayerSpec.js']
  60
+        end
  61
+
  62
+        it "should find any helpers" do
  63
+          @config.helpers.should == ['helpers/SpecHelper.js']
  64
+        end
  65
+
  66
+        it "should build an array of all the JavaScript files to include, source files then spec files" do
  67
+          @config.js_files.should == [
  68
+                  '/public/javascripts/Player.js',
  69
+                  '/public/javascripts/Song.js',
  70
+                  '/__spec__/helpers/SpecHelper.js',
  71
+                  '/__spec__/PlayerSpec.js'
  72
+          ]
  73
+        end
  74
+
  75
+        it "should allow the js_files to be filtered" do
  76
+          @config.js_files("PlayerSpec.js").should == [
  77
+                  '/public/javascripts/Player.js',
  78
+                  '/public/javascripts/Song.js',
  79
+                  '/__spec__/helpers/SpecHelper.js',
  80
+                  '/__spec__/PlayerSpec.js'
  81
+          ]
  82
+        end
  83
+
  84
+        it "should report the full paths of the spec files" do
  85
+          @config.spec_files_full_paths.should == [File.join(@project_dir, 'spec/javascripts/PlayerSpec.js')]
  86
+        end
  87
+      end
  88
+
  89
+      it "should parse ERB" do
  90
+        @config.stub!(:simple_config_file).and_return(File.expand_path(File.join(@root, 'spec', 'fixture','jasmine.erb.yml')))
  91
+        Dir.stub!(:glob).and_return { |glob_string| [glob_string] }
  92
+        @config.src_files.should == ['file0.js', 'file1.js', 'file2.js',]
  93
+      end
  94
+
  95
+      describe "if jasmine.yml not found" do
  96
+        before(:each) do
  97
+          File.stub!(:exist?).and_return(false)
  98
+        end
  99
+
  100
+        it "should default to loading no source files" do
  101
+          @config.src_files.should be_empty
  102
+        end
  103
+
  104
+        it "should default to loading no stylesheet files" do
  105
+          @config.stylesheets.should be_empty
  106
+        end
  107
+
  108
+      end
  109
+
  110
+      describe "if jasmine.yml is empty" do
  111
+        before(:each) do
  112
+          @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml'))
  113
+          YAML.stub!(:load).and_return(false)
  114
+        end
  115
+
  116
+        it "should default to loading no source files" do
  117
+          @config.src_files.should be_empty
  118
+        end
  119
+
  120
+        it "should default to loading no stylesheet files" do
  121
+          @config.stylesheets.should be_empty
  122
+        end
  123
+      end
  124
+
  125
+      describe "should use the first appearance of duplicate filenames" do
  126
+        before(:each) do
  127
+          Dir.stub!(:glob).and_return { |glob_string| [glob_string] }
  128
+          fake_config = Hash.new.stub!(:[]).and_return { |x| ["file1.ext", "file2.ext", "file1.ext"] }
  129
+          @config.stub!(:simple_config).and_return(fake_config)
  130
+        end
  131
+
  132
+        it "src_files" do
  133
+          @config.src_files.should == ['file1.ext', 'file2.ext']
  134
+        end
  135
+
  136
+        it "stylesheets" do
  137
+          @config.stylesheets.should == ['file1.ext', 'file2.ext']
  138
+        end
  139
+
  140
+        it "spec_files" do
  141
+          @config.spec_files.should == ['file1.ext', 'file2.ext']
  142
+        end
  143
+
  144
+        it "helpers" do
  145
+          @config.spec_files.should == ['file1.ext', 'file2.ext']
  146
+        end
  147
+
  148
+        it "js_files" do
  149
+          @config.js_files.should == ["/file1.ext",
  150
+                                      "/file2.ext",
  151
+                                      "/__spec__/file1.ext",
  152
+                                      "/__spec__/file2.ext",
  153
+                                      "/__spec__/file1.ext",
  154
+                                      "/__spec__/file2.ext"]
  155
+        end
  156
+
  157
+        it "spec_files_full_paths" do
  158
+          @config.spec_files_full_paths.should == [
  159
+                  File.expand_path("spec/javascripts/file1.ext", @project_dir),
  160
+                  File.expand_path("spec/javascripts/file2.ext", @project_dir)
  161
+          ]
  162
+        end
  163
+      end
  164
+
  165
+      describe "should permit explicity-declared filenames to pass through regardless of their existence" do
  166
+        before(:each) do
  167
+          Dir.stub!(:glob).and_return { |glob_string| [] }
  168
+          fake_config = Hash.new.stub!(:[]).and_return { |x| ["file1.ext", "!file2.ext", "**/*file3.ext"] }
  169
+          @config.stub!(:simple_config).and_return(fake_config)
  170
+        end
  171
+
  172
+        it "should contain explicitly files" do
  173
+          @config.src_files.should == ["file1.ext"]
  174
+        end
  175
+      end
  176
+
  177
+      describe "should allow .gitignore style negation (!pattern)" do
  178
+        before(:each) do
  179
+          Dir.stub!(:glob).and_return { |glob_string| [glob_string] }
  180
+          fake_config = Hash.new.stub!(:[]).and_return { |x| ["file1.ext", "!file1.ext", "file2.ext"] }
  181
+          @config.stub!(:simple_config).and_return(fake_config)
  182
+        end
  183
+
  184
+        it "should not contain negated files" do
  185
+          @config.src_files.should == ["file2.ext"]
  186
+        end
  187
+      end
  188
+
  189
+      it "simple_config stylesheets" do
  190
+        @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml'))
  191
+
  192
+        YAML.stub!(:load).and_return({'stylesheets' => ['foo.css', 'bar.css']})
  193
+        Dir.stub!(:glob).and_return { |glob_string| [glob_string] }
  194
+
  195
+        @config.stylesheets.should == ['foo.css', 'bar.css']
  196
+      end
  197
+
  198
+      it "using rails jasmine.yml" do
  199
+        ['public/javascripts/prototype.js',
  200
+         'public/javascripts/effects.js',
  201
+         'public/javascripts/controls.js',
  202
+         'public/javascripts/dragdrop.js',
  203
+         'public/javascripts/application.js'].each { |f| `touch #{f}` }
  204
+
  205
+        @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine-rails.yml'))
  206
+
  207
+        @config.spec_files.should == ['PlayerSpec.js']
  208
+        @config.helpers.should == ['helpers/SpecHelper.js']
  209
+        @config.src_files.should == ['public/javascripts/prototype.js',
  210
+                                     'public/javascripts/effects.js',
  211
+                                     'public/javascripts/controls.js',
  212
+                                     'public/javascripts/dragdrop.js',
  213
+                                     'public/javascripts/application.js',
  214
+                                     'public/javascripts/Player.js',
  215
+                                     'public/javascripts/Song.js']
  216
+        @config.js_files.should == [
  217
+                '/public/javascripts/prototype.js',
  218
+                '/public/javascripts/effects.js',
  219
+                '/public/javascripts/controls.js',
  220
+                '/public/javascripts/dragdrop.js',
  221
+                '/public/javascripts/application.js',
  222
+                '/public/javascripts/Player.js',
  223
+                '/public/javascripts/Song.js',
  224
+                '/__spec__/helpers/SpecHelper.js',
  225
+                '/__spec__/PlayerSpec.js',
  226
+        ]
  227
+        @config.js_files("PlayerSpec.js").should == [
  228
+                '/public/javascripts/prototype.js',
  229
+                '/public/javascripts/effects.js',
  230
+                '/public/javascripts/controls.js',
  231
+                '/public/javascripts/dragdrop.js',
  232
+                '/public/javascripts/application.js',
  233
+                '/public/javascripts/Player.js',
  234
+                '/public/javascripts/Song.js',
  235
+                '/__spec__/helpers/SpecHelper.js',
  236
+                '/__spec__/PlayerSpec.js'
  237
+        ]
  238
+      end
67 239
     end
68 240
   end
69 241
 
70  
-  describe "project_root" do
71  
-    it "should return the user project_root from the config" do
72  
-      project_root = ['some/dir']
73  
-      user_config = double('config', :project_root => project_root)
74  
-      Jasmine::RunnerConfig.new(user_config).project_root.should == project_root
  242
+
  243
+  describe "jasmine_stylesheets" do
  244
+    it "should return the relative web server path to the core Jasmine css stylesheets" do
  245
+      #TODO: wrap Jasmine::Core with a class that knows about the core path and the relative mapping.
  246
+      Jasmine::Core.stub(:css_files).and_return(["my_css_file1.css", "my_css_file2.css"])
  247
+      Jasmine::Config.new.jasmine_stylesheets.should == ["/__JASMINE_ROOT__/my_css_file1.css", "/__JASMINE_ROOT__/my_css_file2.css"]
75 248
     end
76 249
   end
77 250
 
78  
-  describe "root_path" do
79  
-    it "should return the user root_path from the config" do
80  
-      root_path = ['some/path']
81  
-      user_config = double('config', :root_path => root_path)
82  
-      Jasmine::RunnerConfig.new(user_config).root_path.should == root_path
  251
+  describe "jasmine_javascripts" do
  252
+    it "should return the relative web server path to the core Jasmine css javascripts" do
  253
+      Jasmine::Core.stub(:js_files).and_return(["my_js_file1.js", "my_js_file2.js"])
  254
+      Jasmine::Config.new.jasmine_javascripts.should == ["/__JASMINE_ROOT__/my_js_file1.js", "/__JASMINE_ROOT__/my_js_file2.js"]
83 255
     end
84 256
   end
85  
-
86 257
 end
4  spec/jasmine_self_test_spec.rb
... ...
@@ -1,8 +1,8 @@
1 1
 require 'spec_helper'
2 2
 require 'jasmine_self_test_config'
3 3
 
4  
-jasmine_config = Jasmine::RunnerConfig.new(JasmineSelfTestConfig.new)
5  
-spec_builder = Jasmine::SpecBuilder.new(jasmine_config)
  4
+jasmine_runner_config = Jasmine::RunnerConfig.new(JasmineSelfTestConfig.new)
  5
+spec_builder = Jasmine::SpecBuilder.new(jasmine_runner_config)
6 6
 
7 7
 should_stop = false
8 8
 
0  spec/user_config_spec.rb → spec/runner_config_spec.rb
File renamed without changes
4  spec/server_spec.rb
@@ -6,7 +6,7 @@
6 6
 
7 7
   def app
8 8
     @root = File.join(File.dirname(__FILE__))
9  
-    config = double("config",
  9
+    runner_config = double("config",
10 10
                     :project_root => @root,
11 11
                     :spec_dir => File.join(@root, "fixture", "spec"),
12 12
                     :spec_path => "/__spec__",
@@ -17,7 +17,7 @@ def app
17 17
                     :src_dir => File.join(@root, "fixture", "src"),
18 18
                     :src_files => ["file1.js"],
19 19
                     :spec_files => ["example_spec.js"])
20  
-    Jasmine.app(config)
  20
+    Jasmine.app(runner_config)
21 21
   end
22 22
 
23 23
   it "includes no-cache headers for specs" do

0 notes on commit c5d39ff

Please sign in to comment.
Something went wrong with that request. Please try again.