ammeter 0.2.9 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2de6d4a25f2da4f07ab81378f182f7f258bbb4b3
4
+ data.tar.gz: cc570161b0b4857749090fe8085dcd910227a14d
5
+ SHA512:
6
+ metadata.gz: f5c31970c5ab5a6ef56fd920c76d408a99534254348b8b91d3a9b248555490148241b38383227ec8119d9d4bcb1bd850464b9b8bc21f59876b30e7a8166f5868
7
+ data.tar.gz: 3cff3a5991a9293fdde73c16beb7848632045ffec136e4dc4715a54fa24633d276b16e75f336bfd1a1220ed64f40721eddd1228426e8d8582942202bd24b6b8d
@@ -1,18 +1,22 @@
1
1
  script: "bundle exec rake ci"
2
2
  rvm:
3
3
  - ruby-head
4
+ - 2.1.1
4
5
  - 2.0.0
5
6
  - 1.9.3
6
7
  - 1.8.7
7
8
  - jruby-head
8
9
  - jruby-19mode
9
- - jruby-18mode
10
10
  - rbx-19mode
11
- - rbx-18mode
11
+ env:
12
+ - RSPEC_VERSION=master
13
+ - RSPEC_VERSION=2.99.0.beta2
14
+ - RSPEC_VERSION=2.14
12
15
  matrix:
13
16
  allow_failures:
17
+ - rvm: 1.8.7
18
+ - rvm: 1.9.3
19
+ - rvm: ruby-head
14
20
  - rvm: jruby-head
15
21
  - rvm: jruby-19mode
16
- - rvm: jruby-18mode
17
22
  - rvm: rbx-19mode
18
- - rvm: rbx-18mode
data/Gemfile CHANGED
@@ -1,4 +1,21 @@
1
1
  source "http://rubygems.org"
2
2
 
3
+ rspec_version = ENV['RSPEC_VERSION'] || '2.99.0.beta2'
4
+
5
+ case rspec_version
6
+ when 'master'
7
+ gem "rspec-rails", :git => 'git://github.com/rspec/rspec-rails.git'
8
+ gem "rspec", :git => 'git://github.com/rspec/rspec.git'
9
+ gem "rspec-core", :git => 'git://github.com/rspec/rspec-core.git'
10
+ gem "rspec-expectations", :git => 'git://github.com/rspec/rspec-expectations.git'
11
+ gem "rspec-mocks", :git => 'git://github.com/rspec/rspec-mocks.git'
12
+ gem "rspec-collection_matchers", :git => 'git://github.com/rspec/rspec-collection_matchers.git'
13
+ gem "rspec-support", :git => 'git://github.com/rspec/rspec-support.git'
14
+ else
15
+ gem 'rspec-rails', rspec_version
16
+ gem 'rspec', rspec_version
17
+ end
18
+
3
19
  # Specify your gem's dependencies in rspec-rails-generator-specs.gemspec
4
20
  gemspec
21
+
data/History.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## Ammeter release history
2
2
 
3
+ ### 1.0.0 / 2014-04-07
4
+
5
+ [full changelog](https://github.com/alexrothenberg/ammeter/compare/v0.2.9...v1.0.0)
6
+
7
+ * Compatible with RSpec 3 & RSpec 2
8
+
3
9
  ### 0.2.9 / 2013-06-06
4
10
 
5
11
  [full changelog](https://github.com/alexrothenberg/ammeter/compare/v0.2.8...v0.2.9)
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'bundler/setup'
3
3
  Bundler::GemHelper.install_tasks
4
4
 
5
5
  require 'rdoc/task'
6
- require 'rspec'
6
+ require 'rspec/core'
7
7
  require 'rspec/core/rake_task'
8
8
  require 'cucumber/rake/task'
9
9
 
@@ -19,9 +19,9 @@ Gem::Specification.new do |s|
19
19
 
20
20
  s.add_runtime_dependency 'railties', '>= 3.0'
21
21
  s.add_runtime_dependency 'activesupport', '>= 3.0'
22
- s.add_runtime_dependency 'rspec', '>= 2.2'
23
22
  s.add_runtime_dependency 'rspec-rails', '>= 2.2'
24
23
 
24
+ s.add_development_dependency 'rspec', '>= 2.2'
25
25
  s.add_development_dependency 'rails', '>= 3.1'
26
26
  s.add_development_dependency 'uglifier', '>= 1.2.4'
27
27
  s.add_development_dependency 'rake', '>= 0.9.2.2'
@@ -29,9 +29,9 @@ Feature: Gems can contain generators
29
29
  before { run_generator %w(my_dir) }
30
30
  describe 'public/my_dir/awesome.html' do
31
31
  subject { file('public/my_dir/awesome.html') }
32
- it { should exist }
33
- it { should contain 'This is an awesome file' }
34
- it { should_not contain 'This text is not in the file' }
32
+ it { expect(subject).to exist }
33
+ it { expect(subject).to contain 'This is an awesome file' }
34
+ it { expect(subject).to_not contain 'This text is not in the file' }
35
35
  end
36
36
  end
37
37
  """
@@ -67,14 +67,14 @@ Feature: Gems can contain generators
67
67
  before { run_generator %w(post) }
68
68
  describe 'app/controller/posts_controller.rb' do
69
69
  subject { file('app/controllers/posts_controller.rb') }
70
- it { should exist }
71
- it { should contain 'class PostsController < ResourcefulController' }
70
+ it { expect(subject).to exist }
71
+ it { expect(subject).to contain 'class PostsController < ResourcefulController' }
72
72
  end
73
73
 
74
74
  describe 'app/models/post.rb' do
75
75
  subject { file('app/models/post.rb') }
76
- it { should exist }
77
- it { should contain 'class Post < ActiveRecord::Base' }
76
+ it { expect(subject).to exist }
77
+ it { expect(subject).to contain 'class Post < ActiveRecord::Base' }
78
78
  end
79
79
  end
80
80
  """
@@ -39,15 +39,15 @@ Feature: generator spec
39
39
  before { run_generator %w(my_dir) }
40
40
  describe 'public/my_dir/awesome.html' do
41
41
  subject { file('public/my_dir/awesome.html') }
42
- it { should exist }
43
- it { should contain 'This is an awesome file' }
44
- it { should_not contain 'This text is not in the file' }
42
+ it { expect(subject).to exist }
43
+ it { expect(subject).to contain 'This is an awesome file' }
44
+ it { expect(subject).to_not contain 'This text is not in the file' }
45
45
  end
46
46
  describe 'public/my_dir/lame.html' do
47
47
  subject { file('public/my_dir/lame.html') }
48
- it { should exist }
49
- it { should contain 'This is a lame file' }
50
- it { should_not contain 'This text is not in the file' }
48
+ it { expect(subject).to exist }
49
+ it { expect(subject).to contain 'This is a lame file' }
50
+ it { expect(subject).to_not contain 'This text is not in the file' }
51
51
  end
52
52
  end
53
53
  """
@@ -66,9 +66,9 @@ Feature: generator spec
66
66
  before { invoke_task :create_awesomeness }
67
67
  describe 'public/another_dir/awesome.html' do
68
68
  subject { file('public/another_dir/awesome.html') }
69
- it { should exist }
70
- it { should contain 'This is an awesome file' }
71
- it { should_not contain 'This text is not in the file' }
69
+ it { expect(subject).to exist }
70
+ it { expect(subject).to contain 'This is an awesome file' }
71
+ it { expect(subject).to_not contain 'This text is not in the file' }
72
72
  end
73
73
  describe 'public/another_dir/lame.html' do
74
74
  subject { file('public/another_dir/lame.html') }
@@ -89,17 +89,17 @@ Feature: generator spec
89
89
  before { run_generator %w(my_dir) }
90
90
  describe 'public/my_dir/awesome.html' do
91
91
  subject { file('public/my_dir/awesome.html') }
92
- it { should_not contain 'This is an awesome file' }
93
- it { should contain 'This text is not in the file' }
94
- it { should_not exist }
92
+ it { expect(subject).to_not contain 'This is an awesome file' }
93
+ it { expect(subject).to contain 'This text is not in the file' }
94
+ it { expect(subject).to_not exist }
95
95
  end
96
96
  describe 'public/my_dir/non_existent.html' do
97
97
  subject { file('public/my_dir/non_existent.html') }
98
- it { should exist }
98
+ it { expect(subject).to exist }
99
99
  end
100
100
  describe 'db/migrate/non_existent_migration.rb' do
101
101
  subject { migration_file('db/migrate/non_existent_migration.rb') }
102
- it { should exist }
102
+ it { expect(subject).to exist }
103
103
  end
104
104
  end
105
105
  """
@@ -138,11 +138,11 @@ Feature: generator spec
138
138
  before { generator.invoke_all }
139
139
  describe 'public/my_dir/super_awesome.html' do
140
140
  subject { file('public/my_dir/super_awesome.html') }
141
- it { should exist }
141
+ it { expect(subject).to exist }
142
142
  end
143
143
  describe 'public/my_dir/super_lame.html' do
144
144
  subject { file('public/my_dir/super_lame.html') }
145
- it { should exist }
145
+ it { expect(subject).to exist }
146
146
  end
147
147
  end
148
148
  """
@@ -158,9 +158,9 @@ Feature: generator spec
158
158
  describe ActiveRecord::Generators::MigrationGenerator do
159
159
  before { run_generator %w(create_posts) }
160
160
  subject { migration_file('db/migrate/create_posts.rb') }
161
- it { should exist }
162
- it { should be_a_migration }
163
- it { should contain 'class CreatePosts < ActiveRecord::Migration' }
161
+ it { expect(subject).to exist }
162
+ it { expect(subject).to be_a_migration }
163
+ it { expect(subject).to contain 'class CreatePosts < ActiveRecord::Migration' }
164
164
  end
165
165
  """
166
166
  When I run `rake spec`
@@ -178,8 +178,8 @@ Feature: generator spec
178
178
  before { run_generator %w(my_dir --super) }
179
179
  describe 'public/my_dir/super_awesome.html' do
180
180
  subject { file('public/my_dir/super_awesome.html') }
181
- it { should == "#{Rails.root}/tmp/generated_files/public/my_dir/super_awesome.html" }
182
- it { should exist }
181
+ it { expect(subject).to eq "#{Rails.root}/tmp/generated_files/public/my_dir/super_awesome.html" }
182
+ it { expect(subject).to exist }
183
183
  end
184
184
  end
185
185
  """
@@ -34,14 +34,14 @@ Feature: generator spec
34
34
  before { run_generator %w(post) }
35
35
  describe 'app/controller/posts_controller.rb' do
36
36
  subject { file('app/controllers/posts_controller.rb') }
37
- it { should exist }
38
- it { should contain 'class PostsController < ResourcefulController' }
37
+ it { expect(subject).to exist }
38
+ it { expect(subject).to contain 'class PostsController < ResourcefulController' }
39
39
  end
40
40
 
41
41
  describe 'app/models/post.rb' do
42
42
  subject { file('app/models/post.rb') }
43
- it { should exist }
44
- it { should contain 'class Post < ActiveRecord::Base' }
43
+ it { expect(subject).to exist }
44
+ it { expect(subject).to contain 'class Post < ActiveRecord::Base' }
45
45
  end
46
46
  end
47
47
  """
@@ -1,2 +1,2 @@
1
- gem 'rspec-rails'
1
+ gem 'rspec-rails'#, '>=3.0.0.beta2'
2
2
  gem 'ammeter', :path=>'../..'
@@ -16,5 +16,5 @@ Gem::Specification.new do |gem|
16
16
  gem.version = MyRailsGem::VERSION
17
17
 
18
18
  gem.add_runtime_dependency 'rails', '>= 3.1'
19
- gem.add_development_dependency 'rspec-rails', '>= 2.2'
19
+ gem.add_development_dependency 'rspec-rails', '>=2.2'
20
20
  end
@@ -1,3 +1,7 @@
1
+ require 'rspec/core'
2
+ if RSpec::Core::Version::STRING < '3'
3
+ require 'ammeter/rspec/rspec_2_compatibility' # if rspec2
4
+ end
1
5
  require 'ammeter/rspec/generator/example.rb'
2
6
  require 'ammeter/rspec/generator/matchers.rb'
3
7
  require 'rails'
@@ -2,7 +2,23 @@ require 'rspec/core'
2
2
  require 'ammeter/rspec/generator/example/generator_example_group'
3
3
 
4
4
  RSpec::configure do |c|
5
- c.include Ammeter::RSpec::Rails::GeneratorExampleGroup, :type => :generator, :example_group => {
6
- :file_path => /spec[\\\/]generators/
7
- }
5
+ def c.escaped_path(*parts)
6
+ Regexp.compile(parts.join('[\\\/]') + '[\\\/]')
7
+ end
8
+
9
+ generator_path_regex = c.escaped_path(%w[spec generators])
10
+ if RSpec::Core::Version::STRING >= '3'
11
+ c.include Ammeter::RSpec::Rails::GeneratorExampleGroup,
12
+ :type => :generator,
13
+ :file_path => lambda { |file_path, metadata|
14
+ metadata[:type].nil? && generator_path_regex =~ file_path
15
+ }
16
+
17
+ else #rspec2
18
+
19
+ c.include Ammeter::RSpec::Rails::GeneratorExampleGroup, :type => :generator, :example_group => {
20
+ :file_path => generator_path_regex
21
+ }
22
+ end
23
+
8
24
  end
@@ -29,10 +29,10 @@ module Ammeter
29
29
  def ensure_current_path
30
30
  self.test_unit_test_case_delegate.send :ensure_current_path
31
31
  end
32
-
32
+
33
33
  def initialize_delegate
34
34
  self.test_unit_test_case_delegate = ::Rails::Generators::TestCase.new 'pending'
35
- self.test_unit_test_case_delegate.class.tests(describes)
35
+ self.test_unit_test_case_delegate.class.tests(described_class)
36
36
  @generator = nil
37
37
  end
38
38
 
@@ -51,17 +51,17 @@ module Ammeter
51
51
  def invoke_task name
52
52
  capture(:stdout) { generator.invoke_task(generator_class.all_tasks[name.to_s]) }
53
53
  end
54
-
54
+
55
55
  included do
56
56
  delegate :generator, :run_generator, :destination, :arguments, :ensure_current_path, :to => :'self.class'
57
57
  DELEGATED_METHODS.each do |method|
58
58
  delegate method, :to => :'self.class'
59
59
  end
60
-
60
+
61
61
  def prepare_destination
62
62
  self.class.send :prepare_destination
63
63
  end
64
-
64
+
65
65
  ::Rails::Generators::TestCase.destination File.expand_path('ammeter', Dir.tmpdir)
66
66
  initialize_delegate
67
67
 
@@ -1,7 +1,8 @@
1
1
  RSpec::Matchers.define :be_a_migration do
2
2
  match do |file_path|
3
3
  dirname, file_name = File.dirname(file_path), File.basename(file_path)
4
- if file_name.match(/\d+_.*\.rb/)
4
+
5
+ if file_name =~ /\d+_.*\.rb/
5
6
  migration_file_path = file_path
6
7
  else
7
8
  migration_file_path = Dir.glob("#{dirname}/[0-9]*_*.rb").grep(/\d+_#{file_name}$/).first
@@ -1,15 +1,15 @@
1
1
  RSpec::Matchers.define :contain do |*expected_contents|
2
- match_for_should do |file_path|
2
+ match do |file_path|
3
3
  @actual_contents = File.read(file_path)
4
4
  not_found_expectations.empty?
5
5
  end
6
6
 
7
- match_for_should_not do |file_path|
7
+ match_when_negated do |file_path|
8
8
  @actual_contents = File.read(file_path)
9
9
  found_expectations.empty?
10
10
  end
11
11
 
12
- failure_message_for_should do |file_path|
12
+ failure_message do |file_path|
13
13
  "expected the file #{file_path} to contain " +
14
14
  if expected_contents.many?
15
15
  "#{expected_contents.map(&:inspect).to_sentence} but " +
@@ -19,7 +19,7 @@ RSpec::Matchers.define :contain do |*expected_contents|
19
19
  end
20
20
  end
21
21
 
22
- failure_message_for_should_not do |file_path|
22
+ failure_message_when_negated do |file_path|
23
23
  "expected the file #{file_path} to not contain " +
24
24
  if expected_contents.many?
25
25
  "#{expected_contents.map(&:inspect).to_sentence} but " +
@@ -1,5 +1,5 @@
1
1
  RSpec::Matchers.define :exist do
2
2
  match do |file_path|
3
- File.exists?(file_path)
3
+ File.exist?(file_path)
4
4
  end
5
5
  end
@@ -0,0 +1,19 @@
1
+ require 'rspec/expectations'
2
+ if RSpec::Expectations::Version::STRING < '3'
3
+
4
+ { :match_when_negated => :match_for_should_not,
5
+ :failure_message => :failure_message_for_should,
6
+ :failure_message_when_negated => :failure_message_for_should_not
7
+ }.each do |rspec3_method, rspec2_method|
8
+ RSpec::Matchers::DSL::Matcher.send :alias_method, rspec3_method, rspec2_method
9
+ end
10
+
11
+ module RSpec2CoreMemoizedHelpers
12
+ def is_expected
13
+ expect(subject)
14
+ end
15
+ end
16
+ RSpec::Core::MemoizedHelpers.extend RSpec2CoreMemoizedHelpers
17
+
18
+
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Ammeter
2
- VERSION = "0.2.9"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -2,8 +2,8 @@ require "spec_helper"
2
2
 
3
3
  module Ammeter::RSpec::Rails
4
4
  describe GeneratorExampleGroup do
5
- it { should be_included_in_files_in('./spec/generators/') }
6
- it { should be_included_in_files_in('.\\spec\\generators\\') }
5
+ it { is_expected.to be_included_in_files_in('./spec/generators/') }
6
+ it { is_expected.to be_included_in_files_in('.\\spec\\generators\\') }
7
7
 
8
8
  let(:group_class) do
9
9
  ::RSpec::Core::ExampleGroup.describe do
@@ -12,28 +12,27 @@ module Ammeter::RSpec::Rails
12
12
  end
13
13
 
14
14
  it "adds :type => :generator to the metadata" do
15
- group_class.metadata[:type].should eq(:generator)
15
+ expect(group_class.metadata[:type]).to eq(:generator)
16
16
  end
17
17
 
18
18
  describe 'an instance of the group' do
19
19
  let(:group) { group_class.new }
20
- subject { group }
21
- let(:generator) { double('generator') }
22
- before { group.stub(:generator => generator) }
23
20
  describe 'uses the generator as the implicit subject' do
24
- its(:subject) { should == generator }
21
+ let(:generator) { double('generator') }
22
+ it 'sets a generator as subject' do
23
+ allow(group).to receive(:generator).and_return(generator)
24
+ expect(group.subject).to eq generator
25
+ end
25
26
  end
26
27
 
27
- describe "allows you to override with explicity subject" do
28
- before { group_class.subject { 'explicit' } }
29
- its(:subject) { should == 'explicit' }
28
+ it "allows you to override with explicity subject" do
29
+ group_class.subject { 'explicit' }
30
+ expect(group.subject).to eq 'explicit'
30
31
  end
31
32
 
32
- describe 'able to delegate to ::Rails::Generators::TestCase' do
33
- describe 'with a destination root' do
34
- before { group.destination '/some/path' }
35
- its(:destination_root) { should == '/some/path' }
36
- end
33
+ it 'allows delegation of destination root to ::Rails::Generators::TestCase' do
34
+ group.destination '/some/path'
35
+ expect(group.destination_root).to eq '/some/path'
37
36
  end
38
37
 
39
38
  describe 'working with files' do
@@ -44,7 +43,7 @@ module Ammeter::RSpec::Rails
44
43
  FileUtils.mkdir path_to_gem_root_tmp
45
44
  end
46
45
  it 'should use destination to find relative root file' do
47
- group.file('app/model/post.rb').should == "#{path_to_gem_root_tmp}/app/model/post.rb"
46
+ expect(group.file('app/model/post.rb')).to eq "#{path_to_gem_root_tmp}/app/model/post.rb"
48
47
  end
49
48
 
50
49
  describe 'migrations' do
@@ -55,10 +54,10 @@ module Ammeter::RSpec::Rails
55
54
  FileUtils.touch(tmp_db_migrate + '/20111010203337_create_posts.rb')
56
55
  end
57
56
  it 'should use destination to find relative root file' do
58
- group.migration_file('db/migrate/create_posts.rb').should == "#{path_to_gem_root_tmp}/db/migrate/20111010203337_create_posts.rb"
57
+ expect(group.migration_file('db/migrate/create_posts.rb')).to eq "#{path_to_gem_root_tmp}/db/migrate/20111010203337_create_posts.rb"
59
58
  end
60
59
  it 'should stick "TIMESTAMP" in when migration does not exist' do
61
- group.migration_file('db/migrate/migration_that_is_not_there.rb').should == "#{path_to_gem_root_tmp}/db/migrate/TIMESTAMP_migration_that_is_not_there.rb"
60
+ expect(group.migration_file('db/migrate/migration_that_is_not_there.rb')).to eq "#{path_to_gem_root_tmp}/db/migrate/TIMESTAMP_migration_that_is_not_there.rb"
62
61
  end
63
62
  end
64
63
  end
@@ -5,19 +5,19 @@ describe "be_a_migration" do
5
5
  let(:migration_files) { ['db/migrate/20110504132601_create_posts.rb', 'db/migrate/20110520132601_create_users.rb'] }
6
6
 
7
7
  before do
8
- File.stub(:exist?).and_return(false)
8
+ allow(File).to receive(:exist?).and_return(false)
9
9
  migration_files.each do |migration_file|
10
- File.stub(:exist?).with(migration_file).and_return(true)
10
+ allow(File).to receive(:exist?).with(migration_file).and_return(true)
11
11
  end
12
- Dir.stub!(:glob).with('db/migrate/[0-9]*_*.rb').and_return(migration_files)
12
+ allow(Dir).to receive(:glob).with('db/migrate/[0-9]*_*.rb').and_return(migration_files)
13
13
  end
14
14
  it 'should find for the migration file adding the filename timestamp for us' do
15
- 'db/migrate/create_users.rb'.should be_a_migration
15
+ expect('db/migrate/create_users.rb').to be_a_migration
16
16
  end
17
17
  it 'should find for the migration file when we know the filename timestamp' do
18
- 'db/migrate/20110504132601_create_posts.rb'.should be_a_migration
18
+ expect('db/migrate/20110504132601_create_posts.rb').to be_a_migration
19
19
  end
20
20
  it 'should know when a migration does not exist' do
21
- 'db/migrate/create_comments.rb'.should_not be_a_migration
21
+ expect('db/migrate/create_comments.rb').to_not be_a_migration
22
22
  end
23
23
  end
@@ -7,23 +7,23 @@ describe "contain" do
7
7
 
8
8
  subject { '/some/file/path' }
9
9
  before do
10
- File.stub(:read).with('/some/file/path').and_return(contents)
10
+ allow(File).to receive(:read).with('/some/file/path').and_return(contents)
11
11
  end
12
- it { should contain "This file\ncontains\nthis text" }
13
- it { should contain "This file" }
14
- it { should contain "this text" }
15
- it { should contain /This file/ }
16
- it { should contain /this text/ }
17
- it { should contain "contains", /this text/ }
18
- it { should_not contain /something not there/ }
19
- it { should_not contain /this isn't at the contents/, /neither is this/ }
12
+ it { is_expected.to contain "This file\ncontains\nthis text" }
13
+ it { is_expected.to contain "This file" }
14
+ it { is_expected.to contain "this text" }
15
+ it { is_expected.to contain /This file/ }
16
+ it { is_expected.to contain /this text/ }
17
+ it { is_expected.to contain "contains", /this text/ }
18
+ it { is_expected.to_not contain /something not there/ }
19
+ it { is_expected.to_not contain /this isn't at the contents/, /neither is this/ }
20
20
  end
21
21
 
22
22
  context "when the file is not there" do
23
23
  it 'raises an error when the file does not exist' do
24
24
  expect do
25
- 'some/file/that/does/not/exist'.should contain 'something'
26
- end.to raise_error 'No such file or directory - some/file/that/does/not/exist'
25
+ expect('some/file/that/does/not/exist').to contain 'something'
26
+ end.to raise_error /No such file or directory/
27
27
  end
28
28
  end
29
29
  end
@@ -2,12 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  describe "exist" do
4
4
  it 'passes when the file exists' do
5
- File.stub(:exists?).with('/some/file/path').and_return(true)
6
- '/some/file/path'.should exist
5
+ allow(File).to receive(:exist?).with('/some/file/path').and_return(true)
6
+ expect('/some/file/path').to exist
7
7
  end
8
8
  it 'fails when the file does not exist' do
9
- File.stub(:exists?).with('/some/file/path').and_return(false)
10
- '/some/file/path'.should_not exist
9
+ allow(File).to receive(:exist?).with('/some/file/path').and_return(false)
10
+ expect('/some/file/path').to_not exist
11
11
  end
12
12
 
13
13
  end
@@ -11,22 +11,9 @@ require 'ammeter/init'
11
11
 
12
12
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
13
13
 
14
- # TODO - most of this is borrowed from rspec-rails's spec_helper - which
15
- # is copied from rspec-core's
16
- module MatchesForRSpecRailsSpecs
17
- extend RSpec::Matchers::DSL
18
-
19
- matcher :be_included_in_files_in do |path|
20
- match do |mod|
21
- stub_metadata(
22
- :example_group => {:file_path => "#{path}whatever_spec.rb:15"}
23
- )
24
- group = RSpec::Core::ExampleGroup.describe
25
- group.included_modules.include?(mod)
26
- end
27
- end
28
- end
29
-
30
14
  RSpec.configure do |c|
31
15
  c.include MatchesForRSpecRailsSpecs
16
+ if RSpec::Core::Version::STRING < '3'
17
+ c.include RSpec2MemoizedHelpersCompatibility
18
+ end
32
19
  end
@@ -1,19 +1,11 @@
1
1
  module Helpers
2
2
  def stub_metadata(additional_metadata)
3
3
  stub_metadata = metadata_with(additional_metadata)
4
- RSpec::Core::ExampleGroup.stub(:metadata) { stub_metadata }
4
+ allow(RSpec::Core::ExampleGroup).to receive(:metadata) { stub_metadata }
5
5
  end
6
6
 
7
7
  def metadata_with(additional_metadata)
8
- m = RSpec::Core::Metadata.new
9
- m.process("example group")
10
-
11
- group_metadata = additional_metadata.delete(:example_group)
12
- if group_metadata
13
- m[:example_group].merge!(group_metadata)
14
- end
15
- m.merge!(additional_metadata)
16
- m
8
+ ::RSpec.describe("example group").metadata.merge(additional_metadata)
17
9
  end
18
10
 
19
11
  RSpec.configure {|c| c.include self}
@@ -0,0 +1,20 @@
1
+ # Copied from rspec-rails spec/support/matchers.rb
2
+ module MatchesForRSpecRailsSpecs
3
+ extend RSpec::Matchers::DSL
4
+
5
+ matcher :be_included_in_files_in do |path|
6
+ match do |mod|
7
+ if RSpec::Core::Version::STRING >= '3'
8
+ stub_metadata(
9
+ :file_path => "#{path}whatever_spec.rb:15"
10
+ )
11
+ else
12
+ stub_metadata(
13
+ :example_group => {:file_path => "#{path}whatever_spec.rb:15"}
14
+ )
15
+ end
16
+ group = RSpec::Core::ExampleGroup.describe
17
+ group.included_modules.include?(mod)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,7 @@
1
+ # rspec3 defines this method in RSpec::Core::MemoizedHelpers
2
+ # see https://github.com/rspec/rspec-core/blob/master/lib/rspec/core/memoized_helpers.rb
3
+ module RSpec2MemoizedHelpersCompatibility
4
+ def is_expected
5
+ expect(subject)
6
+ end
7
+ end
metadata CHANGED
@@ -1,222 +1,195 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ammeter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Alex Rothenberg
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-06 00:00:00.000000000 Z
11
+ date: 2014-04-07 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: railties
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '3.0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '3.0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: activesupport
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '3.0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '3.0'
46
41
  - !ruby/object:Gem::Dependency
47
- name: rspec
42
+ name: rspec-rails
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '2.2'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '2.2'
62
55
  - !ruby/object:Gem::Dependency
63
- name: rspec-rails
56
+ name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '2.2'
70
- type: :runtime
62
+ type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '2.2'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rails
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: '3.1'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: '3.1'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: uglifier
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - ">="
100
88
  - !ruby/object:Gem::Version
101
89
  version: 1.2.4
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - ">="
108
95
  - !ruby/object:Gem::Version
109
96
  version: 1.2.4
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: rake
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - ">="
116
102
  - !ruby/object:Gem::Version
117
103
  version: 0.9.2.2
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - ">="
124
109
  - !ruby/object:Gem::Version
125
110
  version: 0.9.2.2
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: coffee-rails
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - ">="
132
116
  - !ruby/object:Gem::Version
133
117
  version: 3.2.2
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - ">="
140
123
  - !ruby/object:Gem::Version
141
124
  version: 3.2.2
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: sass-rails
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
- - - ! '>='
129
+ - - ">="
148
130
  - !ruby/object:Gem::Version
149
131
  version: 3.2.5
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
- - - ! '>='
136
+ - - ">="
156
137
  - !ruby/object:Gem::Version
157
138
  version: 3.2.5
158
139
  - !ruby/object:Gem::Dependency
159
140
  name: jquery-rails
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
- - - ! '>='
143
+ - - ">="
164
144
  - !ruby/object:Gem::Version
165
145
  version: 2.0.2
166
146
  type: :development
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
- - - ! '>='
150
+ - - ">="
172
151
  - !ruby/object:Gem::Version
173
152
  version: 2.0.2
174
153
  - !ruby/object:Gem::Dependency
175
154
  name: cucumber
176
155
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
156
  requirements:
179
- - - ! '>='
157
+ - - ">="
180
158
  - !ruby/object:Gem::Version
181
159
  version: '0.10'
182
160
  type: :development
183
161
  prerelease: false
184
162
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
163
  requirements:
187
- - - ! '>='
164
+ - - ">="
188
165
  - !ruby/object:Gem::Version
189
166
  version: '0.10'
190
167
  - !ruby/object:Gem::Dependency
191
168
  name: aruba
192
169
  requirement: !ruby/object:Gem::Requirement
193
- none: false
194
170
  requirements:
195
- - - ! '>='
171
+ - - ">="
196
172
  - !ruby/object:Gem::Version
197
173
  version: '0.3'
198
174
  type: :development
199
175
  prerelease: false
200
176
  version_requirements: !ruby/object:Gem::Requirement
201
- none: false
202
177
  requirements:
203
- - - ! '>='
178
+ - - ">="
204
179
  - !ruby/object:Gem::Version
205
180
  version: '0.3'
206
181
  - !ruby/object:Gem::Dependency
207
182
  name: sqlite3
208
183
  requirement: !ruby/object:Gem::Requirement
209
- none: false
210
184
  requirements:
211
- - - ! '>='
185
+ - - ">="
212
186
  - !ruby/object:Gem::Version
213
187
  version: '1'
214
188
  type: :development
215
189
  prerelease: false
216
190
  version_requirements: !ruby/object:Gem::Requirement
217
- none: false
218
191
  requirements:
219
- - - ! '>='
192
+ - - ">="
220
193
  - !ruby/object:Gem::Version
221
194
  version: '1'
222
195
  description: Write specs for your Rails 3+ generators
@@ -226,8 +199,8 @@ executables: []
226
199
  extensions: []
227
200
  extra_rdoc_files: []
228
201
  files:
229
- - .gitignore
230
- - .travis.yml
202
+ - ".gitignore"
203
+ - ".travis.yml"
231
204
  - Gemfile
232
205
  - History.md
233
206
  - LICENSE.txt
@@ -258,6 +231,7 @@ files:
258
231
  - lib/ammeter/rspec/generator/matchers/be_a_migration.rb
259
232
  - lib/ammeter/rspec/generator/matchers/contain.rb
260
233
  - lib/ammeter/rspec/generator/matchers/exist.rb
234
+ - lib/ammeter/rspec/rspec_2_compatibility.rb
261
235
  - lib/ammeter/version.rb
262
236
  - spec/ammeter/rspec/generator/example/generator_example_group_spec.rb
263
237
  - spec/ammeter/rspec/generator/matchers/be_a_migration_spec.rb
@@ -265,35 +239,30 @@ files:
265
239
  - spec/ammeter/rspec/generator/matchers/exist_spec.rb
266
240
  - spec/spec_helper.rb
267
241
  - spec/support/helpers.rb
242
+ - spec/support/matchers.rb
243
+ - spec/support/memoized_helpers_rspec2compatibility.rb
268
244
  homepage: ''
269
245
  licenses: []
246
+ metadata: {}
270
247
  post_install_message:
271
248
  rdoc_options: []
272
249
  require_paths:
273
250
  - lib
274
251
  required_ruby_version: !ruby/object:Gem::Requirement
275
- none: false
276
252
  requirements:
277
- - - ! '>='
253
+ - - ">="
278
254
  - !ruby/object:Gem::Version
279
255
  version: '0'
280
- segments:
281
- - 0
282
- hash: 1076241884620753575
283
256
  required_rubygems_version: !ruby/object:Gem::Requirement
284
- none: false
285
257
  requirements:
286
- - - ! '>='
258
+ - - ">="
287
259
  - !ruby/object:Gem::Version
288
260
  version: '0'
289
- segments:
290
- - 0
291
- hash: 1076241884620753575
292
261
  requirements: []
293
262
  rubyforge_project:
294
- rubygems_version: 1.8.24
263
+ rubygems_version: 2.2.2
295
264
  signing_key:
296
- specification_version: 3
265
+ specification_version: 4
297
266
  summary: Write specs for your Rails 3+ generators
298
267
  test_files:
299
268
  - features/generator_in_a_gem.feature
@@ -317,3 +286,5 @@ test_files:
317
286
  - spec/ammeter/rspec/generator/matchers/exist_spec.rb
318
287
  - spec/spec_helper.rb
319
288
  - spec/support/helpers.rb
289
+ - spec/support/matchers.rb
290
+ - spec/support/memoized_helpers_rspec2compatibility.rb