opal-spec 0.2.13 → 0.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +0 -10
 - data/Rakefile +3 -1
 - data/config.ru +5 -2
 - data/lib/assets/javascripts/opal/spec/assertions.rb +12 -0
 - data/lib/assets/javascripts/opal/spec/browser_formatter.rb +2 -2
 - data/lib/assets/javascripts/opal/spec/sprockets_runner.rb.erb +2 -2
 - data/lib/assets/javascripts/opal/spec/test_case.rb +3 -0
 - data/lib/opal/spec/rake_task.rb +16 -24
 - data/lib/opal/spec/version.rb +1 -1
 - data/lib/opal/spec.rb +0 -6
 - data/spec/{specs.rb → specs_spec.rb} +8 -0
 - data/spec/tests_spec.rb +17 -0
 - metadata +5 -5
 - data/lib/opal/spec/server.rb +0 -23
 - data/spec/tests.rb +0 -9
 
    
        data/README.md
    CHANGED
    
    | 
         @@ -23,16 +23,6 @@ describe MyClass do 
     | 
|
| 
       23 
23 
     | 
    
         
             
            end
         
     | 
| 
       24 
24 
     | 
    
         
             
            ```
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
            ### Running specs
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
            Loading these specs in a browser won't just work. You need to run them.
         
     | 
| 
       29 
     | 
    
         
            -
            The best place to do this is inside `spec/spec_helper.rb`, and with a
         
     | 
| 
       30 
     | 
    
         
            -
            simple call:
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
            ```ruby
         
     | 
| 
       33 
     | 
    
         
            -
            Opal::Spec::Runner.autorun
         
     | 
| 
       34 
     | 
    
         
            -
            ```
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
26 
     | 
    
         
             
            ###  Async examples
         
     | 
| 
       37 
27 
     | 
    
         | 
| 
       38 
28 
     | 
    
         
             
            Examples can be async, and need to be defined as so:
         
     | 
    
        data/Rakefile
    CHANGED
    
    
    
        data/config.ru
    CHANGED
    
    
| 
         @@ -1,10 +1,10 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # This file is used by Opal:: 
     | 
| 
      
 1 
     | 
    
         
            +
            # This file is used by Opal::Server to basically load all spec files that
         
     | 
| 
       2 
2 
     | 
    
         
             
            # can be found in the spec/ directory.
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            <% require_asset 'opal' %>
         
     | 
| 
       5 
5 
     | 
    
         
             
            <% require_asset 'opal-spec' %>
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
            <% Dir.glob('spec 
     | 
| 
      
 7 
     | 
    
         
            +
            <% Dir.glob('spec/**/*_spec.{rb,opal}').each do |s| %>
         
     | 
| 
       8 
8 
     | 
    
         
             
            <% require_asset s.sub(/^spec\//, '').sub(/\.(rb|opal)$/, '') %>
         
     | 
| 
       9 
9 
     | 
    
         
             
            <% end %>
         
     | 
| 
       10 
10 
     | 
    
         | 
    
        data/lib/opal/spec/rake_task.rb
    CHANGED
    
    | 
         @@ -1,30 +1,34 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'opal/spec'
         
     | 
| 
       2 
     | 
    
         
            -
            require 'opal/spec/server'
         
     | 
| 
       3 
2 
     | 
    
         | 
| 
       4 
3 
     | 
    
         
             
            module Opal
         
     | 
| 
       5 
4 
     | 
    
         
             
              module Spec
         
     | 
| 
       6 
5 
     | 
    
         
             
                class RakeTask
         
     | 
| 
       7 
6 
     | 
    
         
             
                  include Rake::DSL if defined? Rake::DSL
         
     | 
| 
       8 
7 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                   
     | 
| 
      
 8 
     | 
    
         
            +
                  RUNNER = File.expand_path('../../../../vendor/spec_runner.js', __FILE__)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  PORT = 9999
         
     | 
| 
      
 10 
     | 
    
         
            +
                  URL = "http://localhost:9999/"
         
     | 
| 
       10 
11 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
                  def initialize(name = 'opal: 
     | 
| 
       12 
     | 
    
         
            -
                    @name = name
         
     | 
| 
       13 
     | 
    
         
            -
                    define_tasks
         
     | 
| 
       14 
     | 
    
         
            -
                  end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                  def define_tasks
         
     | 
| 
      
 12 
     | 
    
         
            +
                  def initialize(name = 'opal:test', &block)
         
     | 
| 
       17 
13 
     | 
    
         
             
                    desc "Run opal specs in phantomjs"
         
     | 
| 
       18 
     | 
    
         
            -
                    task  
     | 
| 
      
 14 
     | 
    
         
            +
                    task name do
         
     | 
| 
       19 
15 
     | 
    
         
             
                      require 'rack'
         
     | 
| 
       20 
16 
     | 
    
         
             
                      require 'webrick'
         
     | 
| 
       21 
17 
     | 
    
         | 
| 
       22 
18 
     | 
    
         
             
                      server = fork do
         
     | 
| 
       23 
     | 
    
         
            -
                         
     | 
| 
       24 
     | 
    
         
            -
                           
     | 
| 
      
 19 
     | 
    
         
            +
                        s = Opal::Server.new { |s|
         
     | 
| 
      
 20 
     | 
    
         
            +
                          s.main = 'opal/spec/sprockets_runner'
         
     | 
| 
      
 21 
     | 
    
         
            +
                          s.append_path 'spec'
         
     | 
| 
      
 22 
     | 
    
         
            +
                          s.debug = false
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                          block.call s if block
         
     | 
| 
      
 25 
     | 
    
         
            +
                        }
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                        Rack::Server.start(:app => s, :Port => PORT, :AccessLog => [],
         
     | 
| 
      
 28 
     | 
    
         
            +
                          :Logger => WEBrick::Log.new("/dev/null"))
         
     | 
| 
       25 
29 
     | 
    
         
             
                      end
         
     | 
| 
       26 
30 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
                      system "phantomjs #{ 
     | 
| 
      
 31 
     | 
    
         
            +
                      system "phantomjs #{RUNNER} \"#{URL}\""
         
     | 
| 
       28 
32 
     | 
    
         
             
                      success = $?.success?
         
     | 
| 
       29 
33 
     | 
    
         | 
| 
       30 
34 
     | 
    
         
             
                      Process.kill(:SIGINT, server)
         
     | 
| 
         @@ -33,18 +37,6 @@ module Opal 
     | 
|
| 
       33 
37 
     | 
    
         
             
                      exit 1 unless success
         
     | 
| 
       34 
38 
     | 
    
         
             
                    end
         
     | 
| 
       35 
39 
     | 
    
         
             
                  end
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
                  def runner_path
         
     | 
| 
       38 
     | 
    
         
            -
                    File.join(VENDOR_PATH, 'spec_runner.js')
         
     | 
| 
       39 
     | 
    
         
            -
                  end
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
                  def url_path
         
     | 
| 
       42 
     | 
    
         
            -
                    "http://localhost:9999/"
         
     | 
| 
       43 
     | 
    
         
            -
                  end
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
                  def port
         
     | 
| 
       46 
     | 
    
         
            -
                    9999
         
     | 
| 
       47 
     | 
    
         
            -
                  end
         
     | 
| 
       48 
40 
     | 
    
         
             
                end
         
     | 
| 
       49 
41 
     | 
    
         
             
              end
         
     | 
| 
       50 
42 
     | 
    
         
             
            end
         
     | 
    
        data/lib/opal/spec/version.rb
    CHANGED
    
    
    
        data/lib/opal/spec.rb
    CHANGED
    
    | 
         @@ -1,11 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'opal'
         
     | 
| 
       2 
2 
     | 
    
         
             
            require 'opal/spec/version'
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
            module Opal
         
     | 
| 
       5 
     | 
    
         
            -
              module Spec
         
     | 
| 
       6 
     | 
    
         
            -
                VENDOR_PATH = File.join(File.dirname(__FILE__), '..', '..', 'vendor')
         
     | 
| 
       7 
     | 
    
         
            -
              end
         
     | 
| 
       8 
     | 
    
         
            -
            end
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
4 
     | 
    
         
             
            # Just register our opal code path with opal build tools
         
     | 
| 
       11 
5 
     | 
    
         
             
            Opal.append_path File.join(File.dirname(__FILE__), '..', 'assets', 'javascripts')
         
     | 
    
        data/spec/tests_spec.rb
    ADDED
    
    | 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class SimpleTest < OpalTest::TestCase
         
     | 
| 
      
 2 
     | 
    
         
            +
              def test_this_should_be_tested
         
     | 
| 
      
 3 
     | 
    
         
            +
                :pass.should eq(:pass)
         
     | 
| 
      
 4 
     | 
    
         
            +
              end
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              def test_should_also_pass
         
     | 
| 
      
 7 
     | 
    
         
            +
                1.should == 1
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              def test_simple_assertion
         
     | 
| 
      
 11 
     | 
    
         
            +
                assert true
         
     | 
| 
      
 12 
     | 
    
         
            +
                assert 42
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                lambda { assert nil }.should raise_error(Exception)
         
     | 
| 
      
 15 
     | 
    
         
            +
                lambda { assert false }.should raise_error(Exception)
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: opal-spec
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.14
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2013- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2013-03-01 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       14 
14 
     | 
    
         
             
            description: Opal compatible spec library
         
     | 
| 
       15 
15 
     | 
    
         
             
            email: adam.beynon@gmail.com
         
     | 
| 
         @@ -25,6 +25,7 @@ files: 
     | 
|
| 
       25 
25 
     | 
    
         
             
            - config.ru
         
     | 
| 
       26 
26 
     | 
    
         
             
            - lib/assets/javascripts/opal-spec.rb
         
     | 
| 
       27 
27 
     | 
    
         
             
            - lib/assets/javascripts/opal/spec.rb
         
     | 
| 
      
 28 
     | 
    
         
            +
            - lib/assets/javascripts/opal/spec/assertions.rb
         
     | 
| 
       28 
29 
     | 
    
         
             
            - lib/assets/javascripts/opal/spec/browser_formatter.rb
         
     | 
| 
       29 
30 
     | 
    
         
             
            - lib/assets/javascripts/opal/spec/expectations.rb
         
     | 
| 
       30 
31 
     | 
    
         
             
            - lib/assets/javascripts/opal/spec/kernel.rb
         
     | 
| 
         @@ -41,13 +42,12 @@ files: 
     | 
|
| 
       41 
42 
     | 
    
         
             
            - lib/opal-spec.rb
         
     | 
| 
       42 
43 
     | 
    
         
             
            - lib/opal/spec.rb
         
     | 
| 
       43 
44 
     | 
    
         
             
            - lib/opal/spec/rake_task.rb
         
     | 
| 
       44 
     | 
    
         
            -
            - lib/opal/spec/server.rb
         
     | 
| 
       45 
45 
     | 
    
         
             
            - lib/opal/spec/version.rb
         
     | 
| 
       46 
46 
     | 
    
         
             
            - opal-spec.gemspec
         
     | 
| 
       47 
47 
     | 
    
         
             
            - spec/matchers/be_empty_spec.rb
         
     | 
| 
       48 
48 
     | 
    
         
             
            - spec/matchers/respond_to_spec.rb
         
     | 
| 
       49 
     | 
    
         
            -
            - spec/ 
     | 
| 
       50 
     | 
    
         
            -
            - spec/ 
     | 
| 
      
 49 
     | 
    
         
            +
            - spec/specs_spec.rb
         
     | 
| 
      
 50 
     | 
    
         
            +
            - spec/tests_spec.rb
         
     | 
| 
       51 
51 
     | 
    
         
             
            - vendor/spec_runner.js
         
     | 
| 
       52 
52 
     | 
    
         
             
            homepage: http://opalrb.org
         
     | 
| 
       53 
53 
     | 
    
         
             
            licenses: []
         
     | 
    
        data/lib/opal/spec/server.rb
    DELETED
    
    | 
         @@ -1,23 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'opal/spec'
         
     | 
| 
       2 
     | 
    
         
            -
            require 'opal'
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            module Opal
         
     | 
| 
       5 
     | 
    
         
            -
              module Spec
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
                # Custom Opal::Server subclass which adds the 'spec' dir as a
         
     | 
| 
       8 
     | 
    
         
            -
                # directory for testing (adds to load path). Specs run through this
         
     | 
| 
       9 
     | 
    
         
            -
                # server are not run in debug mode (all scripts loaded in a single
         
     | 
| 
       10 
     | 
    
         
            -
                # file). This can be overriden in the supplied block.
         
     | 
| 
       11 
     | 
    
         
            -
                class Server < Opal::Server
         
     | 
| 
       12 
     | 
    
         
            -
                  def initialize(*args, &block)
         
     | 
| 
       13 
     | 
    
         
            -
                    super(*args) do |s|
         
     | 
| 
       14 
     | 
    
         
            -
                      s.append_path 'spec'
         
     | 
| 
       15 
     | 
    
         
            -
                      s.main = 'opal/spec/sprockets_runner'
         
     | 
| 
       16 
     | 
    
         
            -
                      s.debug = false
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                      yield s if block_given?
         
     | 
| 
       19 
     | 
    
         
            -
                    end
         
     | 
| 
       20 
     | 
    
         
            -
                  end
         
     | 
| 
       21 
     | 
    
         
            -
                end
         
     | 
| 
       22 
     | 
    
         
            -
              end
         
     | 
| 
       23 
     | 
    
         
            -
            end
         
     |