Skip to content

Commit

Permalink
Fix the spec file example & make it more complete
Browse files Browse the repository at this point in the history
elia committed Jul 29, 2015
1 parent dc03b01 commit 79a23da
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* Dynamic require severity now defaults to `:ignore`
* Make `#opal_tag` helper respect provided options + specs
* Sprockets bootstrap code can be skipped from `javascript_include_tag` passing `skip_opal_loader: true`
* All specs now need to require "opal" and "opal-rspec" explicitly
* All specs now need to `require "opal"` and `require "opal-rspec"` explicitly


# 0.7.0 2015-02-02
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -168,6 +168,8 @@ and then a spec folder with you specs!

```ruby
# spec-opal/example_spec.js.rb
require 'opal'
require 'opal-rspec'

describe 'a spec' do
it 'has successful examples' do
@@ -178,6 +180,27 @@ end

Then visit `/opal_spec` from your app and **reload at will** or use the command line with `rake opal:spec`.

Note that `opal` and `opal-rspec` need to be required explicitly in the spec file or in a `spec_helper.rb` as follows:

```ruby
# spec_helper.rb
require 'opal'
require 'opal-rspec'
```

```ruby
# spec-opal/example_spec.js.rb
require 'spec_helper'

describe 'a spec' do
it 'has successful examples' do
'I run'.should =~ /run/
end
end
```

That is to allow having specs that make use of [`opal-minitest`](https://rubygems.org/gems/opal-minitest) or another testing library.

#### CHANGE from versions pre 0.7.1

Specs used to run out of app/assets/javascripts/spec which was problematic because require_tree . would cause opal/sprockets to compile the specs for non spec running. This could result in bad specs that prevent your application Opal code from compiling, and even if it compiles you'll get exceptions about the test framework methods not being defined. To address this, specs have been moved out of the app/assets/javascripts to Rails.root/spec-opal. The name spec-opal was chosen to put it close to the spec directory. We don't want to put specs in spec directory because we don't want the "backend" rspec to run those.
@@ -236,7 +259,7 @@ template.render(self)

## License

© 2012-2014 Elia Schito
© 2012-2015 Elia Schito

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

0 comments on commit 79a23da

Please sign in to comment.