ammeter 1.1.4 → 1.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
- SHA1:
3
- metadata.gz: a001157dcbfae6b406995d4e01a27b89ce22ae92
4
- data.tar.gz: 7f43153034ae84e0698a73c609782714224d64dc
2
+ SHA256:
3
+ metadata.gz: 45a625241c915188a70b534c263a9c38bfb1c0315aedf7d7a31fd27aaec8407f
4
+ data.tar.gz: 80c902df52f5b7b68af80f680dbc0273c5b42b819d0a19f7de2065ddc3d556e3
5
5
  SHA512:
6
- metadata.gz: 44b2ea56e21b1650b60a598d0ac45ab8e07c0e36c8500a93a067cc2ed42dacc8efc853996ceea1d4362b4f50de75454ab440833689c5ede74881a7c31aef1673
7
- data.tar.gz: d54a0ab64428f7f462f5fb22c70ca2af3e0498b95e94c86b26babc6d7c5741fa8d915b820ae4dd047443432c03713c61e1e38093e0d79c044b14962c0baf24c1
6
+ metadata.gz: 3ce7d82c75dedff9639409713b630ce6ea8e04c11a75536bd2ef4f5200a9901cc111510d643b316b51da78b83f3cf1729ec5a85d296ff755ea9256e2caca8145
7
+ data.tar.gz: a99410d8eddd86ca0732099a108a9fdcad91674b72e93e7f93d67a8dc6464cde8eb93f860514edaad65c43281304b3c05d8eb9b8035b892bc42f8cb96b0cd704
@@ -0,0 +1,70 @@
1
+ name: Ammeter CI
2
+ on:
3
+ push:
4
+ branches:
5
+ - 'main'
6
+ pull_request:
7
+ branches:
8
+ - '*'
9
+ jobs:
10
+ test:
11
+ name: 'Ruby: ${{ matrix.ruby }}, Rspec: ${{matrix.env.RSPEC_VERSION}}, Rails: ${{ matrix.env.RAILS_VERSION }}'
12
+ runs-on: ubuntu-20.04
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ include:
17
+ - ruby: 3.0
18
+ env:
19
+ RSPEC_VERSION: 'master'
20
+ RAILS_VERSION: '~> 6.1.0'
21
+ - ruby: 3.0
22
+ env:
23
+ RSPEC_VERSION: '~> 4.0'
24
+ RAILS_VERSION: '~> 6.1.0'
25
+ - ruby: 3.0
26
+ env:
27
+ RSPEC_VERSION: '~> 4.0'
28
+ RAILS_VERSION: '~> 6.0.0'
29
+ - ruby: 3.0
30
+ env:
31
+ RSPEC_VERSION: '~> 3.9'
32
+ RAILS_VERSION: '~> 6.0.0'
33
+ - ruby: 2.5
34
+ env:
35
+ RSPEC_VERSION: 'master'
36
+ RAILS_VERSION: '~> 6.1.0'
37
+ - ruby: 2.5
38
+ env:
39
+ RSPEC_VERSION: '~> 4.0'
40
+ RAILS_VERSION: '~> 6.1.0'
41
+ - ruby: 2.5
42
+ env:
43
+ RSPEC_VERSION: '~> 4.0'
44
+ RAILS_VERSION: '~> 6.0.0'
45
+ - ruby: 2.5
46
+ env:
47
+ RSPEC_VERSION: '~> 4.0'
48
+ RAILS_VERSION: '~> 5.2.0'
49
+ - ruby: 2.5
50
+ env:
51
+ RSPEC_VERSION: '~> 3.9'
52
+ RAILS_VERSION: '~> 6.0.0'
53
+ - ruby: 2.5
54
+ env:
55
+ RSPEC_VERSION: '~> 3.9'
56
+ RAILS_VERSION: '~> 5.2.0'
57
+ - ruby: ruby-head
58
+ env:
59
+ RSPEC_VERSION: 'master'
60
+ RAILS_VERSION: '~> 6.1.0'
61
+ env: ${{ matrix.env }}
62
+ steps:
63
+ - uses: actions/checkout@v2
64
+ - uses: ruby/setup-ruby@v1
65
+ with:
66
+ ruby-version: ${{ matrix.ruby }}
67
+ bundler-cache: true
68
+ - run: bundle install
69
+ - run: bundle exec rake ci
70
+ continue-on-error: ${{ matrix.allow_failure || false }}
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.2
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
- source "http://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- rspec_version = ENV['RSPEC_VERSION']
4
- rspec_major_version = (rspec_version && rspec_version != 'master') ? rspec_version.scan(/\d+/).first : '3'
3
+ rspec_version = ENV['RSPEC_VERSION'] || '~> 4.0'
4
+ rails_version = ENV['RAILS_VERSION'] || '>= 5.1.0'
5
5
 
6
6
  if rspec_version == 'master'
7
7
  gem "rspec-rails", :git => 'git://github.com/rspec/rspec-rails.git'
@@ -13,38 +13,16 @@ if rspec_version == 'master'
13
13
  gem "rspec-support", :git => 'git://github.com/rspec/rspec-support.git'
14
14
  else
15
15
  gem 'rspec-rails', rspec_version
16
- gem 'rspec', rspec_version
17
16
  end
18
17
 
19
- if rspec_major_version == '2' || RUBY_VERSION.to_f < 1.9
20
- # rspec 2.x does not support Rails 4.1+ nor does Ruby 1.8.7
21
- gem 'rails', '~> 3.2'
22
- gem 'uglifier', '~> 1.2.4'
23
- gem 'rake', '~> 0.9.2.2'
24
- gem 'coffee-rails', '~> 3.2'
25
- gem 'sass-rails', '~> 3.2'
26
- gem 'jquery-rails', '~> 2.0'
27
- gem 'haml-rails', '~> 0.4'
28
- gem 'execjs', '~> 2.0.0'
29
- elsif rspec_major_version == '3'
30
- if RUBY_VERSION < '2.2.2'
31
- gem 'rails', '< 5.0' # rails 5 is ruby >= 2.2.2
32
- else
33
- gem 'rails', '>= 4.0'
34
- end
35
- gem 'uglifier', '>= 1.3'
36
- gem 'rake', '>= 0.10'
37
- gem 'coffee-rails', '>= 4.0'
38
- gem 'sass-rails', '>= 4.0'
39
- gem 'jquery-rails', '>= 3.0'
40
- gem 'haml-rails', '>= 0.5'
41
- else
42
- raise "rspec version #{rspec_version} is not supported"
43
- end
44
-
45
- gem "i18n", '< 0.7.0' if RUBY_VERSION < '1.9.3'
46
- gem "rack", '<= 1.6.4' if RUBY_VERSION < '2.2.2'
18
+ gem 'rails', rails_version
19
+ gem 'uglifier'
20
+ gem 'rake'
21
+ gem 'coffee-rails'
22
+ gem 'sass-rails'
23
+ gem 'jquery-rails'
24
+ gem 'haml-rails'
47
25
 
48
- # Specify your gem's dependencies in rspec-rails-generator-specs.gemspec
26
+ # Specify your gem's dependencies in ammeter.gemspec
49
27
  gemspec
50
28
 
data/History.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## Ammeter release history
2
2
 
3
+ ### 1.1.6 / 2023-11-29
4
+
5
+ [full changelog](https://github.com/alexrothenberg/ammeter/compare/v1.1.5...v1.1.6)
6
+
7
+ * Deprecate the custom exist matcher (#68)
8
+
3
9
  ### 1.0.0 / 2014-04-07
4
10
 
5
11
  [full changelog](https://github.com/alexrothenberg/ammeter/compare/v0.2.9...v1.0.0)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Ammeter [![Build Status](https://secure.travis-ci.org/alexrothenberg/ammeter.png)](http://travis-ci.org/alexrothenberg/ammeter) [![Code Climate](https://codeclimate.com/github/alexrothenberg/ammeter.png)](https://codeclimate.com/github/alexrothenberg/ammeter) [![Gem Version](https://badge.fury.io/rb/ammeter.png)](http://badge.fury.io/rb/ammeter)
1
+ # Ammeter [![Ammeter CI](https://github.com/alexrothenberg/ammeter/actions/workflows/ci.yml/badge.svg)](https://github.com/alexrothenberg/ammeter/actions/workflows/ci.yml) [![Code Climate](https://codeclimate.com/github/alexrothenberg/ammeter.png)](https://codeclimate.com/github/alexrothenberg/ammeter) [![Gem Version](https://badge.fury.io/rb/ammeter.png)](http://badge.fury.io/rb/ammeter)
2
2
 
3
3
 
4
4
  A gem that makes it easy to write specs for your Rails 3 Generators.
@@ -13,6 +13,24 @@ and we think you may find it useful too.
13
13
  An [ammeter](http://en.wikipedia.org/wiki/Ammeter) is used to measure electrical current and
14
14
  electricity can be produced by a generator.
15
15
 
16
+ # Installation
17
+ Add this line to your Gemfile (or gemspec):
18
+
19
+ ```ruby
20
+ gem 'ammeter'
21
+ ```
22
+
23
+ And then execute:
24
+ ```bash
25
+ $ bundle
26
+ ```
27
+
28
+ Add:
29
+ ```ruby
30
+ require 'ammeter/init'
31
+ ```
32
+ To your `spec/spec_helper.rb`.
33
+
16
34
  # Example
17
35
 
18
36
  ```ruby
@@ -53,8 +71,6 @@ describe Rspec::Generators::ModelGenerator, :type => :generator do
53
71
  describe 'the spec' do
54
72
  # file - gives you the absolute path where the generator will create the file
55
73
  subject { file('spec/models/posts_spec.rb') }
56
- # is_expected_to exist - verifies the file exists
57
- it { is_expected_to exist }
58
74
 
59
75
  # is_expected_to contain - verifies the file's contents
60
76
  it { is_expected_to contain /require 'spec_helper'/ }
@@ -64,7 +80,7 @@ describe Rspec::Generators::ModelGenerator, :type => :generator do
64
80
  subject { migration_file('db/migrate/create_posts.rb') }
65
81
 
66
82
  # is_expected_to be_a_migration - verifies the file exists with a migration timestamp as part of the filename
67
- it { is_expected_to exist }
83
+ it { is_expected_to be_a_migration }
68
84
  it { is_expected_to contain /create_table/ }
69
85
  end
70
86
  end
@@ -73,7 +89,6 @@ end
73
89
 
74
90
  # Available matchers
75
91
 
76
- - `exist` - verifies the file exists
77
92
  - `contain` - verifies the file's contents
78
93
  - `be_a_migration` - verifies the file exists with a migration timestamp as part of the filename
79
94
  - `have_method` - verifies the file (or a class withing it) implements a method
data/Rakefile CHANGED
@@ -35,20 +35,19 @@ def create_gem(gem_name)
35
35
  sh "mkdir -p tmp/#{gem_name}/spec"
36
36
  sh "cp '#{template_folder}/spec/spec_helper.rb' tmp/#{gem_name}/spec"
37
37
  Dir.chdir("./tmp/#{gem_name}") do
38
- Bundler.clean_system 'bundle install'
38
+ Bundler.unbundled_system 'bundle install'
39
39
  end
40
40
  end
41
41
 
42
42
  namespace :generate do
43
43
  desc "generate a fresh app with rspec installed"
44
44
  task :app => :ensure_bundler_11 do |t|
45
- sh "bundle exec rails new ./tmp/example_app -m 'features/templates/generate_example_app.rb' --skip-test-unit"
45
+ sh "bundle exec rails new ./tmp/example_app -m 'features/templates/generate_example_app.rb' --skip-test-unit --skip-bootsnap --skip-spring --skip-webpack-install"
46
46
  sh "cp 'features/templates/rspec.rake' ./tmp/example_app/lib/tasks"
47
47
  Dir.chdir("./tmp/example_app/") do
48
- Bundler.clean_system 'bundle install'
49
- Bundler.clean_system 'rake db:migrate'
50
- Bundler.clean_system 'rails g rspec:install'
51
- Bundler.clean_system 'spring stop'
48
+ Bundler.unbundled_system 'bundle install'
49
+ Bundler.unbundled_system 'rake db:migrate'
50
+ Bundler.unbundled_system 'rails g rspec:install'
52
51
  end
53
52
  end
54
53
 
@@ -42,7 +42,7 @@ def copy_to_aruba_from(gem_or_app_name)
42
42
  if rspec_major_version == '2'
43
43
  # rspec 2.x does not create rails_helper.rb so we create a symlink to avoid cluttering tests
44
44
  write_symlink("tmp/#{gem_or_app_name}/spec/spec_helper.rb", gem_or_app_name, 'rails_helper.rb')
45
- elsif rspec_major_version == '3'
45
+ elsif rspec_major_version >= '3'
46
46
  write_symlink("tmp/#{gem_or_app_name}/spec/rails_helper.rb", gem_or_app_name)
47
47
  end
48
48
  end
@@ -11,7 +11,6 @@ if rspec_version == 'master'
11
11
  gem "rspec-support", :git => 'git://github.com/rspec/rspec-support.git'
12
12
  else
13
13
  gem 'rspec-rails', rspec_version
14
- gem 'rspec', rspec_version
15
14
  end
16
15
 
17
16
  gem "i18n", '< 0.7.0' if RUBY_VERSION < '1.9.3'
@@ -1,7 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- rspec_version = ENV['RSPEC_VERSION']
4
- rspec_major_version = (rspec_version && rspec_version != 'master') ? rspec_version.scan(/\d+/).first : '3'
3
+ rspec_version = ENV['RSPEC_VERSION'] || '~> 4.0'
4
+ rails_version = ENV['RAILS_VERSION'] || '>= 5.1.0'
5
5
 
6
6
  if rspec_version == 'master'
7
7
  gem "rspec-rails", :git => 'git://github.com/rspec/rspec-rails.git'
@@ -13,19 +13,9 @@ if rspec_version == 'master'
13
13
  gem "rspec-support", :git => 'git://github.com/rspec/rspec-support.git'
14
14
  else
15
15
  gem 'rspec-rails', rspec_version
16
- gem 'rspec', rspec_version
17
- end
18
-
19
- if rspec_major_version == '2' || RUBY_VERSION.to_f < 1.9
20
- gem 'rails', '~> 3.2.0'
21
- # Execjs is causing problems on 1.8.7
22
- gem 'execjs', '~> 2.0.0'
23
- elsif rspec_major_version == '3'
24
- gem 'rails', '>= 4.1'
25
- else
26
- raise "rspec version #{rspec_version} is not supported"
27
16
  end
28
17
 
18
+ gem 'rails', rails_version
29
19
 
30
20
  # Specify your gem's dependencies in my_gem.gemspec
31
21
  gemspec
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env rake
2
1
  require "bundler/gem_tasks"
3
2
 
4
3
  require 'rspec'
@@ -1,7 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- rspec_version = ENV['RSPEC_VERSION']
4
- rspec_major_version = (rspec_version && rspec_version != 'master') ? rspec_version.scan(/\d+/).first : '3'
3
+ rspec_version = ENV['RSPEC_VERSION'] || '~> 4.0'
4
+ rails_version = ENV['RAILS_VERSION'] || '>= 5.1.0'
5
5
 
6
6
  if rspec_version == 'master'
7
7
  gem "rspec-rails", :git => 'git://github.com/rspec/rspec-rails.git'
@@ -13,19 +13,9 @@ if rspec_version == 'master'
13
13
  gem "rspec-support", :git => 'git://github.com/rspec/rspec-support.git'
14
14
  else
15
15
  gem 'rspec-rails', rspec_version
16
- gem 'rspec', rspec_version
17
- end
18
-
19
- if rspec_major_version == '2' || RUBY_VERSION.to_f < 1.9
20
- gem 'railties', '~> 3.2.0'
21
- # Execjs is causing problems on 1.8.7
22
- #gem 'execjs', '~> 2.0.0'
23
- elsif rspec_major_version == '3'
24
- gem 'railties', '>= 4.1'
25
- else
26
- raise "rspec version #{rspec_version} is not supported"
27
16
  end
28
17
 
18
+ gem 'railties', rails_version
29
19
 
30
20
  # Specify your gem's dependencies in my_gem.gemspec
31
21
  gemspec
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env rake
2
1
  require "bundler/gem_tasks"
3
2
 
4
3
  require 'rspec'
@@ -12,7 +12,8 @@ RSpec::configure do |c|
12
12
  c.include Ammeter::RSpec::Rails::GeneratorExampleHelpers,
13
13
  :type => :generator
14
14
  c.include Ammeter::RSpec::Rails::GeneratorExampleGroup,
15
- :type => :generator,
15
+ :type => :generator
16
+ c.include Ammeter::RSpec::Rails::GeneratorExampleGroup,
16
17
  :file_path => lambda { |file_path, metadata|
17
18
  metadata[:type].nil? && generator_path_regex =~ file_path
18
19
  }
@@ -1,5 +1,11 @@
1
- RSpec::Matchers.define :exist do
1
+ # DEPRECATED: use `expect(Pathname.new(path)).to exist` instead
2
+ RSpec::Matchers.define :exist do |*expected|
2
3
  match do |file_path|
3
- File.exist?(file_path)
4
+ if !(file_path.respond_to?(:exist?) || file_path.respond_to?(:exists?))
5
+ ActiveSupport::Deprecation.warn "The `exist` matcher overrides one built-in by RSpec; use `expect(Pathname.new(path)).to exist` instead"
6
+ File.exist?(file_path)
7
+ else
8
+ RSpec::Matchers::BuiltIn::Exist.new(*expected).matches?(file_path)
9
+ end
4
10
  end
5
11
  end
@@ -30,7 +30,11 @@ RSpec::Matchers.define :have_correct_syntax do
30
30
  require 'ostruct'
31
31
 
32
32
  begin
33
- view = ActionView::Template::Handlers::ERB.call(OpenStruct.new(:source => code))
33
+ if Rails::VERSION::STRING < "6.0"
34
+ view = ActionView::Template::Handlers::ERB.call(OpenStruct.new(:source => code))
35
+ else
36
+ view = ActionView::Template::Handlers::ERB.call(OpenStruct.new, code)
37
+ end
34
38
  eval('__crash_me__; ' + view)
35
39
  rescue SyntaxError
36
40
  false
@@ -1,3 +1,3 @@
1
1
  module Ammeter
2
- VERSION = "1.1.4"
2
+ VERSION = "1.1.6"
3
3
  end
@@ -5,9 +5,17 @@ describe "exist" do
5
5
  allow(File).to receive(:exist?).with('/some/file/path').and_return(true)
6
6
  expect('/some/file/path').to exist
7
7
  end
8
+
8
9
  it 'fails when the file does not exist' do
9
10
  allow(File).to receive(:exist?).with('/some/file/path').and_return(false)
10
11
  expect('/some/file/path').to_not exist
11
12
  end
12
13
 
14
+ it 'maintains default RSpec behavior', :aggregate_failures do
15
+ path = Pathname.new('/some/file/path')
16
+ allow(path).to receive(:exist?).and_return(true)
17
+ expect(path).to exist
18
+ allow(path).to receive(:exist?).and_return(false)
19
+ expect(path).not_to exist
20
+ end
13
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ammeter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Rothenberg
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-23 00:00:00.000000000 Z
11
+ date: 2023-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -213,8 +213,9 @@ executables: []
213
213
  extensions: []
214
214
  extra_rdoc_files: []
215
215
  files:
216
+ - ".github/workflows/ci.yml"
216
217
  - ".gitignore"
217
- - ".travis.yml"
218
+ - ".ruby-version"
218
219
  - Gemfile
219
220
  - History.md
220
221
  - LICENSE.txt
@@ -267,7 +268,7 @@ files:
267
268
  homepage: ''
268
269
  licenses: []
269
270
  metadata: {}
270
- post_install_message:
271
+ post_install_message:
271
272
  rdoc_options: []
272
273
  require_paths:
273
274
  - lib
@@ -282,9 +283,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
282
283
  - !ruby/object:Gem::Version
283
284
  version: '0'
284
285
  requirements: []
285
- rubyforge_project:
286
- rubygems_version: 2.4.3
287
- signing_key:
286
+ rubygems_version: 3.4.10
287
+ signing_key:
288
288
  specification_version: 4
289
289
  summary: Write specs for your Rails 3+ generators
290
290
  test_files:
data/.travis.yml DELETED
@@ -1,23 +0,0 @@
1
- language: ruby
2
- sudo: false
3
-
4
- rvm:
5
- - 2.3.0
6
- - 2.2
7
- - 2.1.2
8
- - 2.0.0
9
- - ruby-head
10
- - jruby-9.1.2.0
11
-
12
- env:
13
- - RSPEC_VERSION=master
14
- - RSPEC_VERSION='~> 3.0'
15
-
16
- bundler_args: "--retry=3 --jobs=3"
17
-
18
- script: "bundle exec rake ci --trace"
19
-
20
- matrix:
21
- allow_failures:
22
- - rvm: ruby-head
23
- - rvm: jruby-9.1.2.0