opal-rspec 0.2.0 → 0.2.1
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/README.md +36 -0
- data/example/Gemfile +4 -0
- data/example/README.md +13 -0
- data/example/Rakefile +8 -0
- data/example/opal/user.rb +11 -0
- data/example/spec/user_spec.rb +15 -0
- data/lib/opal/rspec/version.rb +1 -1
- data/opal-rspec.gemspec +1 -1
- data/opal/opal/rspec/fixes.rb +16 -0
- data/spec/mock_spec.rb +5 -0
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a7488ad47abebb8001e48deb75b5369e83b4424
|
4
|
+
data.tar.gz: abea36a3490465840454bb5cc00abab1997ec64c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdd3f0a30d5f98e2d9058ebe162183b25007d59a8b1678666d4d6d92eb65b93b3935943ba7ecba26a5d149833a12d794a949faabd9f16d90ac2030f4fe0aea2a
|
7
|
+
data.tar.gz: c1546b0df5f69836e96fb0cf1d73fdb46f140efa2da1488816922da94395c32d9c315cc1896e4f855801e3c2f99235fae18d067677a8761e294e36bf04c6f2e8
|
data/README.md
CHANGED
@@ -45,6 +45,42 @@ run Opal::Server.new { |s|
|
|
45
45
|
Then run the rack server `bundle exec rackup` and visit `http://localhost:9292`
|
46
46
|
in any web browser.
|
47
47
|
|
48
|
+
## Async examples
|
49
|
+
|
50
|
+
`opal-rspec` adds support for async specs to rspec. These specs are defined using
|
51
|
+
`#async` instead of `#it`:
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
describe MyClass do
|
55
|
+
# normal example
|
56
|
+
it 'does something' do
|
57
|
+
expect(:foo).to eq(:foo)
|
58
|
+
end
|
59
|
+
|
60
|
+
# async example
|
61
|
+
async 'does something else, too' do
|
62
|
+
# ...
|
63
|
+
end
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
This just marks the example as running async. To actually handle the async result,
|
68
|
+
you also need to use a `run_async` call inside some future handler:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
async 'HTTP requests should work' do
|
72
|
+
HTTP.get('/users/1.json') do |res|
|
73
|
+
run_async {
|
74
|
+
expect(res).to be_ok
|
75
|
+
}
|
76
|
+
end
|
77
|
+
end
|
78
|
+
```
|
79
|
+
|
80
|
+
The block passed to `run_async` informs the runner that this spec is finished
|
81
|
+
so it can move on. Any failures/expectations run inside this block will be run
|
82
|
+
in the context of the example.
|
83
|
+
|
48
84
|
## Contributing
|
49
85
|
|
50
86
|
Install required gems at required versions:
|
data/example/Gemfile
ADDED
data/example/README.md
ADDED
data/example/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'user'
|
2
|
+
|
3
|
+
describe User do
|
4
|
+
it '#initialize accepts a name' do
|
5
|
+
expect(User.new('Jim').name).to eq('Jim')
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'is an admin if name is Bob' do
|
9
|
+
expect(User.new('Bob')).to be_admin
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'is not an admin if name is not Bob' do
|
13
|
+
expect(User.new('Jim')).to_not be_admin
|
14
|
+
end
|
15
|
+
end
|
data/lib/opal/rspec/version.rb
CHANGED
data/opal-rspec.gemspec
CHANGED
data/opal/opal/rspec/fixes.rb
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
# Opal defines enumerable#flat_map, but doesnt implement it
|
2
|
+
module RSpec::Core::FlatMap
|
3
|
+
def flat_map(array)
|
4
|
+
array.map { |item| yield item }.flatten
|
5
|
+
end
|
6
|
+
|
7
|
+
module_function :flat_map
|
8
|
+
end
|
9
|
+
|
10
|
+
# This breaks on 2.0.0, so it is here ready for when opal bumps to 2.0.0
|
11
|
+
class RSpec::CallerFilter
|
12
|
+
def self.first_non_rspec_line
|
13
|
+
""
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
1
17
|
# String#<< is not supported by Opal
|
2
18
|
module RSpec::Expectations
|
3
19
|
def self.fail_with(message, expected = nil, actual = nil)
|
data/spec/mock_spec.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.1
|
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-
|
11
|
+
date: 2013-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.5.
|
19
|
+
version: 0.5.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.5.
|
26
|
+
version: 0.5.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: opal-sprockets
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -64,6 +64,11 @@ files:
|
|
64
64
|
- Rakefile
|
65
65
|
- app/rspec-builder.rb
|
66
66
|
- config.ru
|
67
|
+
- example/Gemfile
|
68
|
+
- example/README.md
|
69
|
+
- example/Rakefile
|
70
|
+
- example/opal/user.rb
|
71
|
+
- example/spec/user_spec.rb
|
67
72
|
- lib/opal-rspec.rb
|
68
73
|
- lib/opal/rspec.rb
|
69
74
|
- lib/opal/rspec/rake_task.rb
|