opal-rspec 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1cc133e9e68247ec3724254799c05ae252b3997be94713206f2668ea50bab6c9
4
- data.tar.gz: dbe4d9ff976f2b02eb9c06da3d4087e5e85559ef2c212f9ac3bda5f01daf98cc
3
+ metadata.gz: b7ed32b2aee48df3d8cdb71faef3fb81644cd7a4d8ae96ffd9708f4eccab7c6a
4
+ data.tar.gz: 9e4e7ff4030e66438fc2e67864c79d73c80eeaa19c6d20398140067c4cbc1399
5
5
  SHA512:
6
- metadata.gz: f58ff1127357c59a61b7b50210495d5c5ec7a826d7366e43709d358107b9579379f215a109cc1269ae837f0e867c80ebfd8945b81b1d6476045421e55e33eac9
7
- data.tar.gz: a013b85ed190c2c38965641de42f4d849552c4de3c7e843e3cc53583d887f45823aaf73ddab84c1db307326a2cb9c3c4ba62271dc801c8f1a77ac9c815ad0b4a
6
+ metadata.gz: 33923120410d49a01f3b3c04be70e670310e0b15a926820bb70ef62a5cc907bdbe9a494dffec5e9564a27e522b8ea2bd3313e58e9ee57f484157c8535126eb7b
7
+ data.tar.gz: 690896cb3985e989592e02ed1855710fc0973051f8f6089e13db99f2764be9ac493a7010ed6010cd24e468d8c36e291e2cfe267f8ce8579e3f0bb1b2512c0502
@@ -38,9 +38,6 @@ gemfile:
38
38
  - gemfiles/opal_master.gemfile
39
39
 
40
40
  before_install:
41
- # Attempt to work around Travis issues and Ruby 2.3 - https://github.com/vcr/vcr/issues/582
42
- - gem update --system
43
- - gem install bundler
44
41
  - "mkdir -p phantom20"
45
42
  - "export PATH=`pwd`/phantom20:$PATH"
46
43
  - "echo $PATH"
@@ -1,3 +1,10 @@
1
+ # Opal-RSpec Changelog
2
+
3
+ ## 0.7.1 - 2019-02-04
4
+
5
+ - add a project initializer: `opal-rspec --init`
6
+
7
+
1
8
  ## 0.7.0 - 2019-02-03
2
9
 
3
10
  - Drop support for the legacy async syntax
data/README.md CHANGED
@@ -6,8 +6,6 @@
6
6
 
7
7
  An attempt at a compatibility layer of RSpec for Opal.
8
8
 
9
- #### For the README for the latest release, click [here](https://github.com/opal/opal-rspec/blob/releases/0-6-stable/README.md).
10
-
11
9
  ## Usage
12
10
 
13
11
  Add `opal-rspec` to your Gemfile:
@@ -16,6 +14,26 @@ Add `opal-rspec` to your Gemfile:
16
14
  gem 'opal-rspec'
17
15
  ```
18
16
 
17
+ *(since v0.7.1)*
18
+
19
+ Then type `opal-rspec --init`, this command will create a `spec-opal/` folder for you with a minimal `spec_helper.rb` file. At this point you can write your first opal-spec!
20
+
21
+ _spec-opal/simple_sum_spec.rb_
22
+
23
+ ```rb
24
+ RSpec.describe 'a simple sum' do
25
+ it 'equals two!' do
26
+ expect(1 + 1).to eq(2)
27
+ end
28
+ end
29
+ ```
30
+
31
+ To run your specs, simply type:
32
+
33
+ ```bash
34
+ bundle exec opal-rspec --color spec-opal/
35
+ ```
36
+
19
37
  ## Requirements
20
38
 
21
39
  Besides what's already reflected in the GEM dependencies:
@@ -10,6 +10,11 @@ require 'optparse'
10
10
 
11
11
  options = {}
12
12
  OptionParser.new do |parser|
13
+ parser.on('--init', 'Initialize your project with Opal-RSpec.') do |_cmd|
14
+ Opal::RSpec::ProjectInitializer.new.run
15
+ exit
16
+ end
17
+
13
18
  parser.on('-c', '--[no-]color', '--[no-]colour', 'Enable color in the output.') do |o|
14
19
  options[:color] = o
15
20
  end
@@ -23,17 +28,21 @@ OptionParser.new do |parser|
23
28
  options[:formatters] ||= []
24
29
  options[:formatters] << [o]
25
30
  end
31
+
26
32
  parser.on('-r', '--require PATH', 'Require a file.') do |path|
27
33
  options[:requires] ||= []
28
34
  options[:requires] << path
29
35
  end
36
+
30
37
  parser.on('-I PATH', 'Specify PATH to add to $LOAD_PATH (may be used more than once).') do |dir|
31
38
  options[:includes] ||= []
32
39
  options[:includes] << dir
33
40
  end
41
+
34
42
  parser.on('-P', '--pattern PATTERN', 'Load files matching pattern (default: "spec-opal/**/*_spec.rb").') do |o|
35
43
  options[:pattern] = o
36
44
  end
45
+
37
46
  parser.on('--default-path PATH', 'Set the default path where RSpec looks for examples (can',
38
47
  ' be a path to a file or a directory).') do |path|
39
48
  options[:default_path] = path
@@ -44,9 +53,7 @@ OptionParser.new do |parser|
44
53
  parser.on('-R', '--runner NAME', 'Use a different JS runner (default is nodejs)') do |name|
45
54
  options[:runner] = name
46
55
  end
47
-
48
56
  end.parse!
49
- # p options: options
50
57
 
51
58
  runner = Opal::RSpec::Runner.new do |server, config|
52
59
  spec_opts = []
@@ -55,7 +62,8 @@ runner = Opal::RSpec::Runner.new do |server, config|
55
62
  raise "can accept only one formatter at this time" if options[:formatters] && options[:formatters].size != 1
56
63
  spec_opts += ['--format', options[:formatters].flatten.first] if options[:formatters]
57
64
  raw_files = ARGV
58
- # p raw_files: ARGV
65
+ raw_files = ['spec-opal'] if raw_files.empty?
66
+
59
67
  files = raw_files.flat_map do |file|
60
68
  if File.directory? file
61
69
  Dir[File.join(file, '**{,/*/**}/*_spec{.js,}.rb')]
@@ -65,7 +73,6 @@ runner = Opal::RSpec::Runner.new do |server, config|
65
73
  raise "Can't stat path: #{file}"
66
74
  end
67
75
  end
68
- # p files: files
69
76
 
70
77
  options[:includes].each {|dir| server.append_path dir} if options[:includes]
71
78
  config.default_path = options[:default_path] if options[:default_path]
@@ -73,6 +80,5 @@ runner = Opal::RSpec::Runner.new do |server, config|
73
80
  config.files = files
74
81
  end
75
82
 
76
- # puts runner.command
77
83
  runner.run
78
84
 
@@ -18,6 +18,8 @@ Opal::Config.dynamic_require_severity = :ignore
18
18
 
19
19
  module Opal
20
20
  module RSpec
21
+ autoload :ProjectInitializer, 'opal/rspec/project_initializer'
22
+
21
23
  def self.spec_opts_code(spec_opts)
22
24
  code = []
23
25
  if spec_opts && !spec_opts.empty?
@@ -9,7 +9,8 @@ module Opal
9
9
  class Locator
10
10
  include ::RSpec::Core::RubyProject
11
11
 
12
- DEFAULT_PATTERN = 'spec-opal/**/*_spec{.js,}.{rb,opal}'
12
+ DEFAULT_GLOB = '**{,/*/**}/*_spec{.js,}.{rb,opal}'
13
+ DEFAULT_PATTERN = "spec-opal/#{DEFAULT_GLOB}"
13
14
  DEFAULT_DEFAULT_PATH = 'spec-opal'
14
15
 
15
16
  attr_accessor :spec_pattern, :spec_exclude_pattern, :spec_files, :default_path
@@ -0,0 +1,48 @@
1
+ require 'fileutils'
2
+
3
+ module Opal
4
+ module RSpec
5
+ # @private
6
+ # Generates conventional files for an rspec project
7
+ class ProjectInitializer
8
+ attr_reader :destination, :stream, :template_path
9
+
10
+ DOT_RSPEC_FILE = '.rspec-opal'
11
+ SPEC_HELPER_FILE = 'spec-opal/spec_helper.rb'
12
+
13
+ def initialize(opts={})
14
+ @destination = opts.fetch(:destination, Dir.getwd)
15
+ @stream = opts.fetch(:report_stream, $stdout)
16
+ @template_path = opts.fetch(:template_path) do
17
+ File.expand_path("../project_initializer", __FILE__)
18
+ end
19
+ end
20
+
21
+ def run
22
+ copy_template DOT_RSPEC_FILE
23
+ copy_template SPEC_HELPER_FILE
24
+ end
25
+
26
+ private
27
+
28
+ def copy_template(file)
29
+ destination_file = File.join(destination, file)
30
+ return report_exists(file) if File.exist?(destination_file)
31
+
32
+ report_creating(file)
33
+ FileUtils.mkdir_p(File.dirname(destination_file))
34
+ File.open(destination_file, 'w') do |f|
35
+ f.write File.read(File.join(template_path, file))
36
+ end
37
+ end
38
+
39
+ def report_exists(file)
40
+ stream.puts " exist #{file}"
41
+ end
42
+
43
+ def report_creating(file)
44
+ stream.puts " create #{file}"
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,13 @@
1
+ RSpec.configure do |config|
2
+ # Run specs in random order to surface order dependencies. If you find an
3
+ # order dependency and want to debug it, you can fix the order by providing
4
+ # the seed, which is printed after each run.
5
+ # --seed 1234
6
+ config.order = :random
7
+
8
+ # Seed global randomization in this process using the `--seed` CLI option.
9
+ # Setting this allows you to use `--seed` to deterministically reproduce
10
+ # test failures related to randomization by passing the same `--seed` value
11
+ # as the one that triggered the failure.
12
+ Kernel.srand config.seed
13
+ end
@@ -1,5 +1,5 @@
1
1
  module Opal
2
2
  module RSpec
3
- VERSION = '0.7.0'
3
+ VERSION = '0.7.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opal-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Beynon
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2019-02-03 00:00:00.000000000 Z
13
+ date: 2019-02-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: opal
@@ -262,6 +262,9 @@ files:
262
262
  - lib/opal/rspec.rb
263
263
  - lib/opal/rspec/cached_environment.rb
264
264
  - lib/opal/rspec/locator.rb
265
+ - lib/opal/rspec/project_initializer.rb
266
+ - lib/opal/rspec/project_initializer/.rspec-opal
267
+ - lib/opal/rspec/project_initializer/spec-opal/spec_helper.rb
265
268
  - lib/opal/rspec/rake_task.rb
266
269
  - lib/opal/rspec/runner.rb
267
270
  - lib/opal/rspec/sprockets_environment.rb
@@ -771,8 +774,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
771
774
  - !ruby/object:Gem::Version
772
775
  version: '0'
773
776
  requirements: []
774
- rubyforge_project:
775
- rubygems_version: 2.7.7
777
+ rubygems_version: 3.0.2
776
778
  signing_key:
777
779
  specification_version: 4
778
780
  summary: RSpec for Opal