guard-rails-assets 0.1.5 → 0.1.6

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
  SHA1:
3
- metadata.gz: 988149e17470d7e623e5d30aa00b29be7b2c46c6
4
- data.tar.gz: c6ef20f917793ed9dd100367b1c25c655bd96eda
3
+ metadata.gz: 5b80e50e640f2d4d6f94a7ca6a21eb357dfc7a3e
4
+ data.tar.gz: 61213ce0c830a579ad4ffb67497e1c0612d6559a
5
5
  SHA512:
6
- metadata.gz: 597c326c4a0a1dd239d56124df6702e9fd95ed6d362ef9296704091713c5607c21c3bd0ee27e9b81675899f75058bbf7a7557f224b68d29155a3299f36717d55
7
- data.tar.gz: ab534ff457b5062f8df88e223b923034fcbfeea7e1e0f594e28783f1652b587542f8141c6e557aa18a9fb48e82d1965a79a33cacb9b0923e02f0be6d8e69b17e
6
+ metadata.gz: 8e9f072b1ef2e25a3eaeb8dad7c1d338563b892f8e7d11ee078ffe76eafd886154ffadb769609e7599da1bbc97a1399a3fcab011c21482e6d7b1b286966524f5
7
+ data.tar.gz: c5ffa77814dc51311990efb254c4996eb96e2d4f0025e6a9649459be4968f8dc1b080a5132c10b32f4fdc4637814e545b2524ca9b98081745267e463c52af78a
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1 @@
1
+ inherit_from: .rubocop_todo.yml
@@ -0,0 +1,33 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2014-12-17 03:53:47 +0100 using RuboCop version 0.28.0.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 2
9
+ Lint/Eval:
10
+ Enabled: false
11
+
12
+ # Offense count: 1
13
+ Metrics/AbcSize:
14
+ Max: 38
15
+
16
+ # Offense count: 17
17
+ # Configuration parameters: AllowURI, URISchemes.
18
+ Metrics/LineLength:
19
+ Max: 138
20
+
21
+ # Offense count: 2
22
+ # Configuration parameters: CountComments.
23
+ Metrics/MethodLength:
24
+ Max: 19
25
+
26
+ # Offense count: 5
27
+ Style/Documentation:
28
+ Enabled: false
29
+
30
+ # Offense count: 2
31
+ # Configuration parameters: Exclude.
32
+ Style/FileName:
33
+ Enabled: false
data/Gemfile CHANGED
@@ -1,5 +1,10 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'pry', :group => [:development, :test]
5
+ gem 'pry', group: [:development, :test]
6
+
7
+ group :development do
8
+ gem 'transpec', require: false
9
+ gem 'rubocop', require: false
10
+ end
data/Rakefile CHANGED
@@ -1 +1,16 @@
1
+ require 'nenv'
1
2
  require 'bundler/gem_tasks'
3
+
4
+ default_tasks = []
5
+
6
+ require 'rspec/core/rake_task'
7
+ default_tasks << RSpec::Core::RakeTask.new(:spec) do |t|
8
+ t.verbose = Nenv.ci?
9
+ end
10
+
11
+ unless Nenv.ci?
12
+ require 'rubocop/rake_task'
13
+ default_tasks << RuboCop::RakeTask.new(:rubocop)
14
+ end
15
+
16
+ task default: default_tasks.map(&:name)
@@ -1,27 +1,29 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "guard/rails-assets/version"
2
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
+ require 'guard/rails-assets/version'
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = "guard-rails-assets"
6
+ s.name = 'guard-rails-assets'
7
7
  s.version = Guard::RailsAssetsVersion::VERSION
8
- s.authors = ["Dmytrii Nagirniak"]
9
- s.email = ["dnagir@gmail.com"]
10
- s.homepage = "http://github.com/dnagir/guard-rails-assets"
11
- s.summary = %q{Guard for compiling Rails assets}
12
- s.description = %q{guard-rails-assets automatically generates JavaScript, CSS, Image files using Rails assets pipelie}
8
+ s.authors = ['Dmytrii Nagirniak']
9
+ s.email = ['dnagir@gmail.com']
10
+ s.homepage = 'http://github.com/guard/guard-rails-assets'
11
+ s.summary = 'Guard for compiling Rails assets'
12
+ s.description = 'guard-rails-assets automatically generates JavaScript, CSS, Image files using Rails assets pipelie'
13
13
 
14
- s.licenses = ['MIT', 'WTFPL']
14
+ s.licenses = %w(MIT WTFPL)
15
15
 
16
- s.rubyforge_project = "guard-rails-assets"
16
+ s.rubyforge_project = 'guard-rails-assets'
17
17
 
18
- s.add_dependency 'guard'
19
- s.add_dependency 'rake'
20
- s.add_dependency 'rails', '>= 3.1.1'
21
- s.add_development_dependency 'rspec'
18
+ s.add_dependency 'guard', '~> 2.6'
19
+ s.add_dependency 'guard-compat', '~> 1.1'
20
+ s.add_dependency 'rake'
21
+ s.add_dependency 'rails', '>= 3.1.1'
22
+ s.add_development_dependency 'rspec', '~> 3.1'
23
+ s.add_development_dependency 'nenv', '~> 0.1'
22
24
 
23
25
  s.files = `git ls-files`.split("\n")
24
26
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
25
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
26
- s.require_paths = ["lib"]
27
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
28
+ s.require_paths = ['lib']
27
29
  end
@@ -1,9 +1,8 @@
1
- require 'guard'
2
- require 'guard/guard'
1
+ require 'guard/compat/plugin'
3
2
 
4
3
  module Guard
5
- class RailsAssets < Guard
6
- def initialize(watchers=[], options={})
4
+ class RailsAssets < Plugin
5
+ def initialize(options = {})
7
6
  super
8
7
  @options = options || {}
9
8
  @run_on = @options[:run_on] || [:start, :change]
@@ -24,7 +23,7 @@ module Guard
24
23
  compile_assets if run_for? :all
25
24
  end
26
25
 
27
- def run_on_change(paths=[])
26
+ def run_on_change(_paths = [])
28
27
  compile_assets if run_for? :change
29
28
  end
30
29
 
@@ -33,10 +32,10 @@ module Guard
33
32
  result = runner.compile_assets
34
33
 
35
34
  if result
36
- Notifier::notify 'Assets compiled'
35
+ Compat::UI.notify 'Assets compiled'
37
36
  puts 'Assets compiled.'
38
37
  else
39
- Notifier::notify 'see the details in the terminal', :title => "Can't compile assets", :image => :failed
38
+ Compat::UI.notify 'see the details in the terminal', title: "Can't compile assets", image: :failed
40
39
  puts 'Failed to compile assets.'
41
40
  end
42
41
  end
@@ -50,9 +49,17 @@ module Guard
50
49
  end
51
50
  end
52
51
 
53
- def run_for? command
52
+ def run_for?(command)
54
53
  @run_on.include?(command)
55
54
  end
55
+
56
+ def self.template(plugin_location)
57
+ File.read(template_path(plugin_location))
58
+ end
59
+
60
+ def self.template_path(plugin_location)
61
+ # workaround because Guard discards the '-' when detecting template path
62
+ File.join(plugin_location, 'lib', 'guard', 'rails-assets', 'templates', 'Guardfile')
63
+ end
56
64
  end
57
65
  end
58
-
@@ -1,15 +1,19 @@
1
+ require 'guard/rails-assets'
2
+
1
3
  module Guard
2
- class RailsAssets::CliRunner
3
- def initialize(options={})
4
- @rails_env = (options[:rails_env] || 'test').to_s
5
- @digest = options[:digest]
6
- @digest = true if @digest.nil?
7
- end
4
+ class RailsAssets
5
+ class CliRunner
6
+ def initialize(options = {})
7
+ @rails_env = (options[:rails_env] || 'test').to_s
8
+ @digest = options[:digest]
9
+ @digest = true if @digest.nil?
10
+ end
8
11
 
9
- def compile_assets
10
- task = "assets:precompile"
11
- task += ":nondigest" unless @digest
12
- system "bundle exec rake assets:clean #{task} RAILS_ENV=#{@rails_env}"
12
+ def compile_assets
13
+ task = 'assets:precompile'
14
+ task += ':nondigest' unless @digest
15
+ system "bundle exec rake assets:clean #{task} RAILS_ENV=#{@rails_env}"
16
+ end
13
17
  end
14
18
  end
15
19
  end
@@ -1,93 +1,99 @@
1
1
  require 'rake/dsl_definition'
2
2
  module Guard
3
+ class RailsAssets
4
+ class RailsRunner
5
+ include Rake::DSL
3
6
 
4
- class RailsAssets::RailsRunner
5
- include Rake::DSL
7
+ @rails_booted = false # Only one rails app is allowed, so make it a class var
8
+ @rails_env = nil
9
+ @digest = nil
6
10
 
7
- @@rails_booted = false # Only one rails app is allowed, so make it a class var
8
- @@rails_env = nil
9
- @@digest = nil
11
+ class << self
12
+ attr_reader :rails_booted
13
+ attr_accessor :digest
14
+ attr_accessor :rails_env
15
+ end
10
16
 
11
- def initialize(options={})
12
- @@rails_env = (options[:rails_env] || 'test').to_s unless @@rails_booted
13
- @@digest = options[:digest]
14
- end
17
+ def initialize(options = {})
18
+ self.class.rails_env = (options[:rails_env] || 'test').to_s unless self.class.rails_booted
19
+ self.class.digest = options[:digest]
20
+ end
15
21
 
16
- def self.apply_hacks
17
- # TODO: Hack due to Rails 3.1 issue: https://github.com/rails/rails/issues/2663#issuecomment-1990121
18
- ENV["RAILS_GROUPS"] ||= "assets"
19
- ENV["RAILS_ENV"] ||= @@rails_env
20
- end
22
+ def self.apply_hacks
23
+ # TODO: Hack due to Rails 3.1 issue: https://github.com/rails/rails/issues/2663#issuecomment-1990121
24
+ ENV['RAILS_GROUPS'] ||= 'assets'
25
+ ENV['RAILS_ENV'] ||= rails_env
26
+ end
21
27
 
22
- # Methods to run the asset pipeline
23
- # See as a reference https://github.com/rails/rails/blob/master/actionpack/lib/sprockets/assets.rake
24
- def self.boot_rails
25
- return if @@rails_booted
26
- puts "Booting Rails for #{@@rails_env} environment."
27
- require "fileutils"
28
+ # Methods to run the asset pipeline
29
+ # See as a reference https://github.com/rails/rails/blob/master/actionpack/lib/sprockets/assets.rake
30
+ def self.boot_rails
31
+ return if @rails_booted
32
+ puts "Booting Rails for #{rails_env} environment."
33
+ require 'fileutils'
28
34
 
29
- apply_hacks
30
- require 'rake'
31
- require "#{Dir.pwd}/config/environment.rb"
32
- app = ::Rails.application
35
+ apply_hacks
36
+ require 'rake'
37
+ require "#{Dir.pwd}/config/environment.rb"
38
+ app = ::Rails.application
33
39
 
34
- app.assets.cache = nil # don't touch my FS pls. (can we use `app.config.assets.cache_store = false` instead)?
35
- app.load_tasks
36
- @@rails_booted = true
37
- end
38
-
39
- def clean
40
- Rake::Task["tmp:cache:clear"].execute
41
- # copy from the "assets:clean" Rake task
42
- config = ::Rails.application.config
43
- public_asset_path = File.join(::Rails.public_path, config.assets.prefix)
44
- rm_rf public_asset_path, :secure => true
45
- end
40
+ app.assets.cache = nil # don't touch my FS pls. (can we use `app.config.assets.cache_store = false` instead)?
41
+ app.load_tasks
42
+ @rails_booted = true
43
+ end
46
44
 
47
- def precompile
48
- config = ::Rails.application.config
49
- unless config.assets.enabled
50
- warn "Cannot precompile assets if sprockets is disabled. Enabling it."
51
- config.assets.enabled = true
45
+ def clean
46
+ Rake::Task['tmp:cache:clear'].execute
47
+ # copy from the "assets:clean" Rake task
48
+ config = ::Rails.application.config
49
+ public_asset_path = File.join(::Rails.public_path, config.assets.prefix)
50
+ rm_rf public_asset_path, secure: true
52
51
  end
53
52
 
54
- # Ensure that action view is loaded and the appropriate
55
- # sprockets hooks get executed
56
- _ = ActionView::Base
53
+ def precompile
54
+ config = ::Rails.application.config
55
+ unless config.assets.enabled
56
+ warn 'Cannot precompile assets if sprockets is disabled. Enabling it.'
57
+ config.assets.enabled = true
58
+ end
57
59
 
58
- digest = @@digest.nil? ? config.assets.digest : @@digest
60
+ # Ensure that action view is loaded and the appropriate
61
+ # sprockets hooks get executed
62
+ _ = ActionView::Base
59
63
 
60
- config.assets.compile = true
61
- config.assets.digest = digest
62
- config.assets.digests = {}
64
+ digest = self.class.digest.nil? ? config.assets.digest : self.class.digest
63
65
 
64
- env = ::Rails.application.assets
65
- target = File.join(::Rails.public_path, config.assets.prefix)
66
- compiler = Sprockets::StaticCompiler.new(env,
67
- target,
68
- config.assets.precompile,
69
- :manifest_path => config.assets.manifest,
70
- :digest => config.assets.digest,
71
- :manifest => config.assets.digest.nil?)
72
- compiler.compile
73
- end
66
+ config.assets.compile = true
67
+ config.assets.digest = digest
68
+ config.assets.digests = {}
74
69
 
70
+ env = ::Rails.application.assets
71
+ target = File.join(::Rails.public_path, config.assets.prefix)
72
+ compiler = Sprockets::StaticCompiler.new(env,
73
+ target,
74
+ config.assets.precompile,
75
+ manifest_path: config.assets.manifest,
76
+ digest: config.assets.digest,
77
+ manifest: config.assets.digest.nil?)
78
+ compiler.compile
79
+ end
75
80
 
76
- # Runs the asset pipeline compiler.
77
- #
78
- # @return [ Boolean ] Whether the compilation was successful or not
79
- def compile_assets
80
- self.class.boot_rails
81
- return false unless @@rails_booted
82
- begin
83
- clean
84
- precompile
85
- true
86
- rescue => e
87
- puts "An error occurred compiling assets: #{e}"
88
- false
89
- ensure
90
- ::Rails.application.assets.instance_eval { expire_index! }
81
+ # Runs the asset pipeline compiler.
82
+ #
83
+ # @return [ Boolean ] Whether the compilation was successful or not
84
+ def compile_assets
85
+ self.class.boot_rails
86
+ return false unless self.class.rails_booted
87
+ begin
88
+ clean
89
+ precompile
90
+ true
91
+ rescue => e
92
+ puts "An error occurred compiling assets: #{e}"
93
+ false
94
+ ensure
95
+ ::Rails.application.assets.instance_eval { expire_index! }
96
+ end
91
97
  end
92
98
  end
93
99
  end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module RailsAssetsVersion
3
- VERSION = "0.1.5"
3
+ VERSION = '0.1.6'
4
4
  end
5
5
  end
@@ -1,18 +1,16 @@
1
- require 'spec_helper'
2
-
3
- describe Guard::RailsAssets::CliRunner do
4
-
1
+ require 'guard/rails-assets/cli_runner'
2
+ RSpec.describe Guard::RailsAssets::CliRunner do
5
3
  it 'should run the command' do
6
- subject.stub(:system)
7
- subject.should_receive(:system).with("bundle exec rake assets:clean assets:precompile RAILS_ENV=test")
4
+ allow(subject).to receive(:system)
5
+ expect(subject).to receive(:system).with('bundle exec rake assets:clean assets:precompile RAILS_ENV=test')
8
6
  subject.compile_assets
9
7
  end
10
8
 
11
9
  context 'with production environment' do
12
- subject { Guard::RailsAssets::CliRunner.new(:rails_env => :production) }
10
+ subject { Guard::RailsAssets::CliRunner.new(rails_env: :production) }
13
11
  it 'should run the command' do
14
- subject.stub(:system)
15
- subject.should_receive(:system).with("bundle exec rake assets:clean assets:precompile RAILS_ENV=production")
12
+ allow(subject).to receive(:system)
13
+ expect(subject).to receive(:system).with('bundle exec rake assets:clean assets:precompile RAILS_ENV=production')
16
14
  subject.compile_assets
17
15
  end
18
16
  end
@@ -1,8 +1,7 @@
1
- require 'spec_helper'
2
-
3
- describe Guard::RailsAssets::RailsRunner do
1
+ require 'guard/rails-assets/rails_runner'
4
2
 
3
+ RSpec.describe Guard::RailsAssets::RailsRunner do
5
4
  it 'should be tested properly as a Rails engine'
6
-
7
- it { should respond_to :compile_assets }
5
+
6
+ it { is_expected.to respond_to :compile_assets }
8
7
  end
@@ -1,81 +1,79 @@
1
- require 'spec_helper'
1
+ require 'guard/compat/test/helper'
2
2
  require 'guard/rails-assets'
3
3
 
4
- describe Guard::RailsAssets do
5
-
4
+ require_relative '../support/shared_examples'
6
5
 
6
+ RSpec.describe Guard::RailsAssets do
7
7
  context 'with any runner' do
8
-
9
- let(:options) { {:runner => :cli} }
10
- let(:runner) { mock('runner') }
11
- subject { Guard::RailsAssets.new(['watchers'], options) }
8
+ let(:options) { { runner: :cli } }
9
+ let(:runner) { double('runner') }
10
+ subject { Guard::RailsAssets.new(options) }
12
11
 
13
12
  before do
14
- Guard::RailsAssets::CliRunner.stub(:new).and_return runner
13
+ allow(Guard::RailsAssets::CliRunner).to receive(:new).and_return runner
15
14
  end
16
15
 
17
16
  describe '#start' do
18
- it_behaves_like 'guard command', :command => :start, :run => true
17
+ it_behaves_like 'guard command', command: :start, run: true
19
18
  end
20
19
 
21
20
  describe '#reload' do
22
- it_behaves_like 'guard command', :command => :reload, :run => false
21
+ it_behaves_like 'guard command', command: :reload, run: false
23
22
  end
24
23
 
25
24
  describe '#run_all' do
26
- it_behaves_like 'guard command', :command => :run_all, :run => false
25
+ it_behaves_like 'guard command', command: :run_all, run: false
27
26
  end
28
27
 
29
28
  describe '#run_on_change' do
30
- it_behaves_like 'guard command', :command => :run_on_change, :run => true
29
+ it_behaves_like 'guard command', command: :run_on_change, run: true
31
30
  end
32
31
 
33
32
  describe 'run options' do
34
33
  it 'should allow array of symbols' do
35
- guard = Guard::RailsAssets.new(['watchers'], :run_on => [:start, :change])
36
- guard.run_for?(:start).should be_true
37
- guard.run_for?(:reload).should be_false
34
+ guard = Guard::RailsAssets.new(run_on: [:start, :change])
35
+ expect(guard.run_for?(:start)).to be_truthy
36
+ expect(guard.run_for?(:reload)).to be_falsey
38
37
  end
39
38
 
40
39
  it 'should allow symbol' do
41
- guard = Guard::RailsAssets.new(['watchers'], :run_on => :start)
42
- guard.run_for?(:start).should be_true
43
- guard.run_for?(:reload).should be_false
40
+ guard = Guard::RailsAssets.new(run_on: :start)
41
+ expect(guard.run_for?(:start)).to be_truthy
42
+ expect(guard.run_for?(:reload)).to be_falsey
44
43
  end
45
-
46
44
  end
47
45
 
48
46
  describe 'notifications' do
49
- def stub_system_with result
50
- runner.should_receive(:compile_assets).and_return result
47
+ def stub_system_with(result)
48
+ expect(runner).to receive(:compile_assets).and_return result
51
49
  end
52
50
 
53
51
  it 'should notify on success' do
54
52
  stub_system_with true
55
- Guard::Notifier.should_receive(:notify).with('Assets compiled')
53
+ expect(Guard::Compat::UI).to receive(:notify).with('Assets compiled')
56
54
  subject.compile_assets
57
55
  end
58
56
 
59
57
  it 'should notify on failure' do
60
58
  stub_system_with false
61
- Guard::Notifier.should_receive(:notify).with('see the details in the terminal', :title => "Can't compile assets", :image => :failed)
59
+ expect(Guard::Compat::UI).to receive(:notify)
60
+ .with('see the details in the terminal', title: "Can't compile assets", image: :failed)
62
61
  subject.compile_assets
63
62
  end
64
63
  end
65
-
66
64
  end # context with any runner
67
65
 
68
66
  describe 'picking a runner' do
69
67
  it 'should use Rails runner by default' do
70
- Guard::RailsAssets.new(['watchers']).runner.class.should == ::Guard::RailsAssets::RailsRunner
68
+ expect(Guard::RailsAssets.new.runner.class).to eq(::Guard::RailsAssets::RailsRunner)
71
69
  end
72
70
 
73
71
  it 'should use CLI runner' do
74
- Guard::RailsAssets.new(['watchers'], :runner => :cli).runner.class.should == ::Guard::RailsAssets::CliRunner
72
+ expect(Guard::RailsAssets.new(runner: :cli).runner.class).to eq(::Guard::RailsAssets::CliRunner)
75
73
  end
76
-
74
+
77
75
  it 'should use RailsRunner' do
78
- Guard::RailsAssets.new(['watchers'], :runner => :rails).runner.class.should == ::Guard::RailsAssets::RailsRunner
76
+ expect(Guard::RailsAssets.new(runner: :rails).runner.class).to eq(::Guard::RailsAssets::RailsRunner)
79
77
  end
80
78
  end
81
79
  end
@@ -1,24 +1,26 @@
1
- require 'rspec'
2
- require 'guard/rails-assets'
3
- require 'support/shared_examples'
4
- require 'support/stdout_helper'
5
- require 'guard/rails-assets/cli_runner'
6
- require 'guard/rails-assets/rails_runner'
1
+ require 'nenv'
7
2
 
8
3
  RSpec.configure do |config|
9
- config.color_enabled = true
10
- config.filter_run :focus => true
11
- config.run_all_when_everything_filtered = true
12
-
13
- config.before(:each) do
14
- ENV["GUARD_ENV"] = 'test'
15
- @project_path = Pathname.new(File.expand_path('../../', __FILE__))
4
+ config.expect_with :rspec do |expectations|
5
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
16
6
  end
17
7
 
18
- config.after(:each) do
19
- ENV["GUARD_ENV"] = nil
8
+ config.mock_with :rspec do |mocks|
9
+ mocks.verify_partial_doubles = true
20
10
  end
21
-
22
- config.include(Helpers)
23
11
 
12
+ config.filter_run focus: !Nenv.ci?
13
+ config.run_all_when_everything_filtered = true
14
+
15
+ config.disable_monkey_patching!
16
+
17
+ config.warnings = true
18
+
19
+ config.default_formatter = 'doc' if config.files_to_run.one?
20
+
21
+ # config.profile_examples = 10
22
+
23
+ config.order = :random
24
+
25
+ Kernel.srand config.seed
24
26
  end
@@ -1,6 +1,5 @@
1
- shared_examples_for "guard command" do |info|
2
-
3
- def set_run_on_option info
1
+ RSpec.shared_examples_for 'guard command' do |info|
2
+ def run_on_option=(info)
4
3
  # run_on_change -> change
5
4
  # run_all -> all
6
5
  run_option = info[:command].to_s.match(/(.*_)?(\w+)/)[2].to_sym
@@ -8,24 +7,23 @@ shared_examples_for "guard command" do |info|
8
7
  end
9
8
 
10
9
  it "should execute #{info[:command]} when said so" do
11
- set_run_on_option info
12
- subject.should_receive(:compile_assets)
10
+ self.run_on_option = info
11
+ expect(subject).to receive(:compile_assets)
13
12
  subject.send(info[:command])
14
13
  end
15
14
  it "should not execute #{info[:command]} when disabled" do
16
15
  options[:run_on] = [:something_other]
17
- subject.should_not_receive(:compile_assets)
16
+ expect(subject).not_to receive(:compile_assets)
18
17
  subject.send(info[:command])
19
18
  end
20
19
 
21
20
  it "should #{info[:run] ? '' : 'not '}execute #{info[:command]} by default" do
22
21
  options[:run_on] = nil
23
22
  if info[:run]
24
- subject.should_receive(:compile_assets)
23
+ expect(subject).to receive(:compile_assets)
25
24
  else
26
- subject.should_not_receive(:compile_assets)
25
+ expect(subject).not_to receive(:compile_assets)
27
26
  end
28
27
  subject.send(info[:command])
29
28
  end
30
-
31
29
  end
@@ -1,9 +1,8 @@
1
1
  require 'stringio'
2
2
 
3
3
  module Helpers
4
-
5
4
  def capture(*streams)
6
- streams.map! { |stream| stream.to_s }
5
+ streams.map!(&:to_s)
7
6
  begin
8
7
  result = StringIO.new
9
8
  streams.each { |stream| eval "$#{stream} = result" }
@@ -13,5 +12,4 @@ module Helpers
13
12
  end
14
13
  result.string
15
14
  end
16
-
17
- end
15
+ end
@@ -0,0 +1,23 @@
1
+ require 'rspec'
2
+ require 'guard/rails-assets'
3
+ require 'support/shared_examples'
4
+ require 'support/stdout_helper'
5
+ require 'guard/rails-assets/cli_runner'
6
+ require 'guard/rails-assets/rails_runner'
7
+
8
+ RSpec.configure do |config|
9
+ config.color_enabled = true
10
+ config.filter_run focus: true
11
+ config.run_all_when_everything_filtered = true
12
+
13
+ config.before(:each) do
14
+ ENV['GUARD_ENV'] = 'test'
15
+ @project_path = Pathname.new(File.expand_path('../../', __FILE__))
16
+ end
17
+
18
+ config.after(:each) do
19
+ ENV['GUARD_ENV'] = nil
20
+ end
21
+
22
+ config.include(Helpers)
23
+ end
metadata CHANGED
@@ -1,71 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-rails-assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmytrii Nagirniak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-30 00:00:00.000000000 Z
11
+ date: 2015-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '2.6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '2.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: guard-compat
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - '>='
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
47
  version: '0'
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - '>='
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rails
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - '>='
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
61
  version: 3.1.1
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - '>='
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: 3.1.1
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - '>='
73
+ - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '0'
75
+ version: '3.1'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - '>='
80
+ - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '0'
82
+ version: '3.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: nenv
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.1'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.1'
69
97
  description: guard-rails-assets automatically generates JavaScript, CSS, Image files
70
98
  using Rails assets pipelie
71
99
  email:
@@ -74,7 +102,10 @@ executables: []
74
102
  extensions: []
75
103
  extra_rdoc_files: []
76
104
  files:
77
- - .gitignore
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".rubocop.yml"
108
+ - ".rubocop_todo.yml"
78
109
  - Gemfile
79
110
  - README.md
80
111
  - Rakefile
@@ -90,7 +121,8 @@ files:
90
121
  - spec/spec_helper.rb
91
122
  - spec/support/shared_examples.rb
92
123
  - spec/support/stdout_helper.rb
93
- homepage: http://github.com/dnagir/guard-rails-assets
124
+ - spec_helper.rb
125
+ homepage: http://github.com/guard/guard-rails-assets
94
126
  licenses:
95
127
  - MIT
96
128
  - WTFPL
@@ -101,24 +133,18 @@ require_paths:
101
133
  - lib
102
134
  required_ruby_version: !ruby/object:Gem::Requirement
103
135
  requirements:
104
- - - '>='
136
+ - - ">="
105
137
  - !ruby/object:Gem::Version
106
138
  version: '0'
107
139
  required_rubygems_version: !ruby/object:Gem::Requirement
108
140
  requirements:
109
- - - '>='
141
+ - - ">="
110
142
  - !ruby/object:Gem::Version
111
143
  version: '0'
112
144
  requirements: []
113
145
  rubyforge_project: guard-rails-assets
114
- rubygems_version: 2.0.3
146
+ rubygems_version: 2.4.5
115
147
  signing_key:
116
148
  specification_version: 4
117
149
  summary: Guard for compiling Rails assets
118
- test_files:
119
- - spec/guard/rails-assets/cli_runner_spec.rb
120
- - spec/guard/rails-assets/rails_runner_spec.rb
121
- - spec/guard/rails-assets_spec.rb
122
- - spec/spec_helper.rb
123
- - spec/support/shared_examples.rb
124
- - spec/support/stdout_helper.rb
150
+ test_files: []