jstdutil 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.1.0
@@ -2,4 +2,10 @@
2
2
  require "jstdutil"
3
3
  require "jstdutil/autotest"
4
4
 
5
- Jstdutil::Autotest.new($*).run
5
+ begin
6
+ Jstdutil::Autotest.new($*).run
7
+ rescue StandardError => err
8
+ puts "An error occurred"
9
+ puts err.message
10
+ raise err
11
+ end
@@ -15,6 +15,8 @@ module Jstdutil
15
15
  @runner = Jstdutil::TestRunner.new(args)
16
16
  $jstestdriver_test_runner = @runner
17
17
  @interrupted_at = nil
18
+ rescue StandardError => err
19
+ raise err
18
20
  end
19
21
 
20
22
  def run
@@ -24,12 +24,17 @@ module Jstdutil
24
24
  super
25
25
  end
26
26
 
27
+ def respond_to?(name)
28
+ return true if @contents.key?(name.to_s)
29
+ super
30
+ end
31
+
27
32
  private
28
33
  def load_config(contents)
29
34
  @contents = YAML.load(contents)
30
35
 
31
36
  if !@contents.respond_to?(:key?) || !@contents.key?("server")
32
- raise ArgumentError.new("Error: Missing 'server' setting")
37
+ raise ArgumentError.new("Error: Unable to locate 'server' configuration setting. Did you provide a --config?")
33
38
  end
34
39
 
35
40
  @contents
@@ -4,11 +4,15 @@ require "uri"
4
4
  module Jstdutil
5
5
  module JsTestDriver
6
6
  class Server
7
+ attr_reader :uri
8
+
7
9
  def initialize(config, args = nil)
8
- @uri = URI.parse(config.respond_to?(:server) ? config.server : config)
10
+ uri = config.respond_to?(:server) ? config.server : config
11
+ @uri = URI.parse(uri)
9
12
  @args = args
10
- # @server = nil
11
13
  @pid = nil
14
+ rescue URI::InvalidURIError => err
15
+ raise StandardError.new("Invalid test driver server URL #{uri}")
12
16
  end
13
17
 
14
18
  def running?
@@ -2,6 +2,9 @@ begin
2
2
  require 'Win32/Console/ANSI' if PLATFORM =~ /win32/
3
3
  rescue LoadError
4
4
  raise 'You must gem install win32console to use color on Windows'
5
+ rescue NameError
6
+ # PLATFORM is not defined, not a problem on windows.
7
+ # On other platforms we don't care
5
8
  end
6
9
 
7
10
  module Jstdutil
@@ -15,6 +15,8 @@ module Jstdutil
15
15
  if config && config.server
16
16
  @server = JsTestDriver::Server.new(config, args({}, ["port"]).join(" "))
17
17
  end
18
+ rescue StandardError => err
19
+ raise err
18
20
  end
19
21
 
20
22
  def test_cases(files)
@@ -25,10 +27,14 @@ module Jstdutil
25
27
  end
26
28
 
27
29
  def run(tests = "all")
28
- begin
29
- @server.start unless @server.running?
30
- rescue StandardError => err
31
- puts err.message
30
+ #begin
31
+ # @server.start unless @server.running?
32
+ #rescue StandardError => err
33
+ # puts err.message
34
+ #end
35
+ if !@server.running?
36
+ puts "Server not running, you want to start it with jstestdriver --port #{@server.uri.port}"
37
+ exit
32
38
  end
33
39
 
34
40
  puts(Time.now.strftime("%F %H:%M:%S Running #{tests}"))
@@ -1,5 +1,5 @@
1
1
  require "test_helper"
2
- require "jstdutil/jstestdriver_config"
2
+ require "jstdutil/jstestdriver/config"
3
3
 
4
4
  class JsTestDriverConfigTest < Test::Unit::TestCase
5
5
  context "creating JsTestDriverConfig instances" do
@@ -17,7 +17,7 @@ class JsTestDriverConfigTest < Test::Unit::TestCase
17
17
  config = nil
18
18
 
19
19
  assert_nothing_raised do
20
- config = Jstdutil::JsTestDriverConfig.new @file
20
+ config = Jstdutil::JsTestDriver::Config.new @file
21
21
  end
22
22
 
23
23
  assert_equal @server, config.server
@@ -27,7 +27,7 @@ class JsTestDriverConfigTest < Test::Unit::TestCase
27
27
  config = nil
28
28
 
29
29
  assert_nothing_raised do
30
- config = Jstdutil::JsTestDriverConfig.new "server: #{@server}"
30
+ config = Jstdutil::JsTestDriver::Config.new "server: #{@server}"
31
31
  end
32
32
 
33
33
  assert_equal @server, config.server
@@ -35,7 +35,7 @@ class JsTestDriverConfigTest < Test::Unit::TestCase
35
35
 
36
36
  should "raise error if no valid configuration is provided" do
37
37
  assert_raise ArgumentError do
38
- Jstdutil::JsTestDriverConfig.new "bogus"
38
+ Jstdutil::JsTestDriver::Config.new "bogus"
39
39
  end
40
40
  end
41
41
  end
@@ -3,7 +3,7 @@ require 'test/unit'
3
3
  require 'shoulda'
4
4
  require 'mocha'
5
5
  require 'fileutils'
6
- require 'redgreen'
6
+ require 'redgreen' if RUBY_VERSION < "1.9"
7
7
 
8
8
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
9
9
  $LOAD_PATH.unshift(File.dirname(__FILE__))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jstdutil
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Johansen