Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal-rspec
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cf0c36668100^
Choose a base ref
...
head repository: opal/opal-rspec
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c4f32ebec71c
Choose a head ref

Commits on May 13, 2015

  1. Not sure why this was ignored, pinning this is a good idea to always …

    …build with the same version
    wied03 committed May 13, 2015
    Copy the full SHA
    cf0c366 View commit details
  2. Opal 0.8

    wied03 committed May 13, 2015
    Copy the full SHA
    b272fd0 View commit details
  3. Copy the full SHA
    c8aa319 View commit details
  4. * Pin the Spec version using Git submodules

    * Remove vendor_lib reference since we can use the submodule directly
    * Add submodule files to the GEM explicitly since ls-files won't catch them
    * Don't need rake copy task anymore
    wied03 committed May 13, 2015
    Copy the full SHA
    dc4a6a5 View commit details
  5. Copy the full SHA
    5859a21 View commit details
  6. Copy the full SHA
    dfd7c6a View commit details
  7. Copy the full SHA
    1057ed1 View commit details

Commits on May 14, 2015

  1. Copy the full SHA
    688f8cf View commit details
  2. Revert "Went back to 3.0.0beta1 due to compat issues"

    This reverts commit dfd7c6a.
    wied03 committed May 14, 2015
    Copy the full SHA
    2199e06 View commit details
  3. Copy the full SHA
    78e534f View commit details
  4. Copy the full SHA
    53ab2d4 View commit details
  5. Need racer to do opal-repl

    wied03 committed May 14, 2015
    Copy the full SHA
    69e578f View commit details
  6. * Add a Rake task the attempts to flatten all of the requires RSpec e…

    …ventually does
    
    * Update the requires file with the results of that
    wied03 committed May 14, 2015
    Copy the full SHA
    5f63495 View commit details
  7. Copy the full SHA
    c93c624 View commit details
  8. Copy the full SHA
    d6134a5 View commit details
  9. Separate out better

    wied03 committed May 14, 2015
    Copy the full SHA
    8660ac1 View commit details
  10. Got past formatter issue by changing normalize code to look at file e…

    …xistence, not requiring
    wied03 committed May 14, 2015
    Copy the full SHA
    c1cce17 View commit details
  11. * Separate out formatters to reduce repetition

    * Added stuff formatters RSpec complained about
    wied03 committed May 14, 2015
    Copy the full SHA
    fa943b4 View commit details
  12. Updated with latest run

    wied03 committed May 14, 2015
    Copy the full SHA
    dbb4d4f View commit details
  13. Copy the full SHA
    525470e View commit details
  14. YKatz answered my question

    wied03 committed May 14, 2015
    Copy the full SHA
    906218d View commit details
  15. Copy the full SHA
    d06b1d1 View commit details
  16. Copy the full SHA
    4365972 View commit details

Commits on May 15, 2015

  1. Add a hack until this is fixed

    wied03 committed May 15, 2015
    Copy the full SHA
    4537834 View commit details
  2. Deal with thread usage

    wied03 committed May 15, 2015
    Copy the full SHA
    c578fba View commit details
  3. Need the mocking adapters

    wied03 committed May 15, 2015
    Copy the full SHA
    64c80a3 View commit details
  4. Better explanation

    wied03 committed May 15, 2015
    Copy the full SHA
    2b07410 View commit details
  5. Regenerate

    wied03 committed May 15, 2015
    Copy the full SHA
    cf40eb4 View commit details
  6. Copy the full SHA
    fd44eb3 View commit details
  7. Copy the full SHA
    49ece88 View commit details
  8. Copy the full SHA
    e1078a6 View commit details
  9. Handle Phantom cases

    wied03 committed May 15, 2015
    Copy the full SHA
    493c84e View commit details
  10. Adapt to newer hook notation

    wied03 committed May 15, 2015
    Copy the full SHA
    89dae08 View commit details
  11. * Adapt to new configuration/default_formatter setting

    * Add formatter register method calls to the Opal formatter classes
    * Remove progress formatter from our require list since it was gumming up things
    * Can now get the beginnings of results in the browser, but there are still some errors
    wied03 committed May 15, 2015
    Copy the full SHA
    1e7874e View commit details

Commits on May 17, 2015

  1. Added monkey patching to prevent string mutation in the deprecated fo…

    …rmatter (string mutation of course is not supported in Opal)
    wied03 committed May 17, 2015
    Copy the full SHA
    37366e7 View commit details

Commits on May 18, 2015

  1. * Notification gets sent now (not group)

    * Start adding dump_pending
    wied03 committed May 18, 2015
    Copy the full SHA
    df4e7c8 View commit details
  2. Added missing require

    wied03 committed May 18, 2015
    Copy the full SHA
    fb48b25 View commit details
  3. Remove what we're not handling

    wied03 committed May 18, 2015
    Copy the full SHA
    022996a View commit details
  4. Copy the full SHA
    22ce4dc View commit details
  5. Copy the full SHA
    d719509 View commit details
  6. * Fix unnecessary deprecation warnings

    * Fix real hash usage issues in formatters
    wied03 committed May 18, 2015
    Copy the full SHA
    bf93e23 View commit details
  7. Copy the full SHA
    13b2568 View commit details
  8. * Added missing notify requests

    * Adapt method to new API (notification is passed as param)
    * There is no super method for most of this
    wied03 committed May 18, 2015
    Copy the full SHA
    4dead2c View commit details
  9. Copy the full SHA
    35ad610 View commit details
  10. Copy the full SHA
    5774806 View commit details

Commits on May 19, 2015

  1. * Adapt to new methods (example instead of each)

    * Adapt to new run method signature (no more after_run_block)
    * I think the register method had to be tweaked to register the example with the example group. Otherwise, the group would not have children and the reporter would not notify the formatter that the group had started, so the formatter would fail when it received the example result
    wied03 committed May 19, 2015
    Copy the full SHA
    8ff941b View commit details
  2. Copy the full SHA
    df62107 View commit details
  3. Test for timeout override

    wied03 committed May 19, 2015
    Copy the full SHA
    68067d3 View commit details
  4. Copy the full SHA
    140a413 View commit details
  5. Copy the full SHA
    b5af9eb View commit details
Showing with 1,735 additions and 16,896 deletions.
  1. +1 −0 .gitignore
  2. +23 −1 CHANGELOG.md
  3. +6 −5 Gemfile
  4. +42 −16 README.md
  5. +109 −12 Rakefile
  6. +35 −12 lib/opal/rspec.rb
  7. +1 −1 lib/opal/rspec/version.rb
  8. +5 −2 opal-rspec.gemspec
  9. +2 −10 opal/opal/rspec.rb
  10. +3 −289 opal/opal/rspec/async.rb
  11. +87 −0 opal/opal/rspec/async/async_example.rb
  12. +94 −0 opal/opal/rspec/async/example_group.rb
  13. +46 −0 opal/opal/rspec/async/hooks.rb
  14. +55 −18 opal/opal/rspec/browser_formatter.rb
  15. +12 −80 opal/opal/rspec/fixes.rb
  16. +6 −0 opal/opal/rspec/fixes/caller_filter.rb
  17. +21 −0 opal/opal/rspec/fixes/example.rb
  18. +32 −0 opal/opal/rspec/fixes/example_groups.rb
  19. +21 −0 opal/opal/rspec/fixes/expectations.rb
  20. +50 −0 opal/opal/rspec/fixes/formatter.rb
  21. +34 −0 opal/opal/rspec/fixes/kernel.rb
  22. +15 −0 opal/opal/rspec/fixes/matchers.rb
  23. +13 −0 opal/opal/rspec/fixes/mocks.rb
  24. +12 −0 opal/opal/rspec/fixes/reporter.rb
  25. +4 −0 opal/opal/rspec/pre_require_fixes.rb
  26. +103 −35 opal/opal/rspec/requires.rb
  27. +19 −15 opal/opal/rspec/runner.rb
  28. +24 −10 opal/opal/rspec/text_formatter.rb
  29. +1 −1 rspec
  30. +1 −1 rspec-core
  31. +1 −1 rspec-expectations
  32. +1 −1 rspec-mocks
  33. +1 −1 rspec-support
  34. +140 −0 spec/after_hooks_spec.rb
  35. +223 −0 spec/around_hooks_spec.rb
  36. +113 −20 spec/async_spec.rb
  37. +183 −0 spec/before_hooks_spec.rb
  38. +11 −0 spec/example_spec.rb
  39. +4 −0 spec/matchers_spec.rb
  40. +6 −0 spec/mock_spec.rb
  41. +0 −11 spec/named_subject_spec.rb
  42. +43 −0 spec/skip_pending_spec.rb
  43. +87 −0 spec/subject_spec.rb
  44. +45 −0 util/create_requires.rb
  45. +0 −1 vendor_lib/rspec-expectations.rb
  46. +0 −3 vendor_lib/rspec.rb
  47. +0 −2 vendor_lib/rspec/autorun.rb
  48. +0 −203 vendor_lib/rspec/core.rb
  49. +0 −302 vendor_lib/rspec/core/backport_random.rb
  50. +0 −65 vendor_lib/rspec/core/backtrace_formatter.rb
  51. +0 −36 vendor_lib/rspec/core/command_line.rb
  52. +0 −1,129 vendor_lib/rspec/core/configuration.rb
  53. +0 −143 vendor_lib/rspec/core/configuration_options.rb
  54. +0 −26 vendor_lib/rspec/core/drb_command_line.rb
  55. +0 −87 vendor_lib/rspec/core/drb_options.rb
  56. +0 −26 vendor_lib/rspec/core/dsl.rb
  57. +0 −312 vendor_lib/rspec/core/example.rb
  58. +0 −540 vendor_lib/rspec/core/example_group.rb
  59. +0 −224 vendor_lib/rspec/core/filter_manager.rb
  60. +0 −17 vendor_lib/rspec/core/flat_map.rb
  61. +0 −54 vendor_lib/rspec/core/formatters.rb
  62. +0 −291 vendor_lib/rspec/core/formatters/base_formatter.rb
  63. +0 −307 vendor_lib/rspec/core/formatters/base_text_formatter.rb
  64. +0 −193 vendor_lib/rspec/core/formatters/deprecation_formatter.rb
  65. +0 −67 vendor_lib/rspec/core/formatters/documentation_formatter.rb
  66. +0 −82 vendor_lib/rspec/core/formatters/helpers.rb
  67. +0 −155 vendor_lib/rspec/core/formatters/html_formatter.rb
  68. +0 −408 vendor_lib/rspec/core/formatters/html_printer.rb
  69. +0 −99 vendor_lib/rspec/core/formatters/json_formatter.rb
  70. +0 −32 vendor_lib/rspec/core/formatters/progress_formatter.rb
  71. +0 −101 vendor_lib/rspec/core/formatters/snippet_extractor.rb
  72. +0 −535 vendor_lib/rspec/core/hooks.rb
  73. +0 −431 vendor_lib/rspec/core/memoized_helpers.rb
  74. +0 −313 vendor_lib/rspec/core/metadata.rb
  75. +0 −11 vendor_lib/rspec/core/mocking/with_absolutely_nothing.rb
  76. +0 −27 vendor_lib/rspec/core/mocking/with_flexmock.rb
  77. +0 −52 vendor_lib/rspec/core/mocking/with_mocha.rb
  78. +0 −27 vendor_lib/rspec/core/mocking/with_rr.rb
  79. +0 −27 vendor_lib/rspec/core/mocking/with_rspec.rb
  80. +0 −234 vendor_lib/rspec/core/option_parser.rb
  81. +0 −154 vendor_lib/rspec/core/ordering.rb
  82. +0 −110 vendor_lib/rspec/core/pending.rb
  83. +0 −88 vendor_lib/rspec/core/project_initializer.rb
  84. +0 −128 vendor_lib/rspec/core/rake_task.rb
  85. +0 −132 vendor_lib/rspec/core/reporter.rb
  86. +0 −44 vendor_lib/rspec/core/ruby_project.rb
  87. +0 −97 vendor_lib/rspec/core/runner.rb
  88. +0 −53 vendor_lib/rspec/core/shared_context.rb
  89. +0 −146 vendor_lib/rspec/core/shared_example_group.rb
  90. +0 −27 vendor_lib/rspec/core/shared_example_group/collection.rb
  91. +0 −7 vendor_lib/rspec/core/version.rb
  92. +0 −22 vendor_lib/rspec/core/warnings.rb
  93. +0 −131 vendor_lib/rspec/core/world.rb
  94. +0 −75 vendor_lib/rspec/expectations.rb
  95. +0 −154 vendor_lib/rspec/expectations/differ.rb
  96. +0 −9 vendor_lib/rspec/expectations/errors.rb
  97. +0 −87 vendor_lib/rspec/expectations/expectation_target.rb
  98. +0 −1 vendor_lib/rspec/expectations/extensions.rb
  99. +0 −29 vendor_lib/rspec/expectations/extensions/object.rb
  100. +0 −79 vendor_lib/rspec/expectations/fail_with.rb
  101. +0 −68 vendor_lib/rspec/expectations/handler.rb
  102. +0 −182 vendor_lib/rspec/expectations/syntax.rb
  103. +0 −8 vendor_lib/rspec/expectations/version.rb
  104. +0 −633 vendor_lib/rspec/matchers.rb
  105. +0 −39 vendor_lib/rspec/matchers/built_in.rb
  106. +0 −68 vendor_lib/rspec/matchers/built_in/base_matcher.rb
  107. +0 −213 vendor_lib/rspec/matchers/built_in/be.rb
  108. +0 −15 vendor_lib/rspec/matchers/built_in/be_instance_of.rb
  109. +0 −11 vendor_lib/rspec/matchers/built_in/be_kind_of.rb
  110. +0 −55 vendor_lib/rspec/matchers/built_in/be_within.rb
  111. +0 −141 vendor_lib/rspec/matchers/built_in/change.rb
  112. +0 −21 vendor_lib/rspec/matchers/built_in/cover.rb
  113. +0 −22 vendor_lib/rspec/matchers/built_in/eq.rb
  114. +0 −23 vendor_lib/rspec/matchers/built_in/eql.rb
  115. +0 −48 vendor_lib/rspec/matchers/built_in/equal.rb
  116. +0 −26 vendor_lib/rspec/matchers/built_in/exist.rb
  117. +0 −48 vendor_lib/rspec/matchers/built_in/has.rb
  118. +0 −61 vendor_lib/rspec/matchers/built_in/include.rb
  119. +0 −17 vendor_lib/rspec/matchers/built_in/match.rb
  120. +0 −51 vendor_lib/rspec/matchers/built_in/match_array.rb
  121. +0 −154 vendor_lib/rspec/matchers/built_in/raise_error.rb
  122. +0 −74 vendor_lib/rspec/matchers/built_in/respond_to.rb
  123. +0 −30 vendor_lib/rspec/matchers/built_in/satisfy.rb
  124. +0 −48 vendor_lib/rspec/matchers/built_in/start_and_end_with.rb
  125. +0 −94 vendor_lib/rspec/matchers/built_in/throw_symbol.rb
  126. +0 −297 vendor_lib/rspec/matchers/built_in/yield.rb
  127. +0 −14 vendor_lib/rspec/matchers/compatibility.rb
  128. +0 −113 vendor_lib/rspec/matchers/configuration.rb
  129. +0 −23 vendor_lib/rspec/matchers/dsl.rb
  130. +0 −35 vendor_lib/rspec/matchers/generated_descriptions.rb
  131. +0 −301 vendor_lib/rspec/matchers/matcher.rb
  132. +0 −12 vendor_lib/rspec/matchers/method_missing.rb
  133. +0 −99 vendor_lib/rspec/matchers/operator_matcher.rb
  134. +0 −70 vendor_lib/rspec/matchers/pretty.rb
  135. +0 −11 vendor_lib/rspec/matchers/test_unit_integration.rb
  136. +0 −100 vendor_lib/rspec/mocks.rb
  137. +0 −92 vendor_lib/rspec/mocks/any_instance/chain.rb
  138. +0 −47 vendor_lib/rspec/mocks/any_instance/expectation_chain.rb
  139. +0 −75 vendor_lib/rspec/mocks/any_instance/message_chains.rb
  140. +0 −200 vendor_lib/rspec/mocks/any_instance/recorder.rb
  141. +0 −45 vendor_lib/rspec/mocks/any_instance/stub_chain.rb
  142. +0 −23 vendor_lib/rspec/mocks/any_instance/stub_chain_chain.rb
  143. +0 −104 vendor_lib/rspec/mocks/argument_list_matcher.rb
  144. +0 −264 vendor_lib/rspec/mocks/argument_matchers.rb
  145. +0 −66 vendor_lib/rspec/mocks/arity_calculator.rb
  146. +0 −111 vendor_lib/rspec/mocks/configuration.rb
  147. +0 −203 vendor_lib/rspec/mocks/error_generator.rb
  148. +0 −12 vendor_lib/rspec/mocks/errors.rb
  149. +0 −201 vendor_lib/rspec/mocks/example_methods.rb
  150. +0 −17 vendor_lib/rspec/mocks/extensions/marshal.rb
  151. +0 −36 vendor_lib/rspec/mocks/framework.rb
  152. +0 −112 vendor_lib/rspec/mocks/instance_method_stasher.rb
  153. +0 −99 vendor_lib/rspec/mocks/matchers/have_received.rb
  154. +0 −112 vendor_lib/rspec/mocks/matchers/receive.rb
  155. +0 −72 vendor_lib/rspec/mocks/matchers/receive_messages.rb
  156. +0 −643 vendor_lib/rspec/mocks/message_expectation.rb
  157. +0 −209 vendor_lib/rspec/mocks/method_double.rb
  158. +0 −95 vendor_lib/rspec/mocks/method_reference.rb
  159. +0 −7 vendor_lib/rspec/mocks/mock.rb
  160. +0 −406 vendor_lib/rspec/mocks/mutate_const.rb
  161. +0 −90 vendor_lib/rspec/mocks/object_reference.rb
  162. +0 −82 vendor_lib/rspec/mocks/order_group.rb
  163. +0 −269 vendor_lib/rspec/mocks/proxy.rb
  164. +0 −37 vendor_lib/rspec/mocks/proxy_for_nil.rb
  165. +0 −95 vendor_lib/rspec/mocks/space.rb
  166. +0 −3 vendor_lib/rspec/mocks/standalone.rb
  167. +0 −51 vendor_lib/rspec/mocks/stub_chain.rb
  168. +0 −374 vendor_lib/rspec/mocks/syntax.rb
  169. +0 −90 vendor_lib/rspec/mocks/targets.rb
  170. +0 −109 vendor_lib/rspec/mocks/test_double.rb
  171. +0 −77 vendor_lib/rspec/mocks/verifying_double.rb
  172. +0 −60 vendor_lib/rspec/mocks/verifying_message_expecation.rb
  173. +0 −151 vendor_lib/rspec/mocks/verifying_proxy.rb
  174. +0 −7 vendor_lib/rspec/mocks/version.rb
  175. +0 −6 vendor_lib/rspec/support.rb
  176. +0 −56 vendor_lib/rspec/support/caller_filter.rb
  177. +0 −14 vendor_lib/rspec/support/spec.rb
  178. +0 −29 vendor_lib/rspec/support/spec/deprecation_helpers.rb
  179. +0 −40 vendor_lib/rspec/support/spec/in_sub_process.rb
  180. +0 −50 vendor_lib/rspec/support/spec/stderr_splitter.rb
  181. +0 −7 vendor_lib/rspec/support/version.rb
  182. +0 −41 vendor_lib/rspec/support/warnings.rb
  183. +0 −5 vendor_lib/rspec/version.rb
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
Gemfile.lock
*.gem
Gemfile.lock
24 changes: 23 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
## edge
## 0.5.0 (edge)

* By default, any subject, it example block, before(:each), after(:each), and around that returns a promise will be executed asynchronously. Async is NOT yet supported for context level hooks.

* By default, any subject, it example block, before(:each), after(:each) that returns a promise will be executed asynchronously. Async is NOT yet supported for context hooks or around hooks

* Update to RSpec 3.1 (core is 3.1.7, expectations/support 3.1.2, mocks 3.1.3)

* Remove copy of source (and just rely on git submodule fetch)

## 0.4.3 (2015-06-14)

* Allow the gem to be run under Opal 0.7 and 0.8

* Fix some threading issues

* Avoid some other calls to mutable-strings methods

## 0.4.2 (2015-03-28)

* Avoid phantomjs warning messages

## 0.4.1

* Remove predicate matcher fixes as Opal supports $1..$9 special gvars.

11 changes: 6 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
source 'https://rubygems.org'
gemspec

gem 'rspec', path: 'rspec'
gem 'rspec-support', path: 'rspec-support'
gem 'rspec-core', path: 'rspec-core'
gem 'rspec-mocks', path: 'rspec-mocks'
gem 'rspec-expectations', path: 'rspec-expectations'
unless Dir['rspec{,-{core,expectations,mocks,support}}'].any?
warn 'Run: "git submodule update --init" to get RSpec sources'
end

# Opal 0.9 still in development
# gem 'opal', git: 'https://github.com/opal/opal.git'
58 changes: 42 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -62,28 +62,54 @@ describe MyClass do
end

# async example
async 'does something else, too' do
# ...
it 'does something else, too' do
promise = Promise.new
delay 1 do
expect(:foo).to eq(:foo)
promise.resolve
end
promise
end

it 'does another thing' do
# Argument is number of seconds, delay_with_promise is a convenience method that will
# call setTimeout with the block and return a promise
delay_with_promise 0 do
expect(:foo).to eq(:foo)
end
end
end
```

This just marks the example as running async. To actually handle the async result,
you also need to use a `run_async` call inside some future handler:

```ruby
async 'HTTP requests should work' do
HTTP.get('/users/1.json') do |res|
run_async {
expect(res).to be_ok
}
end
describe MyClass2 do
# will wait for the before promise to complete before proceeding
before do
delay_with_promise 0 do
puts 'async before 'action
end
end

# async subject works too
subject do
delay_with_promise 0 do
42
end
end

it { is_expected.to eq 42 }

# If you use an around block and have async specs, you must use this approach
around do |example|
puts 'do stuff before'
example.run.then do
puts 'do stuff after example'
end
end
end
```

The block passed to `run_async` informs the runner that this spec is finished
so it can move on. Any failures/expectations run inside this block will be run
in the context of the example.
Limitations:
* Right now, async before(:context) and after(:context) hooks cannot be async
* let dependencies cannot be async, only subject

## Contributing

121 changes: 109 additions & 12 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -4,23 +4,120 @@ Bundler.require
Bundler::GemHelper.install_tasks

require 'opal/rspec/rake_task'
Opal::RSpec::RakeTask.new(:default)
Opal::RSpec::RakeTask.new(:specs_untested)

desc 'Generates an RSpec requires file free of dynamic requires'
task :generate_requires do
# Do this free of any requires used to make this Rake task happen
sh 'ruby -Irspec/lib -Irspec-core/lib/rspec -Irspec-support/lib/rspec util/create_requires.rb'
end

task :default do
test_output = `rake specs_untested`
raise "Expected test runner to fail due to failed tests, but got return code of #{$?.exitstatus}" if $?.success?

count_match = /(\d+) examples, (\d+) failures, (\d+) pending/.match(test_output)
raise 'Expected a finished count of test failures/success/etc. but did not see it' unless count_match
total, failed, pending = count_match.captures

require 'fileutils'
desc "Copy RSpec sources"
task :copy_rspec do
gems = %w(rspec rspec-core rspec-expectations rspec-mocks rspec-support)
actual_failures = []
test_output.scan /\d+\) (.*)/ do |match|
actual_failures << match[0].strip
end
actual_failures.sort!

gems.each do |gem|
spec = Gem::Specification.find_by_name gem
lib = File.join spec.gem_dir, 'lib'
failure_messages = []

Dir["#{lib}/**/*.rb"].each do |file|
out = file.sub(/^#{lib}\//, 'opal/')
bad_strings = [/.*is still running, after block problem.*/,
/.*should not have.*/,
/.*Expected \d+ after hits but got \d+.*/,
/.*Expected \d+ around hits but got \d+.*/]

FileUtils.mkdir_p File.dirname(out)
FileUtils.cp file, out
bad_strings.each do |regex|
test_output.scan(regex) do |match|
failure_messages << "Expected not to see #{regex} in output, but found match #{match}"
end
end

expected_pending_count = 22

expected_failures= ['promise should make example fail properly before async block reached',
'promise matcher fails properly',
'promise non-assertion failure in promise no args',
'promise non-assertion failure in promise string arg',
'promise non-assertion failure in promise exception arg',
'pending in example no promise would not fail otherwise, thus fails properly',
'async/sync mix fails properly if a sync test is among async tests',
'async/sync mix can finish running after a long delay and fail properly',
'be_truthy fails properly with truthy values',
'subject sync unnamed assertion fails properly should eq 43',
'subject sync unnamed fails properly during subject create',
'subject async assertion implicit fails properly should eq 43',
'subject async fails properly during creation explicit async',
'subject async fails properly during creation implicit usage',
'subject async assertion explicit async fails properly',
'hooks around sync fails after example should equal 42',
'hooks around sync fails before example',
'hooks around async fails after example after(:each) async fails sync match passes',
'hooks around async fails after example after(:each) async passes sync match passes',
'hooks around async fails after example after(:each) sync fails sync match passes',
'hooks around async fails after example after(:each) sync passes sync match passes',
'hooks around async fails after example before(:each) fails should not reach the example',
'hooks around async fails after example matches another async match',
'hooks around async fails after example matches async match',
'hooks around async fails after example matches async match fails properly',
'hooks around async fails after example matches sync fails properly',
'hooks around async fails after example matches sync match',
'hooks around async fails before example after(:each) async fails sync match passes',
'hooks around async fails before example after(:each) async passes sync match passes',
'hooks around async fails before example after(:each) sync fails sync match passes',
'hooks around async fails before example after(:each) sync passes sync match passes',
'hooks around async fails before example before(:each) fails should not reach the example',
'hooks around async fails before example matches another async match',
'hooks around async fails before example matches async match',
'hooks around async fails before example matches async match fails properly',
'hooks around async fails before example matches sync fails properly',
'hooks around async fails before example matches sync match',
'hooks around async succeeds after(:each) async fails sync match passes',
'hooks around async succeeds after(:each) sync fails sync match passes',
'hooks around async succeeds before(:each) fails should not reach the example',
'hooks around async succeeds matches async match fails properly',
'hooks around async succeeds matches sync fails properly',
'hooks before async with async subject async match fails properly',
'hooks before async with async subject before :each fails properly should not reach the example',
'hooks before async with async subject before :each succeeds, assertion fails properly should not eq 42',
'hooks before async with async subject before :each succeeds, subject fails properly should not reach the example',
'hooks before async with async subject both subject and before(:each) fail properly should not reach the example',
'hooks before async with sync subject async match fails properly',
'hooks before async with sync subject before :each fails properly should not reach the example',
'hooks before async with sync subject match fails properly should not eq 42',
'hooks before sync with sync subject context fails properly should not reach the example',
'hooks before sync with sync subject before :each fails properly should not reach the example',
'hooks before sync with sync subject match fails properly should not eq 42',
'hooks before sync with sync subject first before :each in chain triggers failure inner context should not reach the example',
'hooks after sync after fails should eq 42',
'hooks after sync before fails should not reach the example',
'hooks after sync match fails async match',
'hooks after sync match fails sync match should eq 43',
'hooks after async after(:each) fails properly',
'hooks after async before(:each) fails properly',
'hooks after async match fails properly async match',
'hooks after async match fails properly sync match should eq 43',
'exception handling should fail properly if an exception is raised',
'exception handling should ignore an exception after a failed assertion'].sort

if actual_failures != expected_failures
unexpected = actual_failures - expected_failures
missing = expected_failures - actual_failures
failure_messages << "Expected test failures do not match actual\n"
failure_messages << "\nUnexpected fails:\n#{unexpected.join("\n")}\n\nMissing fails:\n#{missing.join("\n")}\n\n"
end

failure_messages << "Expected #{expected_pending_count} pending examples but actual was #{pending}" unless pending == expected_pending_count.to_s

if failure_messages.empty?
puts 'Test successful!'
else
raise "Test failed, reasons:\n\n#{failure_messages.join("\n")}\n"
end
end
47 changes: 35 additions & 12 deletions lib/opal/rspec.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,43 @@
require 'opal'
require 'opal/rspec/version'
require 'opal/minitest'

# Just register our opal code path with opal build tools
Opal.append_path File.expand_path('../../../opal', __FILE__)
Opal.append_path File.expand_path('../../../vendor_lib', __FILE__)

# Catch our git submodule included directories
%w{rspec rspec-core rspec-expectations rspec-mocks rspec-support}.each do |gem|
Opal.append_path File.expand_path("../../../#{gem}/lib", __FILE__)
end

Opal::Processor.dynamic_require_severity = :warning

Opal::Processor.stub_file "rspec/matchers/built_in/have"
Opal::Processor.stub_file "diff/lcs"
Opal::Processor.stub_file "diff/lcs/hunk"
Opal::Processor.stub_file "fileutils"
Opal::Processor.stub_file "test/unit/assertions"
Opal::Processor.stub_file "coderay"
Opal::Processor.stub_file "optparse"
Opal::Processor.stub_file "shellwords"
Opal::Processor.stub_file "socket"
Opal::Processor.stub_file "uri"
Opal::Processor.stub_file "drb/drb"
stubs = [
'mutex_m', # Used with some threading operations but seems to run OK without this
'prettyprint',
'tempfile', # Doesn't exist in Opal
'diff/lcs',
'diff/lcs/block',
'diff/lcs/callbacks',
'diff/lcs/change',
'diff/lcs/hunk',
'diff/lcs/internals',
'test/unit/assertions',

# Opal doesn't have optparse, yet
'optparse',

'shellwords',
'socket',
'uri',
'drb/drb',

# Minitest used to be in stdlib, now is in opal-minitest GEM,
# but this file does not exist
# (referenced from minitest_assertions_adapter.rb in RSpec)
'minitest/unit',

'cgi/util',
]

stubs.each {|mod| Opal::Processor.stub_file mod }
2 changes: 1 addition & 1 deletion lib/opal/rspec/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Opal
module RSpec
VERSION = '0.4.2'
VERSION = '0.5.0.dev'
end
end
7 changes: 5 additions & 2 deletions opal-rspec.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- encoding: utf-8 -*-
require 'rake'
require File.expand_path('../lib/opal/rspec/version', __FILE__)

Gem::Specification.new do |s|
@@ -10,11 +11,13 @@ Gem::Specification.new do |s|
s.summary = 'RSpec for Opal'
s.description = 'Opal compatible rspec library'

s.files = `git ls-files`.split("\n")
s.files = `git ls-files`.split("\n") + FileList['rspec*/**/*.rb']

s.require_paths = ['lib']

s.add_dependency 'opal', ['>= 0.7.0', '< 0.9']
s.add_dependency 'opal', ['>= 0.8.0.rc1', '< 0.9']
# Opal now does not include minitest but we need it for Sprockets/test execution
s.add_dependency 'opal-minitest', '~> 0.0'
s.add_development_dependency 'rake'
s.add_development_dependency 'yard'
end
12 changes: 2 additions & 10 deletions opal/opal/rspec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
class MiniTest
class Unit; end
end

Test = MiniTest

require 'opal/rspec/pre_require_fixes'
require 'opal/rspec/requires'
require 'opal/rspec/fixes'
require 'opal/rspec/text_formatter'
@@ -13,10 +8,7 @@ class Unit; end

RSpec.configure do |config|
# For now, always use our custom formatter for results
config.formatter = Opal::RSpec::Runner.default_formatter

# Async helpers for specs
config.include Opal::RSpec::AsyncHelpers
config.default_formatter = Opal::RSpec::Runner.default_formatter

# Always support expect() and .should syntax (we should not do this really..)
config.expect_with :rspec do |c|
Loading