pivotal-screw-unit-server 0.5.10 → 0.5.11

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,6 @@
1
+ 0.5.11
2
+ - Added ScrewUnit::Representations::Spec.project_js_files, .project_css_files, and .jquery_js_file.
3
+
1
4
  0.5.10
2
5
  - Updated to erector 0.6.7, which fixes a bug related to including modules into Representations.
3
6
 
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 5
4
- :patch: 10
4
+ :patch: 11
@@ -1,6 +1,13 @@
1
1
  module ScrewUnit
2
2
  module Representations
3
3
  class Spec < JsTestCore::Representations::Spec
4
+ class << self
5
+ def jquery_js_file
6
+ @jquery_js_file ||= "/core/jquery-1.3.2.js"
7
+ end
8
+ attr_writer :jquery_js_file
9
+ end
10
+
4
11
  needs :spec_files
5
12
  def title_text
6
13
  "Screw Unit suite"
@@ -100,14 +107,8 @@ module ScrewUnit
100
107
  script :src => "/core/screw.behaviors.js"
101
108
  end
102
109
 
103
- def project_js_files
104
- end
105
-
106
- def project_css_files
107
- end
108
-
109
110
  def jquery_js_file
110
- "/core/jquery-1.3.2.js"
111
+ self.class.jquery_js_file
111
112
  end
112
113
 
113
114
  def body_content
@@ -6,28 +6,64 @@ module JsTestCore
6
6
  describe SpecFile do
7
7
  describe "File" do
8
8
  describe "GET /specs/failing_spec" do
9
- attr_reader :html, :doc
10
- before do
11
- response = get(SpecFile.path("/failing_spec"))
12
- response.should be_http(
13
- 200,
14
- {},
15
- ""
16
- )
9
+ attr_reader :doc
17
10
 
18
- @doc = Nokogiri::HTML(response.body)
19
- end
11
+ context "when using the default .jquery_js_file" do
12
+ before do
13
+ ScrewUnit::Representations::Spec.project_js_files += ["/javascripts/test_file_1.js", "/javascripts/test_file_2.js"]
14
+ ScrewUnit::Representations::Spec.project_css_files += ["/stylesheets/test_file_1.css", "/stylesheets/test_file_2.css"]
20
15
 
21
- it "returns script tags for the test javascript file" do
22
- doc.at("script[@src='/specs/failing_spec.js']").should_not be_nil
16
+ response = get(SpecFile.path("/failing_spec"))
17
+ response.should be_http( 200, {}, "" )
18
+
19
+ @doc = Nokogiri::HTML(response.body)
20
+ end
21
+
22
+ after do
23
+ ScrewUnit::Representations::Spec.project_js_files.clear
24
+ ScrewUnit::Representations::Spec.project_css_files.clear
25
+ end
26
+
27
+ it "returns script tags for the test javascript file" do
28
+ doc.at("script[@src='/specs/failing_spec.js']").should_not be_nil
29
+ end
30
+
31
+ it "renders the screw unit template" do
32
+ doc.at("link[@href='/core/screw.css']").should_not be_nil
33
+ doc.at("script[@src='/core/screw.builder.js']").should_not be_nil
34
+ doc.at("script[@src='/core/screw.events.js']").should_not be_nil
35
+ doc.at("script[@src='/core/screw.behaviors.js']").should_not be_nil
36
+ doc.at("body/#screw_unit_content").should_not be_nil
37
+ end
38
+
39
+ it "renders project js files" do
40
+ doc.at("script[@src='/javascripts/test_file_1.js']").should_not be_nil
41
+ doc.at("script[@src='/javascripts/test_file_2.js']").should_not be_nil
42
+ end
43
+
44
+ it "renders project css files" do
45
+ doc.at("link[@href='/stylesheets/test_file_1.css']").should_not be_nil
46
+ doc.at("link[@href='/stylesheets/test_file_2.css']").should_not be_nil
47
+ end
23
48
  end
24
49
 
25
- it "returns the screw unit template" do
26
- doc.at("link[@href='/core/screw.css']").should_not be_nil
27
- doc.at("script[@src='/core/screw.builder.js']").should_not be_nil
28
- doc.at("script[@src='/core/screw.events.js']").should_not be_nil
29
- doc.at("script[@src='/core/screw.behaviors.js']").should_not be_nil
30
- doc.at("body/#screw_unit_content").should_not be_nil
50
+ context "when using a custom .jquery_js_file" do
51
+ attr_reader :default_jquery_js_file
52
+ before do
53
+ @default_jquery_js_file = ScrewUnit::Representations::Spec.jquery_js_file
54
+ ScrewUnit::Representations::Spec.jquery_js_file = "/javascripts/jquery-6.6.6.js"
55
+ default_jquery_js_file.should_not == ScrewUnit::Representations::Spec.jquery_js_file
56
+
57
+ response = get(SpecFile.path("/failing_spec"))
58
+ response.should be_http( 200, {}, "" )
59
+
60
+ @doc = Nokogiri::HTML(response.body)
61
+ end
62
+
63
+ it "renders the custom jquery file" do
64
+ doc.at("script[@src='/javascripts/jquery-6.6.6.js']").should_not be_nil
65
+ doc.at("script[@src='#{default_jquery_js_file}']").should be_nil
66
+ end
31
67
  end
32
68
  end
33
69
  end
@@ -1,3 +1,4 @@
1
+ - Added JsTestCore::Representations::Spec.project_js_files and .project_css_files
1
2
  - Updated to erector 0.6.7, which fixes a bug related to including modules into Representations.
2
3
  - Allow test suite to clear all cookies
3
4
  - No longer using the /implementanions directory. Replace all cases of /implementations with /javascripts.
@@ -1,6 +1,18 @@
1
1
  module JsTestCore
2
2
  module Representations
3
3
  class Spec < Page
4
+ class << self
5
+ def project_js_files
6
+ @project_js_files ||= []
7
+ end
8
+ attr_writer :project_js_files
9
+
10
+ def project_css_files
11
+ @project_css_files ||= []
12
+ end
13
+ attr_writer :project_css_files
14
+ end
15
+
4
16
  needs :spec_files, :session_id
5
17
  protected
6
18
  def title_text
@@ -8,6 +20,8 @@ module JsTestCore
8
20
  end
9
21
 
10
22
  def head_content
23
+ project_js_files
24
+ project_css_files
11
25
  spec_script_elements
12
26
  end
13
27
 
@@ -21,6 +35,18 @@ module JsTestCore
21
35
  def script_to_set_window_session_id
22
36
  script "window._session_id = '#{session_id}';", :type => "text/javascript"
23
37
  end
38
+
39
+ def project_js_files
40
+ self.class.project_js_files.each do |file|
41
+ script :src => file, :type => "text/javascript"
42
+ end
43
+ end
44
+
45
+ def project_css_files
46
+ self.class.project_css_files.each do |file|
47
+ link :href => file, :type => "text/css", :media => "screen", :rel => "stylesheet"
48
+ end
49
+ end
24
50
 
25
51
  def body_content
26
52
  end
@@ -3,6 +3,34 @@ require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
3
3
  module JsTestCore
4
4
  module Resources
5
5
  describe SpecFile do
6
+ describe "Configuration" do
7
+ attr_reader :doc
8
+ before do
9
+ JsTestCore::Representations::Spec.project_js_files += ["/javascripts/test_file_1.js", "/javascripts/test_file_2.js"]
10
+ JsTestCore::Representations::Spec.project_css_files += ["/stylesheets/test_file_1.css", "/stylesheets/test_file_2.css"]
11
+
12
+ response = get(SpecFile.path("/failing_spec"))
13
+ response.should be_http( 200, {}, "" )
14
+
15
+ @doc = Nokogiri::HTML(response.body)
16
+ end
17
+
18
+ after do
19
+ JsTestCore::Representations::Spec.project_js_files.clear
20
+ JsTestCore::Representations::Spec.project_css_files.clear
21
+ end
22
+
23
+ it "renders project js files" do
24
+ doc.at("script[@src='/javascripts/test_file_1.js']").should_not be_nil
25
+ doc.at("script[@src='/javascripts/test_file_2.js']").should_not be_nil
26
+ end
27
+
28
+ it "renders project css files" do
29
+ doc.at("link[@href='/stylesheets/test_file_1.css']").should_not be_nil
30
+ doc.at("link[@href='/stylesheets/test_file_2.css']").should_not be_nil
31
+ end
32
+ end
33
+
6
34
  describe "Files" do
7
35
  describe "GET /specs/failing_spec" do
8
36
  it "renders a suite only for failing_spec.js as text/html" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pivotal-screw-unit-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.10
4
+ version: 0.5.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pivotal Labs