pivotal-screw-unit 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +6 -0
- data/Rakefile +4 -1
- data/VERSION.yml +2 -2
- data/bin/screw_unit_server +14 -4
- data/lib/screw_unit/representations/spec.html.rb +1 -1
- data/lib/screw_unit/resources/core_file.rb +7 -0
- data/lib/screw_unit.rb +12 -8
- data/spec/functional/functional_spec_helper.rb +11 -4
- data/spec/functional/functional_spec_server_starter.rb +13 -8
- data/spec/unit/js_test_core/specs/spec_file_spec.rb +51 -18
- data/spec/unit/unit_spec_helper.rb +22 -90
- data/vendor/js-test-core/CHANGES +3 -0
- data/vendor/js-test-core/lib/js_test_core/app.rb +12 -0
- data/vendor/js-test-core/lib/js_test_core/client.rb +5 -5
- data/vendor/js-test-core/lib/js_test_core/configuration.rb +35 -0
- data/vendor/js-test-core/lib/js_test_core/{selenium → extensions/selenium}/client/driver.rb +0 -0
- data/vendor/js-test-core/lib/js_test_core/extensions.rb +1 -1
- data/vendor/js-test-core/lib/js_test_core/models/selenium_session.rb +80 -0
- data/vendor/js-test-core/lib/js_test_core/models.rb +8 -0
- data/vendor/js-test-core/lib/js_test_core/representations/dir.html.rb +24 -0
- data/vendor/js-test-core/{vendor/thin-rest/lib/thin_rest/representations/resource_not_found.html.rb → lib/js_test_core/representations/not_found.html.rb} +3 -7
- data/vendor/js-test-core/{vendor/thin-rest/lib/thin_rest → lib/js_test_core}/representations/page.html.rb +1 -1
- data/vendor/js-test-core/lib/js_test_core/representations/spec.html.rb +1 -1
- data/vendor/js-test-core/lib/js_test_core/representations.rb +4 -2
- data/vendor/js-test-core/lib/js_test_core/resources/core_file.rb +19 -0
- data/vendor/js-test-core/lib/js_test_core/resources/file.rb +38 -18
- data/vendor/js-test-core/lib/js_test_core/resources/implementations_deprecation.rb +12 -0
- data/vendor/js-test-core/lib/js_test_core/resources/not_found.rb +35 -0
- data/vendor/js-test-core/lib/js_test_core/resources/resource.rb +16 -0
- data/vendor/js-test-core/lib/js_test_core/resources/selenium_session.rb +104 -0
- data/vendor/js-test-core/lib/js_test_core/resources/spec_file.rb +63 -0
- data/vendor/js-test-core/lib/js_test_core/resources/web_root.rb +5 -60
- data/vendor/js-test-core/lib/js_test_core/resources.rb +7 -8
- data/vendor/js-test-core/lib/js_test_core.rb +18 -13
- data/vendor/js-test-core/{vendor/thin-rest/README → spec/example_core/subdir/SubDirFile.js} +0 -0
- data/vendor/js-test-core/spec/example_specs/custom_dir_and_suite/passing_spec.js +1 -1
- data/vendor/js-test-core/spec/example_specs/foo/failing_spec.js +1 -1
- data/vendor/js-test-core/spec/example_specs/foo/passing_spec.js +1 -1
- data/vendor/js-test-core/spec/spec_helpers/be_http.rb +32 -0
- data/vendor/js-test-core/spec/spec_helpers/example_group.rb +36 -0
- data/vendor/js-test-core/spec/spec_helpers/fake_selenium_driver.rb +27 -0
- data/vendor/js-test-core/spec/spec_helpers/show_test_exceptions.rb +22 -0
- data/vendor/js-test-core/spec/unit/js_test_core/client_spec.rb +6 -6
- data/vendor/js-test-core/spec/unit/js_test_core/configuration_spec.rb +44 -0
- data/vendor/js-test-core/spec/unit/js_test_core/models/selenium_session_spec.rb +85 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb +60 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/file_spec.rb +54 -63
- data/vendor/js-test-core/spec/unit/js_test_core/resources/implementations_deprecation_spec.rb +18 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/not_found_spec.rb +51 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/selenium_session_spec.rb +362 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/spec_file_spec.rb +120 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/web_root_spec.rb +15 -19
- data/vendor/js-test-core/spec/unit/unit_spec_helper.rb +14 -148
- data/vendor/js-test-core/vendor/lucky-luciano/README.markdown +7 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/resource.rb +135 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec/be_http.rb +32 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec.rb +4 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano.rb +4 -0
- data/vendor/js-test-core/vendor/lucky-luciano/spec/lucky_luciano/resource_spec.rb +231 -0
- data/vendor/js-test-core/vendor/lucky-luciano/spec/spec_helper.rb +48 -0
- data/vendor/js-test-core/vendor/{thin-rest → lucky-luciano}/spec/spec_suite.rb +1 -2
- metadata +74 -59
- data/spec/unit/js_test_core/specs/spec_dir_spec.rb +0 -39
- data/vendor/js-test-core/lib/js_test_core/rack/commonlogger.rb +0 -5
- data/vendor/js-test-core/lib/js_test_core/rack.rb +0 -2
- data/vendor/js-test-core/lib/js_test_core/rails_server.rb +0 -22
- data/vendor/js-test-core/lib/js_test_core/resources/dir.rb +0 -67
- data/vendor/js-test-core/lib/js_test_core/resources/runner.rb +0 -107
- data/vendor/js-test-core/lib/js_test_core/resources/session.rb +0 -44
- data/vendor/js-test-core/lib/js_test_core/resources/session_finish.rb +0 -17
- data/vendor/js-test-core/lib/js_test_core/resources/specs/spec.rb +0 -32
- data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_dir.rb +0 -50
- data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_file.rb +0 -21
- data/vendor/js-test-core/lib/js_test_core/selenium.rb +0 -2
- data/vendor/js-test-core/lib/js_test_core/server.rb +0 -50
- data/vendor/js-test-core/lib/js_test_core/thin/backends/js_test_core_server.rb +0 -9
- data/vendor/js-test-core/lib/js_test_core/thin/js_test_core_connection.rb +0 -8
- data/vendor/js-test-core/lib/js_test_core/thin.rb +0 -3
- data/vendor/js-test-core/spec/example_specs/custom_dir_and_suite.html +0 -9
- data/vendor/js-test-core/spec/unit/js_test_core/rails_server_spec.rb +0 -45
- data/vendor/js-test-core/spec/unit/js_test_core/resources/dir_spec.rb +0 -53
- data/vendor/js-test-core/spec/unit/js_test_core/resources/file_not_found_spec.rb +0 -16
- data/vendor/js-test-core/spec/unit/js_test_core/resources/runners/runner_spec.rb +0 -303
- data/vendor/js-test-core/spec/unit/js_test_core/resources/session_finish_spec.rb +0 -79
- data/vendor/js-test-core/spec/unit/js_test_core/resources/session_spec.rb +0 -82
- data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_dir_spec.rb +0 -104
- data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_file_spec.rb +0 -41
- data/vendor/js-test-core/spec/unit/js_test_core/server_spec.rb +0 -117
- data/vendor/js-test-core/spec/unit/thin/js_test_core_connection_spec.rb +0 -6
- data/vendor/js-test-core/vendor/thin-rest/CHANGES +0 -2
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/connection.rb +0 -117
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions/object.rb +0 -21
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions.rb +0 -3
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/representations/internal_error.html.rb +0 -20
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/representations.rb +0 -4
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/resources/internal_error.rb +0 -11
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/resources/resource.rb +0 -105
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/resources/resource_not_found.rb +0 -19
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/resources.rb +0 -4
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/routing_error.rb +0 -5
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest.rb +0 -10
- data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest/connection_spec.rb +0 -205
- data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest/resources/resource_not_found_spec.rb +0 -16
- data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest/resources/resource_spec.rb +0 -135
- data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest/resources/root_spec.rb +0 -16
- data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest_spec_helper.rb +0 -134
data/CHANGES
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
0.5.0
|
2
|
+
- Replaced thin-rest with Sinatra and Lucky Luciano as the server base.
|
3
|
+
- The Screw Unit Server is now Rake middleware.
|
4
|
+
- Sensible directory defaults for the screw_unit_server executable.
|
5
|
+
- Replaced /implementations with /javascripts, assuming you have a /javascripts directory in the application root.
|
6
|
+
|
1
7
|
0.4.0
|
2
8
|
- Added ScrewUnit::Representations::Spec#project_js_files and #project_css_files, which can be overridden, so the javascript include mechanism is not needed.
|
3
9
|
- Better error message when running using Selenium.
|
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ begin
|
|
6
6
|
s.summary = "Server and helpers for your Screw Unit tests."
|
7
7
|
s.email = "pivotallabsopensource@googlegroups.com"
|
8
8
|
s.homepage = "http://github.com/pivotal/screw-unit-server"
|
9
|
-
s.description = "The Screw Unit server conveniently serves your Screw Unit specs and
|
9
|
+
s.description = "The Screw Unit server conveniently serves your Screw Unit specs and javascript files and css stylesheets."
|
10
10
|
s.authors = ["Pivotal Labs", "Brian Takita"]
|
11
11
|
s.files = Dir["[A-Z]*"] +
|
12
12
|
Dir["*.rb"] +
|
@@ -18,6 +18,9 @@ begin
|
|
18
18
|
s.test_files = Dir['spec/**/*.rb']
|
19
19
|
s.rdoc_options = ["--main", "README.markdown"]
|
20
20
|
s.extra_rdoc_files = ["README.markdown", "CHANGES"]
|
21
|
+
s.add_dependency("thin", ">=1.2.1")
|
22
|
+
s.add_dependency("erector", ">=0.6.6")
|
23
|
+
s.add_dependency("selenium_client")
|
21
24
|
end
|
22
25
|
rescue LoadError
|
23
26
|
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
data/VERSION.yml
CHANGED
data/bin/screw_unit_server
CHANGED
@@ -3,8 +3,18 @@
|
|
3
3
|
dir = File.dirname(__FILE__)
|
4
4
|
$LOAD_PATH.unshift("#{dir}/../lib")
|
5
5
|
require "screw_unit"
|
6
|
+
require "thin"
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
unless ENV["SCREW_UNIT_SPEC_ROOT"]
|
9
|
+
ENV["SCREW_UNIT_SPEC_ROOT"] = ARGV[0]
|
10
|
+
end
|
11
|
+
|
12
|
+
unless ENV["SCREW_UNIT_PUBLIC"]
|
13
|
+
ENV["SCREW_UNIT_PUBLIC"] = ARGV[1]
|
14
|
+
end
|
15
|
+
|
16
|
+
Thin::Runner.new([
|
17
|
+
"--port", "8080",
|
18
|
+
"--rackup", File.expand_path("#{dir}/../standalone.ru"),
|
19
|
+
"start"]
|
20
|
+
).run!
|
data/lib/screw_unit.rb
CHANGED
@@ -3,17 +3,21 @@ require "rubygems"
|
|
3
3
|
dir = File.dirname(__FILE__)
|
4
4
|
$:.unshift(File.expand_path("#{dir}/../vendor/js-test-core/lib"))
|
5
5
|
require "js_test_core"
|
6
|
-
JsTestCore::Resources::WebRoot.dispatch_specs
|
7
6
|
|
8
7
|
require "#{dir}/screw_unit/representations"
|
9
8
|
|
9
|
+
JsTestCore.core_path = File.expand_path("#{dir}/../core/lib")
|
10
|
+
JsTestCore::Resources::SpecFile.spec_representation_class = ScrewUnit::Representations::Spec
|
10
11
|
module ScrewUnit
|
11
|
-
|
12
|
-
DEFAULT_PORT = JsTestCore::DEFAULT_PORT
|
12
|
+
include JsTestCore
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
class << self
|
15
|
+
def method_missing(method_name, *args, &block)
|
16
|
+
if JsTestCore::Configuration.instance.respond_to?(method_name)
|
17
|
+
JsTestCore::Configuration.instance.send(method_name, *args, &block)
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
17
23
|
end
|
18
|
-
JsTestCore.core_path = File.expand_path("#{dir}/../core/lib")
|
19
|
-
JsTestCore::Resources::Specs::Spec.spec_representation_class = ScrewUnit::Representations::Spec
|
@@ -2,24 +2,31 @@ require "rubygems"
|
|
2
2
|
require "spec"
|
3
3
|
require "spec/autorun"
|
4
4
|
require "selenium_rc"
|
5
|
+
require "thin"
|
5
6
|
dir = File.dirname(__FILE__)
|
7
|
+
LIBRARY_ROOT_DIR = File.expand_path("#{dir}/../..")
|
8
|
+
require "#{LIBRARY_ROOT_DIR}/vendor/js-test-core/spec/spec_helpers/be_http"
|
9
|
+
require "#{LIBRARY_ROOT_DIR}/vendor/js-test-core/spec/spec_helpers/show_test_exceptions"
|
6
10
|
require "#{dir}/functional_spec_server_starter"
|
11
|
+
ARGV.push("-b")
|
7
12
|
|
8
13
|
Spec::Runner.configure do |config|
|
9
14
|
config.mock_with :rr
|
10
15
|
end
|
11
16
|
|
12
|
-
|
13
|
-
|
17
|
+
Sinatra::Application.use ShowTestExceptions
|
18
|
+
Sinatra::Application.set :raise_errors, true
|
19
|
+
|
20
|
+
Sinatra::Application.use(ScrewUnit::App)
|
21
|
+
|
14
22
|
|
15
23
|
class Spec::ExampleGroup
|
16
24
|
include WaitFor
|
17
|
-
attr_reader :spec_root_path, :
|
25
|
+
attr_reader :spec_root_path, :public_path
|
18
26
|
|
19
27
|
before(:all) do
|
20
28
|
@spec_root_path = FunctionalSpecServerStarter.spec_root_path
|
21
29
|
@public_path = FunctionalSpecServerStarter.public_path
|
22
|
-
@implementation_root_path = FunctionalSpecServerStarter.implementation_root_path
|
23
30
|
unless SeleniumRC::Server.service_is_running?
|
24
31
|
Thread.start do
|
25
32
|
SeleniumRC::Server.boot
|
@@ -23,23 +23,32 @@ class FunctionalSpecServerStarter
|
|
23
23
|
include WaitFor
|
24
24
|
def call(threaded=true)
|
25
25
|
return if $screw_unit_server_started
|
26
|
+
|
26
27
|
Lsof.kill(8080)
|
27
28
|
wait_for do
|
28
29
|
!Lsof.running?(8080)
|
29
30
|
end
|
30
|
-
|
31
|
+
|
32
|
+
dir = File.dirname(__FILE__)
|
33
|
+
Dir.chdir("#{dir}/../../") do
|
31
34
|
Thread.start do
|
32
|
-
|
35
|
+
start_thin_server
|
33
36
|
end
|
34
|
-
else
|
35
|
-
ScrewUnit::Server.run(spec_root_path, implementation_root_path, public_path)
|
36
37
|
end
|
38
|
+
|
37
39
|
wait_for do
|
38
40
|
Lsof.running?(8080)
|
39
41
|
end
|
40
42
|
$screw_unit_server_started = true
|
41
43
|
end
|
42
44
|
|
45
|
+
def start_thin_server
|
46
|
+
system("bin/screw_unit_server #{spec_root_path} #{public_path}")
|
47
|
+
at_exit do
|
48
|
+
Lsof.kill(8080)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
43
52
|
def spec_root_path
|
44
53
|
File.expand_path("#{dir}/../example_specs")
|
45
54
|
end
|
@@ -48,10 +57,6 @@ class FunctionalSpecServerStarter
|
|
48
57
|
File.expand_path("#{dir}/../example_public")
|
49
58
|
end
|
50
59
|
|
51
|
-
def implementation_root_path
|
52
|
-
File.expand_path("#{public_path}/javascripts")
|
53
|
-
end
|
54
|
-
|
55
60
|
def dir
|
56
61
|
dir = File.dirname(__FILE__)
|
57
62
|
end
|
@@ -4,29 +4,62 @@ module JsTestCore
|
|
4
4
|
module Resources
|
5
5
|
module Specs
|
6
6
|
describe SpecFile do
|
7
|
-
describe "
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
describe "File" do
|
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
|
+
)
|
17
|
+
|
18
|
+
@doc = Nokogiri::HTML(response.body)
|
14
19
|
end
|
15
20
|
|
16
|
-
|
17
|
-
|
18
|
-
|
21
|
+
it "returns script tags for the test javascript file" do
|
22
|
+
doc.at("script[@src='/specs/failing_spec.js']").should_not be_nil
|
23
|
+
end
|
19
24
|
|
20
|
-
|
21
|
-
|
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
|
31
|
+
end
|
22
32
|
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "Directory" do
|
36
|
+
describe "GET /specs" do
|
37
|
+
attr_reader :dir, :html, :doc
|
23
38
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
39
|
+
before do
|
40
|
+
response = get(SpecFile.path("/"))
|
41
|
+
response.should be_http(
|
42
|
+
200,
|
43
|
+
{},
|
44
|
+
""
|
45
|
+
)
|
46
|
+
|
47
|
+
@doc = Nokogiri::HTML(response.body)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "returns script tags for each test javascript file" do
|
51
|
+
doc.at("script[@src='/specs/failing_spec.js']").should_not be_nil
|
52
|
+
doc.at("script[@src='/specs/foo/failing_spec.js']").should_not be_nil
|
53
|
+
doc.at("script[@src='/specs/foo/passing_spec.js']").should_not be_nil
|
54
|
+
end
|
55
|
+
|
56
|
+
it "returns the screw unit template" do
|
57
|
+
doc.at("link[@href='/core/screw.css']").should_not be_nil
|
58
|
+
doc.at("script[@src='/core/screw.builder.js']").should_not be_nil
|
59
|
+
doc.at("script[@src='/core/screw.events.js']").should_not be_nil
|
60
|
+
doc.at("script[@src='/core/screw.behaviors.js']").should_not be_nil
|
61
|
+
doc.at("body/#screw_unit_content").should_not be_nil
|
62
|
+
end
|
30
63
|
end
|
31
64
|
end
|
32
65
|
end
|
@@ -1,119 +1,51 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
require "spec"
|
3
3
|
require "spec/autorun"
|
4
|
-
|
4
|
+
require "rack/test"
|
5
|
+
ARGV.push("-b")
|
5
6
|
|
6
|
-
|
7
|
+
dir = File.dirname(__FILE__)
|
8
|
+
LIBRARY_ROOT_DIR = File.expand_path("#{dir}/../..")
|
9
|
+
$LOAD_PATH.unshift File.expand_path("#{LIBRARY_ROOT_DIR}/lib")
|
7
10
|
require "screw_unit"
|
8
11
|
require "nokogiri"
|
9
12
|
require "guid"
|
13
|
+
require "#{LIBRARY_ROOT_DIR}/vendor/js-test-core/spec/spec_helpers/be_http"
|
14
|
+
require "#{LIBRARY_ROOT_DIR}/vendor/js-test-core/spec/spec_helpers/show_test_exceptions"
|
10
15
|
|
11
16
|
Spec::Runner.configure do |config|
|
12
17
|
config.mock_with :rr
|
13
18
|
end
|
14
19
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
!@actual.nil?
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
20
|
+
Sinatra::Application.use ShowTestExceptions
|
21
|
+
Sinatra::Application.set :raise_errors, true
|
22
|
+
Sinatra::Application.set :show_exceptions, false
|
23
|
+
JsTestCore::App.set :raise_errors, true
|
24
|
+
JsTestCore::App.set :show_exceptions, false
|
25
25
|
|
26
|
-
|
27
|
-
class << self
|
28
|
-
def thin_logging
|
29
|
-
@thin_logging = true if @thin_logging.nil?
|
30
|
-
@thin_logging
|
31
|
-
end
|
32
|
-
|
33
|
-
attr_writer :thin_logging
|
34
|
-
end
|
26
|
+
Sinatra::Application.use(ScrewUnit::App)
|
35
27
|
|
36
|
-
|
28
|
+
class Spec::ExampleGroup
|
29
|
+
include Rack::Test::Methods
|
30
|
+
include BeHttp
|
31
|
+
|
32
|
+
attr_reader :spec_root_path, :public_path, :server, :connection
|
37
33
|
before(:all) do
|
38
34
|
dir = File.dirname(__FILE__)
|
39
35
|
@spec_root_path = File.expand_path("#{dir}/../example_specs")
|
40
|
-
@implementation_root_path = File.expand_path("#{dir}/../example_public/javascripts")
|
41
36
|
@public_path = File.expand_path("#{dir}/../example_public")
|
42
37
|
end
|
43
38
|
|
44
39
|
before(:each) do
|
45
|
-
JsTestCore::
|
46
|
-
|
47
|
-
raise "You need to mock calls to EventMachine.run or the process will hang"
|
48
|
-
end
|
49
|
-
stub(EventMachine).start_server do
|
50
|
-
raise "You need to mock calls to EventMachine.start_server or the process will hang"
|
51
|
-
end
|
52
|
-
stub(EventMachine).send_data do
|
53
|
-
raise "Calls to EventMachine.send_data must be mocked or stubbed"
|
54
|
-
end
|
55
|
-
@connection = Thin::JsTestCoreConnection.new(Guid.new)
|
56
|
-
stub(EventMachine).send_data {raise "EventMachine.send_data must be handled"}
|
57
|
-
stub(EventMachine).close_connection {raise "EventMachine.close_connection must be handled"}
|
58
|
-
@server = JsTestCore::Server.instance
|
59
|
-
Thin::Logging.silent = !self.class.thin_logging
|
60
|
-
Thin::Logging.debug = self.class.thin_logging
|
61
|
-
end
|
62
|
-
|
63
|
-
after(:each) do
|
64
|
-
Thin::Logging.silent = true
|
65
|
-
Thin::Logging.debug = false
|
66
|
-
end
|
67
|
-
|
68
|
-
def get(url, params={})
|
69
|
-
request(:get, url, params)
|
70
|
-
end
|
71
|
-
|
72
|
-
def post(url, params={})
|
73
|
-
request(:post, url, params)
|
40
|
+
JsTestCore::Configuration.instance.spec_root_path = spec_root_path
|
41
|
+
JsTestCore::Configuration.instance.public_path = public_path
|
74
42
|
end
|
75
43
|
|
76
|
-
def
|
77
|
-
|
44
|
+
def app
|
45
|
+
Sinatra::Application
|
78
46
|
end
|
79
47
|
|
80
|
-
def delete(url, params={})
|
81
|
-
request(:delete, url, params)
|
82
|
-
end
|
83
|
-
|
84
|
-
def env_for(method, url, params)
|
85
|
-
Rack::MockRequest.env_for(url, params.merge({:method => method.to_s.upcase, 'js_test_core.connection' => connection}))
|
86
|
-
end
|
87
|
-
|
88
|
-
def create_request(method, url, params={})
|
89
|
-
env = env_for(method, url, params)
|
90
|
-
server.call(env)[2]
|
91
|
-
end
|
92
|
-
alias_method :request, :create_request
|
93
|
-
|
94
48
|
def core_path
|
95
49
|
JsTestCore::Server.core_path
|
96
50
|
end
|
97
|
-
|
98
|
-
def spec_file(relative_path)
|
99
|
-
absolute_path = spec_root_path + relative_path
|
100
|
-
JsTestCore::Resources::File.new(absolute_path, "/specs#{relative_path}")
|
101
|
-
end
|
102
|
-
|
103
|
-
def spec_dir(relative_path="")
|
104
|
-
absolute_path = spec_root_path + relative_path
|
105
|
-
JsTestCore::Resources::SpecDir.new(absolute_path, "/specs#{relative_path}")
|
106
|
-
end
|
107
|
-
|
108
|
-
def contain_spec_file_with_correct_paths(path_relative_to_spec_root)
|
109
|
-
expected_absolute_path = spec_root_path + path_relative_to_spec_root
|
110
|
-
expected_relative_path = "/specs" + path_relative_to_spec_root
|
111
|
-
|
112
|
-
::Spec::Matchers::SimpleMatcher.new(expected_relative_path) do |globbed_files|
|
113
|
-
file = globbed_files.find do |file|
|
114
|
-
file.absolute_path == expected_absolute_path
|
115
|
-
end
|
116
|
-
file && file.relative_path == expected_relative_path
|
117
|
-
end
|
118
|
-
end
|
119
51
|
end
|
data/vendor/js-test-core/CHANGES
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
+
- No longer using the /implementanions directory. Replace all cases of /implementations with /javascripts.
|
1
2
|
- Added support for custom suite files
|
2
3
|
- Added dependency on Erector
|
3
4
|
- Better error messages
|
4
5
|
- Changed dependency from Selenium to selenium-client
|
6
|
+
- Renamed Resources::Runner to Resources::SeleniumSession
|
7
|
+
- Changed /runners to /selenium_sessions
|
5
8
|
|
6
9
|
0.2.0
|
7
10
|
- Renamed Suite to Session to follow Selenium conventions
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
class App < Sinatra::Base
|
3
|
+
set :logging, true
|
4
|
+
register(JsTestCore::Resources::WebRoot.route_handler)
|
5
|
+
register(JsTestCore::Resources::SeleniumSession.route_handler)
|
6
|
+
register(JsTestCore::Resources::CoreFile.route_handler)
|
7
|
+
register(JsTestCore::Resources::SpecFile.route_handler)
|
8
|
+
register(JsTestCore::Resources::File.route_handler)
|
9
|
+
register(JsTestCore::Resources::ImplementationsDeprecation.route_handler)
|
10
|
+
register(JsTestCore::Resources::NotFound.route_handler)
|
11
|
+
end
|
12
|
+
end
|
@@ -80,7 +80,7 @@ module JsTestCore
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def start_runner
|
83
|
-
@session_start_response = http.post(
|
83
|
+
@session_start_response = http.post(Resources::SeleniumSession.path, query_string)
|
84
84
|
end
|
85
85
|
|
86
86
|
def wait_for_session_to_finish
|
@@ -92,10 +92,10 @@ module JsTestCore
|
|
92
92
|
|
93
93
|
def report_result
|
94
94
|
case last_poll_status
|
95
|
-
when Resources::
|
95
|
+
when Resources::SeleniumSession::SUCCESSFUL_COMPLETION
|
96
96
|
STDOUT.puts "SUCCESS"
|
97
97
|
true
|
98
|
-
when Resources::
|
98
|
+
when Resources::SeleniumSession::FAILURE_COMPLETION
|
99
99
|
STDOUT.puts "FAILURE"
|
100
100
|
STDOUT.puts last_poll_reason
|
101
101
|
false
|
@@ -105,11 +105,11 @@ module JsTestCore
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def session_not_completed?
|
108
|
-
last_poll_status.nil? || last_poll_status == Resources::
|
108
|
+
last_poll_status.nil? || last_poll_status == Resources::SeleniumSession::RUNNING
|
109
109
|
end
|
110
110
|
|
111
111
|
def poll
|
112
|
-
@last_poll = http.get("
|
112
|
+
@last_poll = http.get(Resources::SeleniumSession.path("/:session_id", :session_id => session_id))
|
113
113
|
ensure_session_exists!
|
114
114
|
parts = parts_from_query(last_poll.body)
|
115
115
|
@last_poll_status = parts['status']
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
class Configuration
|
3
|
+
class << self
|
4
|
+
attr_accessor :instance
|
5
|
+
|
6
|
+
def method_missing(method_name, *args, &block)
|
7
|
+
if Configuration.instance.respond_to?(method_name)
|
8
|
+
Configuration.instance.send(method_name, *args, &block)
|
9
|
+
else
|
10
|
+
super
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_accessor :host, :port, :spec_root_path, :public_path, :core_path
|
16
|
+
|
17
|
+
def initialize(params={})
|
18
|
+
params = {
|
19
|
+
:spec_root_path => File.expand_path("./specs/javascripts"),
|
20
|
+
:public_path => File.expand_path("./public"),
|
21
|
+
:host => DEFAULT_HOST,
|
22
|
+
:port => DEFAULT_PORT,
|
23
|
+
}.merge(params)
|
24
|
+
@spec_root_path = ::File.expand_path(params[:spec_root_path])
|
25
|
+
@public_path = ::File.expand_path(params[:public_path])
|
26
|
+
@host = params[:host]
|
27
|
+
@port = params[:port]
|
28
|
+
@core_path = params[:core_path]
|
29
|
+
end
|
30
|
+
|
31
|
+
def root_url
|
32
|
+
"http://#{host}:#{port}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
File without changes
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Models
|
3
|
+
class SeleniumSession
|
4
|
+
class << self
|
5
|
+
def find(id)
|
6
|
+
instances[id.to_s]
|
7
|
+
end
|
8
|
+
|
9
|
+
def register(selenium_session)
|
10
|
+
instances[selenium_session.session_id] = selenium_session
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
def instances
|
15
|
+
@instances ||= {}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_reader :spec_url, :selenium_browser_start_command, :selenium_host, :selenium_port, :http_address, :driver, :run_result
|
20
|
+
|
21
|
+
def initialize(params={})
|
22
|
+
@spec_url = params[:spec_url]
|
23
|
+
@selenium_browser_start_command = params[:selenium_browser_start_command]
|
24
|
+
@selenium_host = params[:selenium_host]
|
25
|
+
@selenium_port = params[:selenium_port]
|
26
|
+
|
27
|
+
memoized_parsed_spec_url = parsed_spec_url
|
28
|
+
@http_address = "#{memoized_parsed_spec_url.scheme}://#{memoized_parsed_spec_url.host}:#{memoized_parsed_spec_url.port}"
|
29
|
+
|
30
|
+
@driver = Selenium::Client::Driver.new(
|
31
|
+
selenium_host,
|
32
|
+
selenium_port,
|
33
|
+
selenium_browser_start_command,
|
34
|
+
http_address
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
def start
|
39
|
+
begin
|
40
|
+
driver.start
|
41
|
+
rescue Errno::ECONNREFUSED => e
|
42
|
+
raise Errno::ECONNREFUSED, "Cannot connect to Selenium Server at #{http_address}. To start the selenium server, run `selenium`."
|
43
|
+
end
|
44
|
+
self.class.register(self)
|
45
|
+
Thread.start do
|
46
|
+
driver.open("/")
|
47
|
+
driver.create_cookie("session_id=#{session_id}")
|
48
|
+
driver.open(parsed_spec_url.path)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def session_id
|
53
|
+
driver.session_id
|
54
|
+
end
|
55
|
+
|
56
|
+
def finish(run_result)
|
57
|
+
driver.stop
|
58
|
+
@run_result = run_result.to_s
|
59
|
+
end
|
60
|
+
|
61
|
+
def running?
|
62
|
+
driver.session_started?
|
63
|
+
end
|
64
|
+
|
65
|
+
def successful?
|
66
|
+
!running? && run_result.empty?
|
67
|
+
end
|
68
|
+
|
69
|
+
def failed?
|
70
|
+
!running? && !successful?
|
71
|
+
end
|
72
|
+
|
73
|
+
protected
|
74
|
+
|
75
|
+
def parsed_spec_url
|
76
|
+
URI.parse(spec_url)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module JsTestCore
|
2
|
+
module Representations
|
3
|
+
class Dir < Page
|
4
|
+
needs :relative_path, :absolute_path
|
5
|
+
protected
|
6
|
+
def body_content
|
7
|
+
ul do
|
8
|
+
::Dir.glob("#{absolute_path}/*").inject("") do |html, file|
|
9
|
+
li do
|
10
|
+
a(
|
11
|
+
::File.basename(file),
|
12
|
+
:href => "#{relative_path}/#{::File.basename(file)}".gsub("//", "/")
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def title_text
|
20
|
+
"Contents of #{relative_path}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
module
|
1
|
+
module JsTestCore
|
2
2
|
module Representations
|
3
|
-
class
|
4
|
-
needs :
|
3
|
+
class NotFound < Page
|
4
|
+
needs :message
|
5
5
|
protected
|
6
6
|
def body_content
|
7
7
|
h1 message
|
@@ -10,10 +10,6 @@ module ThinRest
|
|
10
10
|
def title_text
|
11
11
|
message
|
12
12
|
end
|
13
|
-
|
14
|
-
def message
|
15
|
-
"File #{path_info} not found"
|
16
|
-
end
|
17
13
|
end
|
18
14
|
end
|
19
15
|
end
|