teaspoon 0.7.9 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +382 -260
  3. data/app/assets/javascripts/teaspoon-angular.js +108 -26241
  4. data/app/assets/javascripts/teaspoon-jasmine.js +103 -2642
  5. data/app/assets/javascripts/teaspoon-mocha.js +109 -5416
  6. data/app/assets/javascripts/teaspoon-qunit.js +107 -2255
  7. data/app/assets/javascripts/teaspoon-teaspoon.js +0 -1
  8. data/app/assets/javascripts/teaspoon/angular.coffee +3 -1
  9. data/app/assets/javascripts/teaspoon/base/hook.coffee +21 -0
  10. data/app/assets/javascripts/teaspoon/base/reporters/html.coffee +26 -14
  11. data/app/assets/javascripts/teaspoon/base/reporters/html/progress_view.coffee +1 -1
  12. data/app/assets/javascripts/teaspoon/base/reporters/html/template.coffee +3 -3
  13. data/app/assets/javascripts/teaspoon/base/teaspoon.coffee +10 -1
  14. data/app/assets/javascripts/teaspoon/jasmine.coffee +3 -1
  15. data/app/assets/javascripts/teaspoon/mocha.coffee +3 -1
  16. data/app/assets/javascripts/teaspoon/mocha/reporters/html.coffee +1 -1
  17. data/app/assets/javascripts/teaspoon/qunit.coffee +3 -1
  18. data/app/assets/javascripts/teaspoon/qunit/reporters/html.coffee +1 -1
  19. data/app/assets/javascripts/teaspoon/teaspoon.coffee +0 -1
  20. data/app/assets/stylesheets/teaspoon.css +12 -8
  21. data/app/controllers/teaspoon/suite_controller.rb +32 -0
  22. data/app/views/teaspoon/suite/_body.html.erb +0 -0
  23. data/app/views/teaspoon/suite/_boot.html.erb +4 -0
  24. data/app/views/teaspoon/suite/_boot_require_js.html.erb +19 -0
  25. data/app/views/teaspoon/{spec/suites.html.erb → suite/index.html.erb} +6 -7
  26. data/app/views/teaspoon/suite/show.html.erb +19 -0
  27. data/bin/teaspoon +1 -1
  28. data/config/routes.rb +14 -4
  29. data/lib/generators/teaspoon/install/POST_INSTALL +2 -2
  30. data/lib/generators/teaspoon/install/install_generator.rb +22 -11
  31. data/lib/generators/teaspoon/install/templates/_body.html.erb +0 -0
  32. data/lib/generators/teaspoon/install/templates/_boot.html.erb +4 -0
  33. data/lib/generators/teaspoon/install/templates/jasmine/env.rb +11 -0
  34. data/lib/generators/teaspoon/install/templates/jasmine/env_comments.rb +182 -0
  35. data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.coffee +8 -6
  36. data/lib/generators/teaspoon/install/templates/jasmine/spec_helper.js +8 -7
  37. data/lib/generators/teaspoon/install/templates/mocha/env.rb +11 -0
  38. data/lib/generators/teaspoon/install/templates/mocha/env_comments.rb +182 -0
  39. data/lib/generators/teaspoon/install/templates/mocha/spec_helper.coffee +13 -13
  40. data/lib/generators/teaspoon/install/templates/mocha/spec_helper.js +13 -13
  41. data/lib/generators/teaspoon/install/templates/qunit/env.rb +11 -0
  42. data/lib/generators/teaspoon/install/templates/qunit/env_comments.rb +182 -0
  43. data/lib/generators/teaspoon/install/templates/qunit/test_helper.coffee +6 -5
  44. data/lib/generators/teaspoon/install/templates/qunit/test_helper.js +6 -5
  45. data/lib/tasks/teaspoon.rake +9 -2
  46. data/lib/teaspoon.rb +4 -6
  47. data/lib/teaspoon/command_line.rb +116 -134
  48. data/lib/teaspoon/configuration.rb +144 -66
  49. data/lib/teaspoon/console.rb +70 -37
  50. data/lib/teaspoon/coverage.rb +42 -15
  51. data/lib/teaspoon/deprecated.rb +65 -0
  52. data/lib/teaspoon/drivers/base.rb +10 -0
  53. data/lib/teaspoon/drivers/phantomjs/runner.js +9 -11
  54. data/lib/teaspoon/drivers/phantomjs_driver.rb +21 -21
  55. data/lib/teaspoon/drivers/selenium_driver.rb +32 -13
  56. data/lib/teaspoon/engine.rb +32 -12
  57. data/lib/teaspoon/environment.rb +16 -12
  58. data/lib/teaspoon/exceptions.rb +41 -5
  59. data/lib/teaspoon/exporter.rb +52 -0
  60. data/lib/teaspoon/formatters/base.rb +171 -0
  61. data/lib/teaspoon/formatters/clean_formatter.rb +2 -4
  62. data/lib/teaspoon/formatters/documentation_formatter.rb +60 -0
  63. data/lib/teaspoon/formatters/dot_formatter.rb +12 -90
  64. data/lib/teaspoon/formatters/json_formatter.rb +36 -0
  65. data/lib/teaspoon/formatters/junit_formatter.rb +51 -32
  66. data/lib/teaspoon/formatters/modules/report_module.rb +76 -0
  67. data/lib/teaspoon/formatters/pride_formatter.rb +23 -27
  68. data/lib/teaspoon/formatters/snowday_formatter.rb +7 -11
  69. data/lib/teaspoon/formatters/swayze_or_oprah_formatter.rb +88 -64
  70. data/lib/teaspoon/formatters/tap_formatter.rb +18 -27
  71. data/lib/teaspoon/formatters/tap_y_formatter.rb +35 -45
  72. data/lib/teaspoon/formatters/teamcity_formatter.rb +69 -31
  73. data/lib/teaspoon/instrumentation.rb +33 -33
  74. data/lib/teaspoon/result.rb +2 -1
  75. data/lib/teaspoon/runner.rb +40 -28
  76. data/lib/teaspoon/server.rb +23 -25
  77. data/lib/teaspoon/suite.rb +52 -72
  78. data/lib/teaspoon/utility.rb +3 -14
  79. data/lib/teaspoon/version.rb +1 -1
  80. data/spec/dummy/app/assets/javascripts/integration/integration_spec.coffee +3 -0
  81. data/spec/dummy/app/assets/javascripts/integration/spec_helper.coffee +2 -0
  82. data/spec/dummy/config/application.rb +3 -0
  83. data/spec/features/console_reporter_spec.rb +48 -18
  84. data/spec/features/hooks_spec.rb +23 -41
  85. data/spec/features/html_reporter_spec.rb +38 -21
  86. data/spec/features/install_generator_spec.rb +34 -20
  87. data/spec/features/instrumentation_spec.rb +3 -2
  88. data/spec/fixtures/coverage.json +243 -0
  89. data/spec/javascripts/fixtures/_body.html.erb +1 -0
  90. data/spec/javascripts/jasmine_helper.coffee +1 -1
  91. data/spec/javascripts/teaspoon/base/fixture_spec.coffee +4 -4
  92. data/spec/javascripts/teaspoon/base/reporters/html_spec.coffee +9 -10
  93. data/spec/javascripts/teaspoon/mocha/reporters/html_mspec.coffee +0 -6
  94. data/spec/javascripts/teaspoon/phantomjs/runner_spec.coffee +5 -6
  95. data/spec/javascripts/turbolinks_helper.coffee +1 -1
  96. data/spec/spec_helper.rb +3 -4
  97. data/spec/teaspoon/command_line_spec.rb +139 -23
  98. data/spec/teaspoon/configuration_spec.rb +164 -46
  99. data/spec/teaspoon/console_spec.rb +142 -47
  100. data/spec/teaspoon/coverage_spec.rb +98 -28
  101. data/spec/teaspoon/drivers/base_spec.rb +5 -0
  102. data/spec/teaspoon/drivers/phantomjs_driver_spec.rb +32 -14
  103. data/spec/teaspoon/drivers/selenium_driver_spec.rb +32 -24
  104. data/spec/teaspoon/engine_spec.rb +8 -5
  105. data/spec/teaspoon/environment_spec.rb +56 -33
  106. data/spec/teaspoon/exceptions_spec.rb +57 -0
  107. data/spec/teaspoon/exporter_spec.rb +96 -0
  108. data/spec/teaspoon/formatters/base_spec.rb +259 -0
  109. data/spec/teaspoon/formatters/clean_formatter_spec.rb +37 -0
  110. data/spec/teaspoon/formatters/documentation_formatter_spec.rb +127 -0
  111. data/spec/teaspoon/formatters/dot_formatter_spec.rb +52 -56
  112. data/spec/teaspoon/formatters/json_formatter_spec.rb +77 -0
  113. data/spec/teaspoon/formatters/junit_formatter_spec.rb +72 -35
  114. data/spec/teaspoon/formatters/pride_formatter_spec.rb +37 -0
  115. data/spec/teaspoon/formatters/snowday_formatter_spec.rb +35 -0
  116. data/spec/teaspoon/formatters/tap_formatter_spec.rb +29 -81
  117. data/spec/teaspoon/formatters/tap_y_formatter_spec.rb +31 -141
  118. data/spec/teaspoon/formatters/teamcity_formatter_spec.rb +99 -42
  119. data/spec/teaspoon/instrumentation_spec.rb +44 -44
  120. data/spec/teaspoon/result_spec.rb +37 -0
  121. data/spec/teaspoon/runner_spec.rb +70 -59
  122. data/spec/teaspoon/server_spec.rb +34 -52
  123. data/spec/teaspoon/suite_spec.rb +42 -188
  124. data/spec/teaspoon_env.rb +39 -28
  125. data/vendor/assets/javascripts/{angular-scenario-1.0.5.js → angular/1.0.5.js} +0 -0
  126. data/vendor/assets/javascripts/{angular-scenario-1.0.5.MIT-LICENSE → angular/MIT-LICENSE} +0 -0
  127. data/vendor/assets/javascripts/{jasmine-1.3.1.js → jasmine/1.3.1.js} +0 -0
  128. data/vendor/assets/javascripts/jasmine/2.0.0.js +2412 -0
  129. data/vendor/assets/javascripts/{jasmine-1.3.1.MIT.LICENSE → jasmine/MIT.LICENSE} +0 -0
  130. data/vendor/assets/javascripts/{mocha-1.10.0.js → mocha/1.10.0.js} +1 -0
  131. data/vendor/assets/javascripts/mocha/1.17.1.js +5813 -0
  132. data/vendor/assets/javascripts/{mocha-1.10.1.MIT.LICENSE → mocha/MIT.LICENSE} +0 -0
  133. data/vendor/assets/javascripts/{qunit-1.12.0.js → qunit/1.12.0.js} +1 -1
  134. data/vendor/assets/javascripts/qunit/1.14.0.js +2288 -0
  135. data/vendor/assets/javascripts/{qunit-1.12.0.MIT.LICENSE → qunit/MIT.LICENSE} +0 -0
  136. data/vendor/assets/javascripts/support/chai.js +827 -385
  137. data/vendor/assets/javascripts/support/jasmine-jquery-1.7.0.js +720 -0
  138. data/vendor/assets/javascripts/support/jasmine-jquery-2.0.0.js +812 -0
  139. data/vendor/assets/javascripts/support/sinon-chai.js +17 -0
  140. data/vendor/assets/javascripts/support/sinon.js +1138 -643
  141. metadata +57 -36
  142. data/app/controllers/teaspoon/spec_controller.rb +0 -38
  143. data/app/helpers/teaspoon/spec_helper.rb +0 -36
  144. data/app/views/teaspoon/spec/_require_js.html.erb +0 -21
  145. data/app/views/teaspoon/spec/_standard.html.erb +0 -4
  146. data/app/views/teaspoon/spec/runner.html.erb +0 -19
  147. data/lib/generators/teaspoon/install/templates/env.rb +0 -38
  148. data/lib/generators/teaspoon/install/templates/jasmine/initializer.rb +0 -64
  149. data/lib/generators/teaspoon/install/templates/mocha/initializer.rb +0 -64
  150. data/lib/generators/teaspoon/install/templates/qunit/initializer.rb +0 -64
  151. data/lib/teaspoon/check_coverage.rb +0 -33
  152. data/lib/teaspoon/drivers/base_driver.rb +0 -10
  153. data/lib/teaspoon/exception_handling.rb +0 -18
  154. data/lib/teaspoon/formatters/base_formatter.rb +0 -63
  155. data/spec/dummy/config/initializers/teaspoon.rb +0 -41
  156. data/spec/teaspoon/check_coverage_spec.rb +0 -50
  157. data/spec/teaspoon/formatters/base_formatter_spec.rb +0 -45
  158. data/vendor/assets/javascripts/support/chai.MIT.LICENSE +0 -22
  159. data/vendor/assets/javascripts/support/expect.MIT.LICENSE +0 -22
  160. data/vendor/assets/javascripts/support/jasmine-jquery.MIT.LICENSE +0 -20
  161. data/vendor/assets/javascripts/support/jasmine-jquery.js +0 -659
  162. data/vendor/assets/javascripts/support/sinon-chai.MIT-ISH.LICENSE +0 -13
  163. data/vendor/assets/javascripts/support/sinon.BSD.LICENSE +0 -27
@@ -6,14 +6,12 @@ describe Teaspoon::Server do
6
6
 
7
7
  subject { Teaspoon::Server.new }
8
8
 
9
- before do
10
- Teaspoon::Server.any_instance.stub(find_available_port: 31337)
11
- STDOUT.stub(:print)
12
- end
13
-
14
9
  describe "#start" do
15
10
 
11
+ let(:server) { double(start: nil) }
12
+
16
13
  before do
14
+ Thread.stub(:new) { |&b| @block = b; "_thread_" }
17
15
  subject.stub(wait_until_started: nil)
18
16
  end
19
17
 
@@ -23,10 +21,6 @@ describe Teaspoon::Server do
23
21
  end
24
22
 
25
23
  it "starts a rack server" do
26
- STDOUT.should_receive(:print).with("Starting the Teaspoon server...\n")
27
- server = double(start: nil)
28
- Thread.stub(:new) { |&b| @block = b }
29
-
30
24
  Rack::Server.should_receive(:new).and_return(server)
31
25
  server.should_receive(:start)
32
26
 
@@ -34,58 +28,49 @@ describe Teaspoon::Server do
34
28
  @block.call
35
29
  end
36
30
 
37
- it "rescues errors" do
38
- Thread.should_receive(:new).and_raise("OMG!")
39
- expect{ subject.start }.to raise_error("Cannot start server: OMG!")
31
+ it "waits until the server is started" do
32
+ Thread.should_receive(:new)
33
+ subject.should_receive(:wait_until_started).with("_thread_")
34
+ subject.start
40
35
  end
41
36
 
42
- describe "when the server configuration option is set" do
43
- before do
44
- Teaspoon.configuration.server = :cgi
45
- end
46
-
47
- after do
48
- Teaspoon.configuration.server = nil
49
- end
50
-
51
- it "creates a Rack::Server with the correct setting" do
52
- Thread.stub(:new) { |&b| @block = b }
53
-
54
- Rack::Server.should_receive(:new) do |options|
55
- options.should include(:server => :cgi)
56
- end.and_return(double(start: nil))
57
-
58
- subject.start
59
- @block.call
60
- end
37
+ it "rescues errors" do
38
+ Thread.should_receive(:new).and_raise("OMG!")
39
+ expect { subject.start }.to raise_error("Cannot start server: OMG!")
61
40
  end
62
- end
63
41
 
64
- describe "#wait_until_started" do
42
+ it "creates a Rack::Server with the correct setting" do
43
+ expected_opts = {
44
+ app: Rails.application,
45
+ Port: subject.port,
46
+ environment: "test",
47
+ AccessLog: [],
48
+ Logger: Rails.logger,
49
+ server: Teaspoon.configuration.server
50
+ }
51
+ Rack::Server.should_receive(:new).with(expected_opts).and_return(server)
65
52
 
66
- it "uses Timeout" do
67
- Timeout.should_receive(:timeout).with(20)
68
- subject.wait_until_started
53
+ subject.start
54
+ @block.call
69
55
  end
70
56
 
71
- it "handles Timeout::Error" do
72
- Timeout.should_receive(:timeout).and_raise(Timeout::Error)
73
- expect{ subject.wait_until_started }.to raise_error("Server failed to start. You may need to increase the timeout configuration.")
57
+ it "raises a ServerException if the timeout fails" do
58
+ subject.should_receive(:wait_until_started).and_call_original
59
+ Timeout.should_receive(:timeout).with(Teaspoon.configuration.server_timeout.to_i).and_raise(Timeout::Error)
60
+ expect{ subject.start }.to raise_error Teaspoon::ServerException
74
61
  end
75
62
 
76
63
  end
77
64
 
78
65
  describe "#responsive?" do
79
66
 
80
- before do
81
- subject.instance_variable_set(:@thread, double(join: nil))
82
- end
67
+ let(:socket) { double(close: nil) }
83
68
 
84
69
  it "checks a local port to see if a server is running" do
85
- socket = double(close: nil)
70
+ subject.port = 31337
86
71
  TCPSocket.should_receive(:new).with("127.0.0.1", 31337).and_return(socket)
87
72
  socket.should_receive(:close)
88
- subject.wait_until_started
73
+ subject.responsive?
89
74
  end
90
75
 
91
76
  end
@@ -93,23 +78,20 @@ describe Teaspoon::Server do
93
78
  describe "#url" do
94
79
 
95
80
  it "returns a url for the server that includes the port" do
81
+ subject.port = 31337
96
82
  expect(subject.url).to eq("http://127.0.0.1:31337")
97
83
  end
98
84
 
99
85
  end
100
86
 
101
- describe "#port" do
87
+ describe "integration" do
102
88
 
103
- it "returns the port the server is on" do
104
- expect(subject.port).to eq(31337)
89
+ before do
90
+ Teaspoon.configuration.stub(:suite_configs).and_return("foo" => {block: proc{}})
91
+ Teaspoon.configuration.stub(:suppress_log).and_return(true)
105
92
  end
106
93
 
107
- end
108
-
109
- describe "integration" do
110
-
111
94
  it "really starts a server" do
112
- Teaspoon.configuration.stub(:suites).and_return "foo" => proc{ |suite| }
113
95
  subject.start
114
96
  response = Net::HTTP.get_response(URI.parse("#{subject.url}/teaspoon/foo"))
115
97
  expect(response.code).to eq("200")
@@ -3,18 +3,22 @@ require "spec_helper"
3
3
  describe Teaspoon::Suite do
4
4
 
5
5
  before do
6
- Teaspoon.configuration.stub(:suites).and_return "default" => proc{}
6
+ Teaspoon.configuration.stub(:suite_configs).and_return("default" => {block: proc{}})
7
7
  end
8
8
 
9
9
  describe ".all" do
10
10
 
11
+ before do
12
+ Teaspoon::Suite.instance_variable_set(:@all, nil)
13
+ Teaspoon.configuration.stub(:suite_configs).and_return("default" => {block: proc{}}, "foo" => {block: proc{}})
14
+ end
15
+
11
16
  it "returns all the suites" do
12
- Teaspoon.configuration.stub(:suites).and_return "default" => proc{}, "foo" => proc{}
13
- results = Teaspoon::Suite.all
14
- expect(results.first).to be_a(Teaspoon::Suite)
15
- expect(results.length).to be(2)
16
- expect(results.first.name).to eq("default")
17
- expect(results.last.name).to eq("foo")
17
+ result = Teaspoon::Suite.all
18
+ expect(result.first).to be_a(Teaspoon::Suite)
19
+ expect(result.length).to be(2)
20
+ expect(result.first.name).to eq("default")
21
+ expect(result.last.name).to eq("foo")
18
22
  end
19
23
 
20
24
  end
@@ -22,16 +26,16 @@ describe Teaspoon::Suite do
22
26
  describe ".resolve_spec_for" do
23
27
 
24
28
  it "return a hash with the suite name and path" do
25
- results = Teaspoon::Suite.resolve_spec_for("fixture_spec")
26
- expect(results[:suite]).to eq("default")
27
- expect(results[:path].first).to include("base/fixture_spec.")
29
+ result = Teaspoon::Suite.resolve_spec_for("fixture_spec")
30
+ expect(result[:suite]).to eq("default")
31
+ expect(result[:path].first).to include("base/fixture_spec.")
28
32
  end
29
33
 
30
34
  it "returns a hash with the suite name and an array of paths if a directory is given" do
31
- results = Teaspoon::Suite.resolve_spec_for("base")
32
- expect(results[:suite]).to eq("default")
35
+ result = Teaspoon::Suite.resolve_spec_for("base")
36
+ expect(result[:suite]).to eq("default")
33
37
  dirs = ["base/fixture_spec.", "base/runner_spec.", "base/teaspoon_spec"]
34
- expect(dirs.all? { |path| results[:path].grep(/#{path}/)[0] }).to be_true
38
+ expect(dirs.all? { |path| result[:path].grep(/#{path}/)[0] }).to be_true
35
39
  end
36
40
 
37
41
  end
@@ -39,151 +43,61 @@ describe Teaspoon::Suite do
39
43
  describe "#initialize" do
40
44
 
41
45
  it "uses default suite configuration" do
46
+ expect(subject.name).to eq("default")
42
47
  expect(subject.config.helper).to eq("spec_helper")
43
48
  end
44
49
 
45
- it "accepts a suite configuration name" do
46
- Teaspoon.configuration.should_receive(:suites).and_return "test" => proc{ |s| s.helper = "helper_file" }
47
- subject = Teaspoon::Suite.new({suite: :test})
50
+ it "accepts a suite in the options" do
51
+ Teaspoon.configuration.should_receive(:suite_configs).and_return("test" => {block: proc{ |s| s.helper = "helper_file" }})
52
+ subject = Teaspoon::Suite.new(suite: :test)
53
+ expect(subject.name).to eql("test")
48
54
  expect(subject.config.helper).to eq("helper_file")
49
55
  end
50
56
 
51
57
  end
52
58
 
53
- describe "#name" do
54
-
55
- it "returns the name of the suite" do
56
- expect(subject.name).to eql("default")
57
- end
58
-
59
- end
60
-
61
- describe "#stylesheets" do
62
-
63
- it "returns an array of stylesheets" do
64
- expect(subject.stylesheets).to include("teaspoon")
65
- end
66
-
67
- end
68
-
69
- describe "#helper" do
70
-
71
- it "returns the javascript helper" do
72
- expect(subject.helper).to eq("spec_helper")
73
- end
74
-
75
- end
76
-
77
- describe "#javascripts" do
78
-
79
- it "returns an array of all javascripts" do
80
- results = subject.javascripts
81
- expect(results).to include("teaspoon-jasmine")
82
- expect(results).to include("spec_helper")
83
- end
84
-
85
- end
86
-
87
- describe "#core_javascripts" do
88
-
89
- it "returns an array of core javascripts" do
90
- results = subject.core_javascripts
91
- expect(results).to eql(["teaspoon-jasmine"])
92
- end
93
-
94
- end
95
-
96
- describe "#spec_javascripts" do
97
-
98
- it "returns an array of spec javascripts" do
99
- results = subject.spec_javascripts
100
- expect(results).to include("spec_helper")
101
- expect(results).to include("teaspoon/base/reporters/console_spec.js")
102
- end
103
-
104
- it "returns the file requested if one was passed" do
105
- subject = Teaspoon::Suite.new({file: "spec/javascripts/foo.js"})
106
- results = subject.spec_javascripts
107
- expect(results).to eql(["spec_helper", "foo.js"])
108
- end
109
-
110
- end
111
-
112
- describe "#spec_javascripts_for_require" do
113
-
114
- let(:files) { ['/path/file1.js.coffee', 'path/file2.coffee', 'file3.coffee.erb', 'file4.js.erb' ] }
115
-
116
- before do
117
- subject.should_receive(:specs).and_return(files)
118
- end
119
-
120
- it 'returns an array of spec javascripts without .js and Teaspoon prefix' do
121
- expect( subject.spec_javascripts_for_require ).to eq(['/path/file1', 'path/file2', 'file3', 'file4'])
122
- end
123
-
124
- end
125
-
126
- describe "#suites" do
127
-
128
- it "returns as hash with expected results" do
129
- expect(subject.suites).to eql({all: ["default"], active: "default"})
130
- end
131
-
132
- end
133
-
134
59
  describe "#spec_files" do
135
60
 
136
61
  it "returns an array of hashes with the filename and the asset name" do
137
62
  file = Teaspoon::Engine.root.join("spec/javascripts/teaspoon/base/reporters/console_spec.js").to_s
138
63
  subject.should_receive(:glob).and_return([file])
139
- expect(subject.spec_files[0]).to eql({path: file, name: "teaspoon/base/reporters/console_spec.js"})
64
+ expect(subject.spec_files[0]).to eql(path: file, name: "teaspoon/base/reporters/console_spec.js")
140
65
  end
141
66
 
142
- end
143
-
144
- describe "#link" do
145
-
146
- it "returns a link for the specific suite" do
147
- expect(subject.link).to eql("/teaspoon/default")
148
- end
149
-
150
- it "returns a link with added params" do
151
- expect(subject.link(file: ["file1", "file2"], grep: "foo")).to eql("/teaspoon/default/?file%5B%5D=file1&file%5B%5D=file2&grep=foo")
152
- end
153
-
154
- it "returns a link prefixed by app context if given" do
155
- Teaspoon.configuration.stub(:context).and_return('/foo')
156
- expect(subject.link).to eql("/foo/teaspoon/default")
67
+ it "raises an exception if the file isn't servable (in an asset path)" do
68
+ subject.should_receive(:glob).and_return(["/foo"])
69
+ expect { subject.spec_files[0] }.to raise_error Teaspoon::AssetNotServable
157
70
  end
158
71
 
159
72
  end
160
73
 
161
- describe "#instrument_file?" do
162
-
163
- before do
164
- Teaspoon.configuration.stub(:suites).and_return "default" => proc{ |s| s.no_coverage = ["file_", /some\/other/] }
165
- subject.stub(:include_spec?).and_return(false)
166
- end
74
+ describe "#spec_assets" do
167
75
 
168
- it "returns false if the file is a spec" do
169
- subject.should_receive(:include_spec?).with("_some/file_").and_return(true)
170
- expect(subject.instrument_file?("_some/file_")).to be(false)
76
+ it "returns an array of assets" do
77
+ result = subject.spec_assets
78
+ expect(result).to include("spec_helper.js?body=1")
79
+ expect(result).to include("teaspoon/base/reporters/console_spec.js?body=1")
171
80
  end
172
81
 
173
- it "returns false if the file should be ignored" do
174
- expect(subject.instrument_file?("_some/file_")).to be(false)
175
- expect(subject.instrument_file?("_some/other_file_")).to be(false)
82
+ it "returns just a file if one was requests" do
83
+ subject.instance_variable_set(:@options, file: "spec/javascripts/foo.js")
84
+ result = subject.spec_assets(false)
85
+ expect(result).to eql(["foo.js"])
176
86
  end
177
87
 
178
- it "returns true if it's a valid file that should get instrumented" do
179
- expect(subject.instrument_file?("_some/file_for_instrumenting_")).to be(true)
88
+ it "returns the asset tree (all dependencies resolved) if we want coverage" do
89
+ subject.instance_variable_set(:@options, coverage: true)
90
+ result = subject.spec_assets(true)
91
+ expect(result).to include("support/json2.js?body=1")
92
+ expect(result).to include("spec_helper.js?body=1")
93
+ expect(result).to include("drivers/phantomjs/runner.js?body=1&instrument=1")
180
94
  end
181
95
 
182
96
  end
183
97
 
184
98
  describe "#include_spec?" do
185
99
 
186
- it "returns true if the spec was found" do
100
+ it "returns true if the spec was found in the suite" do
187
101
  files = subject.send(:glob)
188
102
  expect(subject.include_spec?(files.first)).to eq(true)
189
103
  end
@@ -207,64 +121,4 @@ describe Teaspoon::Suite do
207
121
 
208
122
  end
209
123
 
210
- describe "#specs" do
211
-
212
- it "converts file names that are in registered asset paths into usable asset urls" do
213
- Teaspoon.configuration.should_receive(:suites).and_return "default" => proc{ |s| s.matcher = Teaspoon::Engine.root.join("spec/javascripts/support/*.*") }
214
- expect(subject.send(:specs)).to include("support/support.js")
215
- end
216
-
217
- it "raises an AssetNotServable exception if the file can't be served by sprockets" do
218
- Teaspoon.configuration.should_receive(:suites).and_return "default" => proc{ |s| s.matcher = __FILE__ }
219
- expect{ subject.send(:specs) }.to raise_error(Teaspoon::AssetNotServable, "#{__FILE__} is not within an asset path")
220
- end
221
-
222
- end
223
-
224
- describe "#asset_from_file" do
225
- before do
226
- Rails.application.config.assets.stub(paths: ["/Users/person/workspace/spec/javascripts"])
227
- end
228
-
229
- it "converts a file name into a usable asset url" do
230
- file = '/Users/person/workspace/spec/javascripts/support/support.js'
231
- expect(subject.send(:asset_from_file, file)).to eq('support/support.js')
232
- end
233
-
234
- context "when the file name has .js.coffee or .coffee extensions" do
235
- it "returns an asset url with a .js suffix" do
236
- coffee_file = '/Users/person/workspace/spec/javascripts/support/support.coffee'
237
- expect(subject.send(:asset_from_file, coffee_file)).to eq('support/support.js')
238
- jscoffee_file = '/Users/person/workspace/spec/javascripts/support/support.js.coffee'
239
- expect(subject.send(:asset_from_file, jscoffee_file)).to eq('support/support.js')
240
- end
241
- end
242
-
243
- context "when the file name contains regex special characters" do
244
- it "converts a file name into a usable asset url" do
245
- regex_file = '/Users/person/.$*?{}/spec/javascripts/support/support.js'
246
- Rails.application.config.assets.stub(paths: ["/Users/person/.$*?{}/spec/javascripts"])
247
- expect(subject.send(:asset_from_file, regex_file)).to eq('support/support.js')
248
- end
249
- end
250
- end
251
-
252
- describe "#run_hooks" do
253
- it "runs blocks added with hook" do
254
- first_value = nil; second_value = nil
255
-
256
- default_suite_config = proc do |suite|
257
- suite.hook(:before) { first_value = true }
258
- suite.hook(:before) { second_value = true }
259
- end
260
-
261
- Teaspoon.configuration.stub(:suites).and_return "default" => default_suite_config
262
-
263
- suite = Teaspoon::Suite.new({suite: :default})
264
- suite.run_hooks :before
265
-
266
- expect(first_value).to eql(true)
267
- expect(second_value).to eql(true)
268
- end
269
- end
270
124
  end
data/spec/teaspoon_env.rb CHANGED
@@ -1,33 +1,44 @@
1
- # This file allows you to override various Teaspoon configuration directives when running from the command line. It is not
2
- # required from within the Rails environment, so overriding directives that have been defined within the initializer
3
- # is not possible.
4
- #
5
- # Set RAILS_ROOT and load the environment.
6
- ENV["RAILS_ROOT"] = File.expand_path("../dummy", __FILE__)
7
- require File.expand_path("../dummy/config/environment", __FILE__)
1
+ # Set RAILS_ROOT and load the environment if it's not already loaded.
2
+ unless defined?(Rails)
3
+ ENV["RAILS_ROOT"] = File.expand_path("../dummy", __FILE__)
4
+ require File.expand_path("../dummy/config/environment", __FILE__)
5
+ end
6
+
7
+ Teaspoon.configure do |config|
8
+ config.root = Teaspoon::Engine.root
9
+ config.asset_paths << Teaspoon::Engine.root.join('lib/teaspoon')
10
+
11
+ config.suite do |suite|
12
+ suite.matcher = "{spec/javascripts,spec/dummy/app/assets/javascripts/specs}/**/*_spec.{js,js.coffee,coffee,js.coffee.erb}"
13
+ suite.javascripts = ["jasmine/1.3.1", "teaspoon/jasmine"]
14
+ end
15
+
16
+ config.suite :jasmine do |suite|
17
+ suite.matcher = "spec/javascripts/**/*_jspec.{js,js.coffee,coffee}"
18
+ suite.helper = "jasmine_helper"
19
+ suite.body_partial = "/body"
20
+ end
8
21
 
9
- # Provide default configuration.
10
- #
11
- # You can override various configuration directives defined here by using arguments with the teaspoon command.
12
- #
13
- # teaspoon --driver=selenium --suppress-log
14
- # rake teaspoon DRIVER=selenium SUPPRESS_LOG=false
15
- Teaspoon.setup do |config|
16
- # Driver
17
- #config.driver = "phantomjs" # available: phantomjs, selenium
22
+ config.suite :mocha do |suite|
23
+ suite.matcher = "spec/javascripts/**/*_mspec.{js,js.coffee,coffee}"
24
+ suite.javascripts = ["mocha/1.17.1", "teaspoon/mocha"]
25
+ suite.helper = "mocha_helper"
26
+ end
18
27
 
19
- # Behaviors
20
- #config.server_timeout = 20 # timeout for starting the server
21
- #config.server_port = nil # defaults to any open port unless specified
22
- #config.fail_fast = true # abort after the first failing suite
28
+ config.suite :qunit do |suite|
29
+ suite.matcher = "test/javascripts/**/*_test.{js,js.coffee,coffee}"
30
+ suite.javascripts = ["qunit/1.14.0", "teaspoon/qunit"]
31
+ suite.helper = "qunit_helper"
32
+ end
23
33
 
24
- # Output
25
- #config.formatters = "dot" # available: dot, tap_y, swayze_or_oprah
26
- #config.suppress_log = false # suppress logs coming from console[log/error/debug]
27
- #config.color = true
34
+ config.suite :angular do |suite|
35
+ suite.matcher = "spec/javascripts/**/*_aspec.{js,js.coffee,coffee}"
36
+ suite.javascripts = ["angular/1.0.5", "teaspoon/angular"]
37
+ suite.helper = "angular_helper"
38
+ end
28
39
 
29
- # Coverage (requires istanbul -- https://github.com/gotwarlost/istanbul)
30
- #config.coverage = true
31
- #config.coverage_reports = "text-summary,text,html,cobertura"
32
- #config.coverage_output_dir = "coverage"
40
+ #config.suite :integration do |suite|
41
+ # suite.matcher = "spec/dummy/app/assets/javascripts/integration/*_spec.{js,js.coffee,coffee}"
42
+ # suite.helper = nil
43
+ #end
33
44
  end