opal-rspec 0.0.1.beta1 → 0.0.1.beta2
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +21 -35
- data/Rakefile +3 -0
- data/app/rspec-builder.rb +32 -1
- data/lib/opal/rspec/version.rb +1 -1
- data/opal/opal/rspec/async.rb +129 -0
- data/opal/opal/rspec/fixes.rb +3 -1
- data/opal/opal/rspec/rspec.js +422 -5834
- data/opal/opal/rspec/runner.rb +27 -10
- data/opal/opal/rspec.rb +5 -0
- data/spec/async_spec.rb +39 -0
- data/spec/example_spec.rb +10 -0
- metadata +4 -9
- data/app/rspec/core/configuration.rb +0 -1070
- data/app/rspec/core/example_group.rb +0 -573
- data/app/rspec/core/project_initializer.rb +0 -0
- data/app/rspec/core/shared_example_group/collection.rb +0 -27
- data/app/rspec/core/shared_example_group.rb +0 -146
- data/app/rspec/core.rb +0 -202
- data/app/rspec/matchers/built_in/have.rb +0 -0
data/opal/opal/rspec/runner.rb
CHANGED
@@ -28,25 +28,42 @@ module Opal
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def initialize(options={}
|
31
|
+
def initialize(options = {})
|
32
32
|
@options = options
|
33
|
-
@
|
34
|
-
@
|
33
|
+
@world = ::RSpec.world
|
34
|
+
@configuration = ::RSpec.configuration
|
35
35
|
end
|
36
36
|
|
37
37
|
def run(err=$stdout, out=$stdout)
|
38
38
|
@configuration.error_stream = err
|
39
39
|
@configuration.output_stream ||= out
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
@configuration.run_hook(:after, :suite)
|
47
|
-
end
|
41
|
+
self.start
|
42
|
+
run_examples
|
43
|
+
|
44
|
+
run_async_examples do
|
45
|
+
self.finish
|
48
46
|
end
|
49
47
|
end
|
48
|
+
|
49
|
+
def run_examples
|
50
|
+
@world.example_groups.map { |g| g.run(@reporter) }.all?
|
51
|
+
end
|
52
|
+
|
53
|
+
def run_async_examples(&block)
|
54
|
+
AsyncRunner.new(self, @reporter, block).run
|
55
|
+
end
|
56
|
+
|
57
|
+
def start
|
58
|
+
@reporter = @configuration.reporter
|
59
|
+
@reporter.start(@world.example_count)
|
60
|
+
@configuration.run_hook(:before, :suite)
|
61
|
+
end
|
62
|
+
|
63
|
+
def finish
|
64
|
+
@configuration.run_hook(:after, :suite)
|
65
|
+
@reporter.finish
|
66
|
+
end
|
50
67
|
end
|
51
68
|
end
|
52
69
|
end
|
data/opal/opal/rspec.rb
CHANGED
@@ -9,11 +9,16 @@ require 'opal/rspec/fixes'
|
|
9
9
|
require 'opal/rspec/text_formatter'
|
10
10
|
require 'opal/rspec/browser_formatter'
|
11
11
|
require 'opal/rspec/runner'
|
12
|
+
require 'opal/rspec/async'
|
12
13
|
|
13
14
|
RSpec.configure do |config|
|
14
15
|
# For now, always use our custom formatter for results
|
15
16
|
config.formatter = Opal::RSpec::Runner.default_formatter
|
16
17
|
|
18
|
+
# Async helpers for specs
|
19
|
+
config.include Opal::RSpec::AsyncHelpers
|
20
|
+
config.extend Opal::RSpec::AsyncDefinitions
|
21
|
+
|
17
22
|
# Always support expect() and .should syntax (we should not do this really..)
|
18
23
|
config.expect_with :rspec do |c|
|
19
24
|
c.syntax = [:should, :expect]
|
data/spec/async_spec.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
describe "Asynchronous helpers" do
|
2
|
+
|
3
|
+
let(:foo) { 100 }
|
4
|
+
|
5
|
+
before do
|
6
|
+
@model = Object.new
|
7
|
+
end
|
8
|
+
|
9
|
+
async "can run examples async" do
|
10
|
+
run_async do
|
11
|
+
1.should == 1
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
async "can access let() helpers and before() helpers" do
|
16
|
+
run_async do
|
17
|
+
foo.should eq(100)
|
18
|
+
@model.should be_kind_of(Object)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
async "can finish running after a long delay" do
|
23
|
+
obj = [1, 2, 3, 4]
|
24
|
+
|
25
|
+
set_timeout 100 do
|
26
|
+
run_async { obj.should == [1, 2, 3, 4] }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
async "should make example fail before async block reached" do
|
31
|
+
expect {
|
32
|
+
expect(:foo).to eq(:baz)
|
33
|
+
}.to raise_error(Exception)
|
34
|
+
|
35
|
+
set_timeout(0) do
|
36
|
+
run_async { expect(42).to eq(42) }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/spec/example_spec.rb
CHANGED
@@ -90,6 +90,16 @@ describe Hash do
|
|
90
90
|
it "should create a new instance of subject for classes" do
|
91
91
|
subject.should == {}
|
92
92
|
end
|
93
|
+
|
94
|
+
it "provides the subject as the described_class" do
|
95
|
+
expect(described_class).to eq(Hash)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe [1, 2, 3] do
|
100
|
+
it "can use an object instance as a subject" do
|
101
|
+
expect(subject).to eq([1, 2, 3])
|
102
|
+
end
|
93
103
|
end
|
94
104
|
|
95
105
|
describe "Simple expectations" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Beynon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -63,13 +63,6 @@ files:
|
|
63
63
|
- README.md
|
64
64
|
- Rakefile
|
65
65
|
- app/rspec-builder.rb
|
66
|
-
- app/rspec/core.rb
|
67
|
-
- app/rspec/core/configuration.rb
|
68
|
-
- app/rspec/core/example_group.rb
|
69
|
-
- app/rspec/core/project_initializer.rb
|
70
|
-
- app/rspec/core/shared_example_group.rb
|
71
|
-
- app/rspec/core/shared_example_group/collection.rb
|
72
|
-
- app/rspec/matchers/built_in/have.rb
|
73
66
|
- config.ru
|
74
67
|
- lib/opal-rspec.rb
|
75
68
|
- lib/opal/rspec.rb
|
@@ -78,11 +71,13 @@ files:
|
|
78
71
|
- opal-rspec.gemspec
|
79
72
|
- opal/opal-rspec.rb
|
80
73
|
- opal/opal/rspec.rb
|
74
|
+
- opal/opal/rspec/async.rb
|
81
75
|
- opal/opal/rspec/browser_formatter.rb
|
82
76
|
- opal/opal/rspec/fixes.rb
|
83
77
|
- opal/opal/rspec/runner.rb
|
84
78
|
- opal/opal/rspec/sprockets_runner.rb.erb
|
85
79
|
- opal/opal/rspec/text_formatter.rb
|
80
|
+
- spec/async_spec.rb
|
86
81
|
- spec/example_spec.rb
|
87
82
|
- spec/matchers_spec.rb
|
88
83
|
- vendor/spec_runner.js
|