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-rails
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 04fc42892aa0
Choose a base ref
...
head repository: opal/opal-rails
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8817da9c4198
Choose a head ref
  • 15 commits
  • 11 files changed
  • 1 contributor

Commits on May 20, 2014

  1. Whitespace

    elia committed May 20, 2014
    Copy the full SHA
    c8c0a68 View commit details
  2. Update dependencies

    elia committed May 20, 2014
    Copy the full SHA
    7125285 View commit details
  3. Update dependencies

    elia committed May 20, 2014
    Copy the full SHA
    dd6455f View commit details
  4. fixup! Update dep

    elia committed May 20, 2014
    Copy the full SHA
    94b2f2a View commit details
  5. Reference the CLI spec interface

    elia committed May 20, 2014
    Copy the full SHA
    90238ce View commit details

Commits on Jun 11, 2014

  1. Add the Slim filter

    fixes #10
    elia committed Jun 11, 2014
    Copy the full SHA
    147a3c4 View commit details

Commits on Sep 30, 2014

  1. Update rspec

    elia committed Sep 30, 2014
    Copy the full SHA
    b5a1d23 View commit details

Commits on Oct 1, 2014

  1. Use the sourcemap server for both .map and .rb

    Probably still missing .opal
    elia committed Oct 1, 2014
    Copy the full SHA
    8d3c077 View commit details
  2. Remove noisy warnings

    elia committed Oct 1, 2014
    Copy the full SHA
    9e810c9 View commit details
  3. Copy the full SHA
    9e4c188 View commit details
  4. Cleanup the sourcemap spec

    elia committed Oct 1, 2014
    Copy the full SHA
    46e5c27 View commit details

Commits on Oct 2, 2014

  1. Copy the full SHA
    5c96c93 View commit details
  2. Copy the full SHA
    7a6d5c2 View commit details
  3. Cleanup Gemfile

    elia committed Oct 2, 2014
    Copy the full SHA
    d7da0f5 View commit details
  4. Add webscale badge

    elia committed Oct 2, 2014
    Copy the full SHA
    8817da9 View commit details
12 changes: 3 additions & 9 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -2,15 +2,9 @@ source 'https://rubygems.org'
gemspec

gem 'capybara-webkit'
gem 'capybara', '< 2'

gem 'opal', :github => 'opal/opal'
gem 'opal-jquery', :github => 'opal/opal-jquery'

# gem 'opal', :path => '~/Code/opal'
# gem 'opal-jquery', :path => '~/Code/opal-jquery'
# gem 'opal-rspec', :path => '~/Code/opal-rspec'
# gem 'opal-browser', :path => '~/Code/opal-browser'
gem 'opal-jquery', github: 'opal/opal-jquery'
gem 'opal', github: 'opal'
# gem 'opal', path: '../opal'

if RUBY_VERSION.to_f < 1.9
gem 'nokogiri', '< 1.6'
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
[![Code Climate](https://img.shields.io/codeclimate/github/elia/opal-rails.svg)](https://codeclimate.com/github/elia/opal-rails)
[![Gem Version](https://badge.fury.io/rb/opal-rails.svg)](http://badge.fury.io/rb/opal-rails)
![fun guaranteed](https://img.shields.io/badge/fun-guaranteed-brightgreen.svg)
![web scale](http://img.shields.io/badge/webscale-over%209000-green.svg)

_Rails (3.2+, 4.0) bindings for [Opal Ruby](http://opalrb.org) engine. ([Changelog](https://github.com/opal/opal-rails/blob/master/CHANGELOG.md))_

@@ -13,7 +14,7 @@ _Rails (3.2+, 4.0) bindings for [Opal Ruby](http://opalrb.org) engine. ([Changel

In your `Gemfile`

``` ruby
```ruby
gem 'opal-rails'
```

@@ -150,7 +151,7 @@ describe 'a spec' do
end
```

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

![1 examples, 0 failures](http://f.cl.ly/items/001n0V0g0u0v14160W2G/Schermata%2007-2456110%20alle%201.06.29%20am.png)

1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -11,3 +11,4 @@ Bundler::GemHelper.install_tasks

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new :default

2 changes: 1 addition & 1 deletion lib/assets/javascripts/opal-rspec-runner.js.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'jquery'
require 'jquery.js'

require 'opal'
require 'opal-rspec'
4 changes: 2 additions & 2 deletions lib/assets/javascripts/opal_ujs.js.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'jquery.js'
require 'jquery_ujs.js'
require 'opal'
require 'jquery'
require 'jquery_ujs'
require 'opal-jquery'
6 changes: 4 additions & 2 deletions lib/opal/rails/engine.rb
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ class Engine < ::Rails::Engine

config.after_initialize do |app|
require 'opal/rails/haml_filter' if defined?(Haml)
require 'opal/rails/slim_filter' if defined?(Slim)

config = app.config
config.opal.each_pair do |key, value|
@@ -35,8 +36,9 @@ class Engine < ::Rails::Engine

app.routes.prepend do
if Opal::Processor.source_map_enabled
maps_app = Opal::SourceMapServer.new(app.assets)
mount maps_app => maps_app.prefix
prefix = app.config.assets.prefix
maps_app = Opal::SourceMapServer.new(app.assets, prefix)
mount Rack::Cascade.new([maps_app, app.assets]) => prefix
end

get '/opal_spec' => 'opal_spec#run'
12 changes: 12 additions & 0 deletions lib/opal/rails/slim_filter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Slim
class Embedded
class OpalEngine < TiltEngine
protected

def tilt_render(tilt_engine, tilt_options, text)
[:static, ::Opal.compile(text)]
end
end
register :opal, JavaScriptEngine, :engine => OpalEngine
end
end if defined? Slim::Embedded
10 changes: 4 additions & 6 deletions opal-rails.gemspec
Original file line number Diff line number Diff line change
@@ -19,17 +19,15 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ['lib']

s.add_dependency 'rails', '>= 3.2.13', '< 5.0'
s.add_dependency 'rails', '>= 4.0', '< 5.0'
s.add_dependency 'opal', '~> 0.7.0.dev'
s.add_dependency 'opal-jquery', '>= 0.1.0'
s.add_dependency 'opal-rspec', '~> 0.3.0.beta1'
s.add_dependency 'opal-rspec', '~> 0.4.0.beta1'
s.add_dependency 'jquery-rails'
s.add_dependency 'opal-activesupport', '>= 0.0.5'

s.add_development_dependency 'execjs'
s.add_development_dependency 'launchy'
s.add_development_dependency 'capybara'

s.add_development_dependency 'rspec', '~> 2.13'
s.add_development_dependency 'rspec-rails', '~> 2.13'
s.add_development_dependency 'capybara', '~> 2.3'
s.add_development_dependency 'rspec-rails', '~> 3.0'
end
4 changes: 3 additions & 1 deletion spec/integration/in_browser_specs_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require 'spec_helper'

feature 'In-browser specs runner', :type => :request do
feature 'In-browser specs runner' do
before { skip 'STILL NEED TO FIX FOR OPAL-RSPEC' }

scenario 'runs all specs', :js do
visit '/opal_spec'

24 changes: 15 additions & 9 deletions spec/integration/source_map_spec.rb
Original file line number Diff line number Diff line change
@@ -2,34 +2,40 @@
require 'opal/source_map'

describe Opal::SourceMap do
let(:js_asset_path) { '/assets/source_map_example.js' }

before do
expect(Rails.application.config.opal.source_map_enabled).to be_true
get '/assets/source_map_example.js'
expect(Rails.application.config.opal.source_map_enabled).to be_truthy
get js_asset_path
end

let(:map_url) { extract_map_url(response) }
let(:map_path) { extract_map_path(response) }

let(:map_body) do
get map_url
raise "#{response.status}\n\n#{response.body}" unless response.success?
get map_path
expect(response).to be_success, "url: #{map_path}\nstatus: #{response.status}"
response.body
end

let(:map) { JSON.parse(map_body) }

it 'has the source map header or magic comment' do
expect(extract_map_url(response)).to be_present
expect(extract_map_path(response)).to be_present
end

it "the map is a valid json" do
get map_path
%w[sources mappings].each do |key|
expect(map_body[key]).to be_present
end
end

def extract_map_url response
response.headers['X-SourceMap'] or
response.body.scan(%r{^//[@#] sourceMappingURL=([^\n]+)}).flatten.first.to_s.strip
def extract_map_path response
source_map_regexp = %r{^//[@#] sourceMappingURL=([^\n]+)}
map_path = (response.headers['X-SourceMap'] ||
response.body.scan(source_map_regexp).
flatten.first.to_s.strip)
File.join(File.dirname(js_asset_path), map_path) if map_path
end

end
90 changes: 80 additions & 10 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -13,27 +13,97 @@
ENV['RAILS_ENV'] = 'test'

require File.expand_path('test_app/config/environment.rb', root_dir)

require 'rspec/rails'
require 'support/capybara'
require 'support/reset_assets_cache'

Rails.backtrace_cleaner.remove_silencers!

# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause this
# file to always be loaded, without a need to explicitly require it in any files.
#
# Given that it is always loaded, you are encouraged to keep this file as
# light-weight as possible. Requiring heavyweight dependencies from this file
# will add to the boot time of your test suite on EVERY test run, even for an
# individual file that may not need all of that loaded. Instead, consider making
# a separate helper file that requires the additional dependencies and performs
# the additional setup, and require it from the spec files that actually need it.
#
# The `.rspec` file also contains a few flags that are not defaults but that
# users commonly want.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
config.infer_spec_type_from_file_location!

# RSPEC

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[File.expand_path('spec/support/**/*.rb', root_dir)].each {|f| require f}
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.
config.expect_with :rspec do |expectations|
# This option will default to `true` in RSpec 4. It makes the `description`
# and `failure_message` of custom matchers include text for helper methods
# defined using `chain`, e.g.:
# be_bigger_than(2).and_smaller_than(4).description
# # => "be bigger than 2 and smaller than 4"
# ...rather than:
# # => "be bigger than 2"
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end

RSpec.configure do |config|
config.mock_with :rspec
# rspec-mocks config goes here. You can use an alternate test double
# library (such as bogus or mocha) by changing the `mock_with` option here.
config.mock_with :rspec do |mocks|
# Prevents you from mocking or stubbing a method that does not exist on
# a real object. This is generally recommended, and will default to
# `true` in RSpec 4.
mocks.verify_partial_doubles = true
end

config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
# These two settings work together to allow you to limit a spec run
# to individual examples or groups you care about by tagging them with
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
# get run.
config.filter_run :focus
config.run_all_when_everything_filtered = true

# Limits the available syntax to the non-monkey patched syntax that is recommended.
# For more details, see:
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
# config.disable_monkey_patching!

# This setting enables warnings. It's recommended, but in some cases may
# be too noisy due to issues in dependencies.
config.warnings = false

# Many RSpec users commonly either run the entire suite or an individual
# file, and it's useful to allow more verbose output when running an
# individual spec file.
if config.files_to_run.one?
# Use the documentation formatter for detailed output,
# unless a formatter has already been configured
# (e.g. via a command-line flag).
config.default_formatter = 'doc'
end

# Print the 10 slowest examples and example groups at the
# end of the spec run, to help surface which specs are running
# particularly slow.
config.profile_examples = 10

# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = 'random'
config.order = :random

# Seed global randomization in this process using the `--seed` CLI option.
# Setting this allows you to use `--seed` to deterministically reproduce
# test failures related to randomization by passing the same `--seed` value
# as the one that triggered the failure.
Kernel.srand config.seed
end