opal-rspec-cj 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/.gitmodules +15 -0
  4. data/.travis.yml +13 -0
  5. data/.yardopts +5 -0
  6. data/CHANGELOG.md +25 -0
  7. data/Gemfile +8 -0
  8. data/README.md +147 -0
  9. data/Rakefile +26 -0
  10. data/config.ru +10 -0
  11. data/example/Gemfile +4 -0
  12. data/example/README.md +13 -0
  13. data/example/Rakefile +8 -0
  14. data/example/opal/user.rb +11 -0
  15. data/example/spec/user_spec.rb +15 -0
  16. data/lib/opal-rspec.rb +2 -0
  17. data/lib/opal/rspec.rb +20 -0
  18. data/lib/opal/rspec/rake_task.rb +63 -0
  19. data/lib/opal/rspec/version.rb +5 -0
  20. data/opal-rspec.gemspec +21 -0
  21. data/opal/opal-rspec.rb +1 -0
  22. data/opal/opal/rspec.rb +25 -0
  23. data/opal/opal/rspec/async.rb +289 -0
  24. data/opal/opal/rspec/browser_formatter.rb +188 -0
  25. data/opal/opal/rspec/fixes.rb +116 -0
  26. data/opal/opal/rspec/requires.rb +45 -0
  27. data/opal/opal/rspec/runner.rb +69 -0
  28. data/opal/opal/rspec/sprockets_runner.rb.erb +11 -0
  29. data/opal/opal/rspec/text_formatter.rb +74 -0
  30. data/spec/async_spec.rb +38 -0
  31. data/spec/example_spec.rb +163 -0
  32. data/spec/matchers_spec.rb +201 -0
  33. data/spec/mock_spec.rb +63 -0
  34. data/spec/named_subject_spec.rb +11 -0
  35. data/spec/should_syntax_spec.rb +17 -0
  36. data/vendor/spec_runner.js +50 -0
  37. data/vendor_lib/rspec-expectations.rb +1 -0
  38. data/vendor_lib/rspec.rb +3 -0
  39. data/vendor_lib/rspec/autorun.rb +2 -0
  40. data/vendor_lib/rspec/core.rb +203 -0
  41. data/vendor_lib/rspec/core/backport_random.rb +302 -0
  42. data/vendor_lib/rspec/core/backtrace_formatter.rb +65 -0
  43. data/vendor_lib/rspec/core/command_line.rb +36 -0
  44. data/vendor_lib/rspec/core/configuration.rb +1129 -0
  45. data/vendor_lib/rspec/core/configuration_options.rb +143 -0
  46. data/vendor_lib/rspec/core/drb_command_line.rb +26 -0
  47. data/vendor_lib/rspec/core/drb_options.rb +87 -0
  48. data/vendor_lib/rspec/core/dsl.rb +26 -0
  49. data/vendor_lib/rspec/core/example.rb +312 -0
  50. data/vendor_lib/rspec/core/example_group.rb +540 -0
  51. data/vendor_lib/rspec/core/filter_manager.rb +224 -0
  52. data/vendor_lib/rspec/core/flat_map.rb +17 -0
  53. data/vendor_lib/rspec/core/formatters.rb +54 -0
  54. data/vendor_lib/rspec/core/formatters/base_formatter.rb +291 -0
  55. data/vendor_lib/rspec/core/formatters/base_text_formatter.rb +307 -0
  56. data/vendor_lib/rspec/core/formatters/deprecation_formatter.rb +193 -0
  57. data/vendor_lib/rspec/core/formatters/documentation_formatter.rb +67 -0
  58. data/vendor_lib/rspec/core/formatters/helpers.rb +82 -0
  59. data/vendor_lib/rspec/core/formatters/html_formatter.rb +155 -0
  60. data/vendor_lib/rspec/core/formatters/html_printer.rb +408 -0
  61. data/vendor_lib/rspec/core/formatters/json_formatter.rb +99 -0
  62. data/vendor_lib/rspec/core/formatters/progress_formatter.rb +32 -0
  63. data/vendor_lib/rspec/core/formatters/snippet_extractor.rb +101 -0
  64. data/vendor_lib/rspec/core/hooks.rb +535 -0
  65. data/vendor_lib/rspec/core/memoized_helpers.rb +431 -0
  66. data/vendor_lib/rspec/core/metadata.rb +313 -0
  67. data/vendor_lib/rspec/core/mocking/with_absolutely_nothing.rb +11 -0
  68. data/vendor_lib/rspec/core/mocking/with_flexmock.rb +27 -0
  69. data/vendor_lib/rspec/core/mocking/with_mocha.rb +52 -0
  70. data/vendor_lib/rspec/core/mocking/with_rr.rb +27 -0
  71. data/vendor_lib/rspec/core/mocking/with_rspec.rb +27 -0
  72. data/vendor_lib/rspec/core/option_parser.rb +234 -0
  73. data/vendor_lib/rspec/core/ordering.rb +154 -0
  74. data/vendor_lib/rspec/core/pending.rb +110 -0
  75. data/vendor_lib/rspec/core/project_initializer.rb +88 -0
  76. data/vendor_lib/rspec/core/rake_task.rb +128 -0
  77. data/vendor_lib/rspec/core/reporter.rb +132 -0
  78. data/vendor_lib/rspec/core/ruby_project.rb +44 -0
  79. data/vendor_lib/rspec/core/runner.rb +97 -0
  80. data/vendor_lib/rspec/core/shared_context.rb +53 -0
  81. data/vendor_lib/rspec/core/shared_example_group.rb +146 -0
  82. data/vendor_lib/rspec/core/shared_example_group/collection.rb +27 -0
  83. data/vendor_lib/rspec/core/version.rb +7 -0
  84. data/vendor_lib/rspec/core/warnings.rb +22 -0
  85. data/vendor_lib/rspec/core/world.rb +131 -0
  86. data/vendor_lib/rspec/expectations.rb +75 -0
  87. data/vendor_lib/rspec/expectations/differ.rb +154 -0
  88. data/vendor_lib/rspec/expectations/errors.rb +9 -0
  89. data/vendor_lib/rspec/expectations/expectation_target.rb +87 -0
  90. data/vendor_lib/rspec/expectations/extensions.rb +1 -0
  91. data/vendor_lib/rspec/expectations/extensions/object.rb +29 -0
  92. data/vendor_lib/rspec/expectations/fail_with.rb +79 -0
  93. data/vendor_lib/rspec/expectations/handler.rb +68 -0
  94. data/vendor_lib/rspec/expectations/syntax.rb +182 -0
  95. data/vendor_lib/rspec/expectations/version.rb +8 -0
  96. data/vendor_lib/rspec/matchers.rb +633 -0
  97. data/vendor_lib/rspec/matchers/built_in.rb +39 -0
  98. data/vendor_lib/rspec/matchers/built_in/base_matcher.rb +68 -0
  99. data/vendor_lib/rspec/matchers/built_in/be.rb +213 -0
  100. data/vendor_lib/rspec/matchers/built_in/be_instance_of.rb +15 -0
  101. data/vendor_lib/rspec/matchers/built_in/be_kind_of.rb +11 -0
  102. data/vendor_lib/rspec/matchers/built_in/be_within.rb +55 -0
  103. data/vendor_lib/rspec/matchers/built_in/change.rb +141 -0
  104. data/vendor_lib/rspec/matchers/built_in/cover.rb +21 -0
  105. data/vendor_lib/rspec/matchers/built_in/eq.rb +22 -0
  106. data/vendor_lib/rspec/matchers/built_in/eql.rb +23 -0
  107. data/vendor_lib/rspec/matchers/built_in/equal.rb +48 -0
  108. data/vendor_lib/rspec/matchers/built_in/exist.rb +26 -0
  109. data/vendor_lib/rspec/matchers/built_in/has.rb +48 -0
  110. data/vendor_lib/rspec/matchers/built_in/include.rb +61 -0
  111. data/vendor_lib/rspec/matchers/built_in/match.rb +17 -0
  112. data/vendor_lib/rspec/matchers/built_in/match_array.rb +51 -0
  113. data/vendor_lib/rspec/matchers/built_in/raise_error.rb +154 -0
  114. data/vendor_lib/rspec/matchers/built_in/respond_to.rb +74 -0
  115. data/vendor_lib/rspec/matchers/built_in/satisfy.rb +30 -0
  116. data/vendor_lib/rspec/matchers/built_in/start_and_end_with.rb +48 -0
  117. data/vendor_lib/rspec/matchers/built_in/throw_symbol.rb +94 -0
  118. data/vendor_lib/rspec/matchers/built_in/yield.rb +297 -0
  119. data/vendor_lib/rspec/matchers/compatibility.rb +14 -0
  120. data/vendor_lib/rspec/matchers/configuration.rb +113 -0
  121. data/vendor_lib/rspec/matchers/dsl.rb +23 -0
  122. data/vendor_lib/rspec/matchers/generated_descriptions.rb +35 -0
  123. data/vendor_lib/rspec/matchers/matcher.rb +301 -0
  124. data/vendor_lib/rspec/matchers/method_missing.rb +12 -0
  125. data/vendor_lib/rspec/matchers/operator_matcher.rb +99 -0
  126. data/vendor_lib/rspec/matchers/pretty.rb +70 -0
  127. data/vendor_lib/rspec/matchers/test_unit_integration.rb +11 -0
  128. data/vendor_lib/rspec/mocks.rb +100 -0
  129. data/vendor_lib/rspec/mocks/any_instance/chain.rb +92 -0
  130. data/vendor_lib/rspec/mocks/any_instance/expectation_chain.rb +47 -0
  131. data/vendor_lib/rspec/mocks/any_instance/message_chains.rb +75 -0
  132. data/vendor_lib/rspec/mocks/any_instance/recorder.rb +200 -0
  133. data/vendor_lib/rspec/mocks/any_instance/stub_chain.rb +45 -0
  134. data/vendor_lib/rspec/mocks/any_instance/stub_chain_chain.rb +23 -0
  135. data/vendor_lib/rspec/mocks/argument_list_matcher.rb +104 -0
  136. data/vendor_lib/rspec/mocks/argument_matchers.rb +264 -0
  137. data/vendor_lib/rspec/mocks/arity_calculator.rb +66 -0
  138. data/vendor_lib/rspec/mocks/configuration.rb +111 -0
  139. data/vendor_lib/rspec/mocks/error_generator.rb +203 -0
  140. data/vendor_lib/rspec/mocks/errors.rb +12 -0
  141. data/vendor_lib/rspec/mocks/example_methods.rb +201 -0
  142. data/vendor_lib/rspec/mocks/extensions/marshal.rb +17 -0
  143. data/vendor_lib/rspec/mocks/framework.rb +36 -0
  144. data/vendor_lib/rspec/mocks/instance_method_stasher.rb +112 -0
  145. data/vendor_lib/rspec/mocks/matchers/have_received.rb +99 -0
  146. data/vendor_lib/rspec/mocks/matchers/receive.rb +112 -0
  147. data/vendor_lib/rspec/mocks/matchers/receive_messages.rb +72 -0
  148. data/vendor_lib/rspec/mocks/message_expectation.rb +643 -0
  149. data/vendor_lib/rspec/mocks/method_double.rb +209 -0
  150. data/vendor_lib/rspec/mocks/method_reference.rb +95 -0
  151. data/vendor_lib/rspec/mocks/mock.rb +7 -0
  152. data/vendor_lib/rspec/mocks/mutate_const.rb +406 -0
  153. data/vendor_lib/rspec/mocks/object_reference.rb +90 -0
  154. data/vendor_lib/rspec/mocks/order_group.rb +82 -0
  155. data/vendor_lib/rspec/mocks/proxy.rb +269 -0
  156. data/vendor_lib/rspec/mocks/proxy_for_nil.rb +37 -0
  157. data/vendor_lib/rspec/mocks/space.rb +95 -0
  158. data/vendor_lib/rspec/mocks/standalone.rb +3 -0
  159. data/vendor_lib/rspec/mocks/stub_chain.rb +51 -0
  160. data/vendor_lib/rspec/mocks/syntax.rb +374 -0
  161. data/vendor_lib/rspec/mocks/targets.rb +90 -0
  162. data/vendor_lib/rspec/mocks/test_double.rb +109 -0
  163. data/vendor_lib/rspec/mocks/verifying_double.rb +77 -0
  164. data/vendor_lib/rspec/mocks/verifying_message_expecation.rb +60 -0
  165. data/vendor_lib/rspec/mocks/verifying_proxy.rb +151 -0
  166. data/vendor_lib/rspec/mocks/version.rb +7 -0
  167. data/vendor_lib/rspec/support.rb +6 -0
  168. data/vendor_lib/rspec/support/caller_filter.rb +56 -0
  169. data/vendor_lib/rspec/support/spec.rb +14 -0
  170. data/vendor_lib/rspec/support/spec/deprecation_helpers.rb +29 -0
  171. data/vendor_lib/rspec/support/spec/in_sub_process.rb +40 -0
  172. data/vendor_lib/rspec/support/spec/stderr_splitter.rb +50 -0
  173. data/vendor_lib/rspec/support/version.rb +7 -0
  174. data/vendor_lib/rspec/support/warnings.rb +41 -0
  175. data/vendor_lib/rspec/version.rb +5 -0
  176. metadata +268 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2b3bffac0fd599819976d04e565530faeb4476b4
4
+ data.tar.gz: 0ced8be11b11b5beb051cb988aa6773e76258b62
5
+ SHA512:
6
+ metadata.gz: ef67bb1aec1bec9edac59b9529d5cd9f266e35edbe18282fb6609959cf4711535947d1138c2987f0d6237a9bdc4d7f18195fc1f60cb5eaea8c880d655da8038a
7
+ data.tar.gz: 00e6c97b347063e75c1106557852796d3442b2a85314e26ff50d8ebc182c41fe24fde41cf9e836bd46601b76e16a11c417d0ab458088472334dddcf05fa6d97c
@@ -0,0 +1,3 @@
1
+ .DS_Store
2
+ Gemfile.lock
3
+ *.gem
@@ -0,0 +1,15 @@
1
+ [submodule "rspec"]
2
+ path = rspec
3
+ url = https://github.com/rspec/rspec.git
4
+ [submodule "rspec-support"]
5
+ path = rspec-support
6
+ url = https://github.com/rspec/rspec-support.git
7
+ [submodule "rspec-core"]
8
+ path = rspec-core
9
+ url = https://github.com/rspec/rspec-core.git
10
+ [submodule "rspec-mocks"]
11
+ path = rspec-mocks
12
+ url = https://github.com/rspec/rspec-mocks.git
13
+ [submodule "rspec-expectations"]
14
+ path = rspec-expectations
15
+ url = https://github.com/rspec/rspec-expectations.git
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ sudo: false
3
+
4
+ rvm:
5
+ - 1.9.3
6
+ - 2.0.0
7
+ - 2.1.0
8
+
9
+ before_install:
10
+ - git submodule update --init
11
+
12
+ notifications:
13
+ irc: "irc.freenode.org#opal"
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ opal/**/*.rb
3
+ --markup markdown
4
+ -
5
+ CHANGELOG.md
@@ -0,0 +1,25 @@
1
+ ## 0.4.3 (2015-06-14)
2
+
3
+ * Allow the gem to be run under Opal 0.7 and 0.8
4
+ * Fix some threading issues
5
+ * Avoid some other calls to mutable-strings methods
6
+
7
+ ## 0.4.2 (2015-03-28)
8
+
9
+ * Avoid phantomjs warning messages
10
+
11
+ ## 0.4.1
12
+
13
+ * Remove predicate matcher fixes as Opal supports $1..$9 special gvars.
14
+
15
+ * Update Opal dependency for ~> 0.6.0.
16
+
17
+ * Remove double-escaping in inline x-strings (from Opal bug fix).
18
+
19
+ * Remove opal-sprockets dependency - build tools now part of opal.
20
+
21
+ * Replaced browser formatter to use html printer from rspec
22
+
23
+ * Add timeout support to asynchronous specs
24
+
25
+ ## 0.2.1 November 24, 2013
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ gem 'rspec', path: 'rspec'
5
+ gem 'rspec-support', path: 'rspec-support'
6
+ gem 'rspec-core', path: 'rspec-core'
7
+ gem 'rspec-mocks', path: 'rspec-mocks'
8
+ gem 'rspec-expectations', path: 'rspec-expectations'
@@ -0,0 +1,147 @@
1
+ # opal-rspec
2
+
3
+ [![Build Status](http://img.shields.io/travis/opal/opal-rspec/master.svg?style=flat)](http://travis-ci.org/opal/opal-rspec)
4
+
5
+ An attempt at a compatibility layer of rspec for opal.
6
+
7
+ [See the website for documentation](http://opalrb.org/docs/rspec/).
8
+
9
+ ## Usage
10
+
11
+ Add `opal-rspec` to your Gemfile:
12
+
13
+ ```ruby
14
+ gem 'opal-rspec'
15
+ ```
16
+
17
+ ### Run specs in phantomjs
18
+
19
+ To run specs, a rake task can be added which will load all spec files from
20
+ `spec/`:
21
+
22
+ ```ruby
23
+ require 'opal/rspec/rake_task'
24
+ Opal::RSpec::RakeTask.new(:default)
25
+ ```
26
+
27
+ Then, to run your specs inside phantomjs, just run the rake task:
28
+
29
+ ```
30
+ bundle exec rake
31
+ ```
32
+
33
+ ### Run specs in a browser
34
+
35
+ `opal-rspec` can use sprockets to build and serve specs over a simple rack
36
+ server. Add the following to a `config.ru` file:
37
+
38
+ ```ruby
39
+ require 'bundler'
40
+ Bundler.require
41
+
42
+ run Opal::Server.new { |s|
43
+ s.main = 'opal/rspec/sprockets_runner'
44
+ s.append_path 'spec'
45
+ s.debug = false
46
+ }
47
+ ```
48
+
49
+ Then run the rack server `bundle exec rackup` and visit `http://localhost:9292`
50
+ in any web browser.
51
+
52
+ ## Async examples
53
+
54
+ `opal-rspec` adds support for async specs to rspec. These specs are defined using
55
+ `#async` instead of `#it`:
56
+
57
+ ```ruby
58
+ describe MyClass do
59
+ # normal example
60
+ it 'does something' do
61
+ expect(:foo).to eq(:foo)
62
+ end
63
+
64
+ # async example
65
+ async 'does something else, too' do
66
+ # ...
67
+ end
68
+ end
69
+ ```
70
+
71
+ This just marks the example as running async. To actually handle the async result,
72
+ you also need to use a `run_async` call inside some future handler:
73
+
74
+ ```ruby
75
+ async 'HTTP requests should work' do
76
+ HTTP.get('/users/1.json') do |res|
77
+ run_async {
78
+ expect(res).to be_ok
79
+ }
80
+ end
81
+ end
82
+ ```
83
+
84
+ The block passed to `run_async` informs the runner that this spec is finished
85
+ so it can move on. Any failures/expectations run inside this block will be run
86
+ in the context of the example.
87
+
88
+ ## Contributing
89
+
90
+ Install required gems at required versions:
91
+
92
+ $ bundle install
93
+
94
+ opal-rspec uses a prebuilt version of rspec to fix the areas where
95
+ opal cannot handle certain features of rspec. To build that file,
96
+ which is needed to run specs, use:
97
+
98
+ $ bundle exec rake build
99
+
100
+ This should build `opal/opal/rspec/rspec.js` ready to use.
101
+
102
+ ### Run on command line
103
+
104
+ A simple rake task should run the example specs in `spec/`:
105
+
106
+ $ bundle exec rake
107
+
108
+ ### Run in the browser
109
+
110
+ Run attached rack app to handle building:
111
+
112
+ $ bundle exec rackup
113
+
114
+ Visit the page in any browser and view the console:
115
+
116
+ $ open http://localhost:9292
117
+
118
+ ## Things to fix
119
+
120
+ `opal/opal-rspec/fixes.rb` contains a few bug fixes that need to be merged upstream
121
+ to opal itself. `app/rspec-builder.rb` is used to precompile rspec ready to be used
122
+ in `opal-rspec`. All requires from `core.rb` have been inlined as opal cannot require
123
+ dynamically at runtime.
124
+
125
+ ## License
126
+
127
+ (The MIT License)
128
+
129
+ Copyright (C) 2013 by Adam Beynon
130
+
131
+ Permission is hereby granted, free of charge, to any person obtaining a copy
132
+ of this software and associated documentation files (the "Software"), to deal
133
+ in the Software without restriction, including without limitation the rights
134
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
135
+ copies of the Software, and to permit persons to whom the Software is
136
+ furnished to do so, subject to the following conditions:
137
+
138
+ The above copyright notice and this permission notice shall be included in
139
+ all copies or substantial portions of the Software.
140
+
141
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
142
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
143
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
144
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
145
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
146
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
147
+ THE SOFTWARE.
@@ -0,0 +1,26 @@
1
+ require 'bundler'
2
+ Bundler.require
3
+
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ require 'opal/rspec/rake_task'
7
+ Opal::RSpec::RakeTask.new(:default)
8
+
9
+
10
+ require 'fileutils'
11
+ desc "Copy RSpec sources"
12
+ task :copy_rspec do
13
+ gems = %w(rspec rspec-core rspec-expectations rspec-mocks rspec-support)
14
+
15
+ gems.each do |gem|
16
+ spec = Gem::Specification.find_by_name gem
17
+ lib = File.join spec.gem_dir, 'lib'
18
+
19
+ Dir["#{lib}/**/*.rb"].each do |file|
20
+ out = file.sub(/^#{lib}\//, 'opal/')
21
+
22
+ FileUtils.mkdir_p File.dirname(out)
23
+ FileUtils.cp file, out
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,10 @@
1
+ require 'bundler'
2
+ Bundler.require
3
+
4
+ Opal::Processor.source_map_enabled = false
5
+
6
+ run Opal::Server.new { |s|
7
+ s.main = 'opal/rspec/sprockets_runner'
8
+ s.append_path 'spec'
9
+ s.debug = false
10
+ }
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake'
4
+ gem 'opal-rspec', :path => '../'
@@ -0,0 +1,13 @@
1
+ # opal-spec example
2
+
3
+ Install dependencies:
4
+
5
+ ```
6
+ bundle install
7
+ ```
8
+
9
+ Run examples:
10
+
11
+ ```
12
+ bundle exec rake
13
+ ```
@@ -0,0 +1,8 @@
1
+ require 'bundler'
2
+ Bundler.require
3
+
4
+ # Add our opal/ directory to the load path
5
+ Opal.append_path File.expand_path('../opal', __FILE__)
6
+
7
+ require 'opal/rspec/rake_task'
8
+ Opal::RSpec::RakeTask.new(:default)
@@ -0,0 +1,11 @@
1
+ class User
2
+ attr_accessor :name
3
+
4
+ def initialize(name)
5
+ @name = name
6
+ end
7
+
8
+ def admin?
9
+ @name == 'Bob'
10
+ end
11
+ end
@@ -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
@@ -0,0 +1,2 @@
1
+ require 'opal/rspec'
2
+
@@ -0,0 +1,20 @@
1
+ require 'opal'
2
+ require 'opal/rspec/version'
3
+
4
+ # Just register our opal code path with opal build tools
5
+ Opal.append_path File.expand_path('../../../opal', __FILE__)
6
+ Opal.append_path File.expand_path('../../../vendor_lib', __FILE__)
7
+
8
+ Opal::Processor.dynamic_require_severity = :ignore
9
+
10
+ Opal::Processor.stub_file "rspec/matchers/built_in/have"
11
+ Opal::Processor.stub_file "diff/lcs"
12
+ Opal::Processor.stub_file "diff/lcs/hunk"
13
+ Opal::Processor.stub_file "fileutils"
14
+ Opal::Processor.stub_file "test/unit/assertions"
15
+ Opal::Processor.stub_file "coderay"
16
+ Opal::Processor.stub_file "optparse"
17
+ Opal::Processor.stub_file "shellwords"
18
+ Opal::Processor.stub_file "socket"
19
+ Opal::Processor.stub_file "uri"
20
+ Opal::Processor.stub_file "drb/drb"
@@ -0,0 +1,63 @@
1
+ require 'opal/rspec'
2
+
3
+ module Opal
4
+ module RSpec
5
+ class RakeTask
6
+ include Rake::DSL if defined? Rake::DSL
7
+
8
+ RUNNER = File.expand_path('../../../../vendor/spec_runner.js', __FILE__)
9
+ PORT = 9999
10
+ URL = "http://localhost:9999/"
11
+
12
+ def initialize(name = 'opal:rspec', spec_app = false, &block)
13
+ desc "Run opal specs in phantomjs"
14
+ task name do
15
+ require 'rack'
16
+ require 'webrick'
17
+
18
+ apps = []
19
+ apps << app = Opal::Server.new { |s|
20
+ s.main = 'opal/rspec/sprockets_runner'
21
+ s.append_path 'spec'
22
+ s.debug = false
23
+
24
+ block.call s if block_given?
25
+ }
26
+
27
+ apps << Object.const_get(spec_app.to_s) if spec_app
28
+
29
+ server = Thread.new do
30
+ Thread.current.abort_on_exception = true
31
+ Rack::Server.start(
32
+ :app => Rack::Cascade.new([app, spec_app]),
33
+ :Port => PORT,
34
+ :AccessLog => [],
35
+ :Logger => WEBrick::Log.new("/dev/null"),
36
+ )
37
+ end
38
+
39
+ if `phantomjs -v`.strip.to_i >= 2
40
+ warn <<-WARN.gsub(/^ /,'')
41
+ Only PhantomJS v1 is currently supported,
42
+ if you're using homebrew on OSX you can switch version with:
43
+
44
+ brew switch phantomjs 1.9.8
45
+
46
+ WARN
47
+ exit 1
48
+ end
49
+
50
+ begin
51
+ system %Q{phantomjs #{RUNNER} "#{URL}"}
52
+ success = $?.success?
53
+
54
+ exit 1 unless success
55
+ ensure
56
+ server.kill
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+
@@ -0,0 +1,5 @@
1
+ module Opal
2
+ module RSpec
3
+ VERSION = '0.4.4'
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/opal/rspec/version', __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'opal-rspec-cj'
6
+ s.version = Opal::RSpec::VERSION
7
+ s.author = ['Adam Beynon', 'CJ Lazell']
8
+ s.email = ['adam.beynon@gmail.com', 'cjlazell@gmail.com']
9
+ s.homepage = 'http://opalrb.org'
10
+ s.summary = 'RSpec for Opal'
11
+ s.description = 'Opal compatible rspec library'
12
+
13
+ s.files = `git ls-files`.split("\n")
14
+
15
+ s.require_paths = ['lib']
16
+
17
+ s.add_dependency 'opal', ['>= 0.7.0', '< 0.9']
18
+ s.add_development_dependency 'rake'
19
+ s.add_development_dependency 'yard'
20
+ end
21
+