ammeter 1.0.0 → 1.1.0

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: 2de6d4a25f2da4f07ab81378f182f7f258bbb4b3
4
- data.tar.gz: cc570161b0b4857749090fe8085dcd910227a14d
3
+ metadata.gz: 0f14d89dc8ba87e492a772bd8e81a8370641b8bd
4
+ data.tar.gz: bea93658480644d813daafa47b58510c7d9c856b
5
5
  SHA512:
6
- metadata.gz: f5c31970c5ab5a6ef56fd920c76d408a99534254348b8b91d3a9b248555490148241b38383227ec8119d9d4bcb1bd850464b9b8bc21f59876b30e7a8166f5868
7
- data.tar.gz: 3cff3a5991a9293fdde73c16beb7848632045ffec136e4dc4715a54fa24633d276b16e75f336bfd1a1220ed64f40721eddd1228426e8d8582942202bd24b6b8d
6
+ metadata.gz: 24107720705e3ff11ba9691b762c43fe2b0d09c2608e00c9438a4ae25699acbc3f27993169c40f739fd30a66fc3a7ff65281ed9673a43330eaeb534b6858dbfa
7
+ data.tar.gz: 7687869b3fddd91f0fba62b628b23f3059befdfba8bdfd1cb25f08bfa64864237ac121152aaef5ebef12999a36f1a05002a8430e966179e676890811673f3e7c
data/Gemfile CHANGED
@@ -1,9 +1,9 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- rspec_version = ENV['RSPEC_VERSION'] || '2.99.0.beta2'
3
+ rspec_version = ENV['RSPEC_VERSION']
4
+ rspec_major_version = (rspec_version && rspec_version != 'master') ? rspec_version.split('.')[0] : '3'
4
5
 
5
- case rspec_version
6
- when 'master'
6
+ if rspec_version == 'master'
7
7
  gem "rspec-rails", :git => 'git://github.com/rspec/rspec-rails.git'
8
8
  gem "rspec", :git => 'git://github.com/rspec/rspec.git'
9
9
  gem "rspec-core", :git => 'git://github.com/rspec/rspec-core.git'
@@ -16,6 +16,28 @@ else
16
16
  gem 'rspec', rspec_version
17
17
  end
18
18
 
19
+ case rspec_major_version
20
+ when '2'
21
+ # rspec 2.x does not support Rails 4.1+
22
+ gem 'rails', '~> 3.2'
23
+ gem 'uglifier', '~> 1.2.4'
24
+ gem 'rake', '~> 0.9.2.2'
25
+ gem 'coffee-rails', '~> 3.2'
26
+ gem 'sass-rails', '~> 3.2'
27
+ gem 'jquery-rails', '~> 2.0'
28
+ gem 'haml-rails', '~> 0.4'
29
+ when '3'
30
+ gem 'rails', '>= 4.0'
31
+ gem 'uglifier', '>= 1.3'
32
+ gem 'rake', '>= 0.10'
33
+ gem 'coffee-rails', '>= 4.0'
34
+ gem 'sass-rails', '>= 4.0'
35
+ gem 'jquery-rails', '>= 3.0'
36
+ gem 'haml-rails', '>= 0.5'
37
+ else
38
+ raise "rspec version #{rspec_version} is not supported"
39
+ end
40
+
19
41
  # Specify your gem's dependencies in rspec-rails-generator-specs.gemspec
20
42
  gemspec
21
43
 
data/README.md CHANGED
@@ -53,23 +53,31 @@ describe Rspec::Generators::ModelGenerator do
53
53
  describe 'the spec' do
54
54
  # file - gives you the absolute path where the generator will create the file
55
55
  subject { file('spec/models/posts_spec.rb') }
56
- # should exist - verifies the file exists
57
- it { should exist }
56
+ # is_expected_to exist - verifies the file exists
57
+ it { is_expected_to exist }
58
58
 
59
- # should contain - verifies the file's contents
60
- it { should contain /require 'spec_helper'/ }
61
- it { should contain /describe Posts/ }
59
+ # is_expected_to contain - verifies the file's contents
60
+ it { is_expected_to contain /require 'spec_helper'/ }
61
+ it { is_expected_to contain /describe Posts/ }
62
62
  end
63
63
  describe 'the migration' do
64
64
  subject { file('db/migrate/create_posts.rb') }
65
65
 
66
- # should be_a_migration - verifies the file exists with a migration timestamp as part of the filename
67
- it { should be_a_migration }
66
+ # is_expected_to be_a_migration - verifies the file exists with a migration timestamp as part of the filename
67
+ it { is_expected_to be_a_migration }
68
68
  end
69
69
  end
70
70
  end
71
71
  ```
72
72
 
73
+ # Available matchers
74
+
75
+ - `exist` - verifies the file exists
76
+ - `contain` - verifies the file's contents
77
+ - `be_a_migration` - verifies the file exists with a migration timestamp as part of the filename
78
+ - `have_method` - verifies the file (or a class withing it) implements a method
79
+ - `have_correct_syntax` - verifies the file has correct syntax and is not broken (works for .rb, .erb and .haml files)
80
+
73
81
  # Contributing
74
82
 
75
83
  * Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.add_development_dependency 'coffee-rails', '>= 3.2.2'
29
29
  s.add_development_dependency 'sass-rails', '>= 3.2.5'
30
30
  s.add_development_dependency 'jquery-rails', '>= 2.0.2'
31
+ s.add_development_dependency 'haml-rails', '>= 0.4'
31
32
  s.add_development_dependency 'cucumber', '>= 0.10'
32
33
  s.add_development_dependency 'aruba', '>= 0.3'
33
34
  case RUBY_PLATFORM
@@ -35,7 +35,7 @@ Feature: Gems can contain generators
35
35
  end
36
36
  end
37
37
  """
38
- When I run `rake spec --trace`
38
+ When I run `rake spec`
39
39
  Then the output should contain "3 examples, 0 failures"
40
40
 
41
41
  @rails_gem
@@ -32,7 +32,7 @@ Feature: generator spec
32
32
  Scenario: A spec that runs the entire generator
33
33
  Given a file named "spec/generators/awesome_generator_spec.rb" with:
34
34
  """
35
- require "spec_helper"
35
+ require "rails_helper"
36
36
  require 'generators/awesome/awesome_generator'
37
37
 
38
38
  describe AwesomeGenerator do
@@ -57,7 +57,7 @@ Feature: generator spec
57
57
  Scenario: A spec that runs one task in the generator
58
58
  Given a file named "spec/generators/another_awesome_generator_spec.rb" with:
59
59
  """
60
- require "spec_helper"
60
+ require "rails_helper"
61
61
  require 'generators/awesome/awesome_generator'
62
62
 
63
63
  describe AwesomeGenerator do
@@ -82,7 +82,7 @@ Feature: generator spec
82
82
  Scenario: A spec with some failures shows nice error messages
83
83
  Given a file named "spec/generators/awesome_generator_spec.rb" with:
84
84
  """
85
- require "spec_helper"
85
+ require "rails_helper"
86
86
  require 'generators/awesome/awesome_generator'
87
87
 
88
88
  describe AwesomeGenerator do
@@ -129,7 +129,7 @@ Feature: generator spec
129
129
  Scenario: Can specify arguments separately from running the generator
130
130
  Given a file named "spec/generators/awesome_generator_spec.rb" with:
131
131
  """
132
- require "spec_helper"
132
+ require "rails_helper"
133
133
  require 'generators/awesome/awesome_generator'
134
134
 
135
135
  describe AwesomeGenerator do
@@ -152,7 +152,7 @@ Feature: generator spec
152
152
  Scenario: A generator that creates a migration
153
153
  Given a file named "spec/generators/a_migration_spec.rb" with:
154
154
  """
155
- require "spec_helper"
155
+ require "rails_helper"
156
156
  require 'rails/generators/active_record/migration/migration_generator'
157
157
 
158
158
  describe ActiveRecord::Generators::MigrationGenerator do
@@ -169,7 +169,7 @@ Feature: generator spec
169
169
  Scenario: Can tell the generator where to put its files
170
170
  Given a file named "spec/generators/awesome_generator_spec.rb" with:
171
171
  """
172
- require "spec_helper"
172
+ require "rails_helper"
173
173
  require 'generators/awesome/awesome_generator'
174
174
 
175
175
  describe AwesomeGenerator do
@@ -27,7 +27,7 @@ Feature: generator spec
27
27
  Scenario: A spec that runs the entire generator
28
28
  Given a file named "spec/generators/resourceful_generator_spec.rb" with:
29
29
  """
30
- require "spec_helper"
30
+ require "rails_helper"
31
31
  require 'generators/resourceful/resourceful_generator'
32
32
 
33
33
  describe ResourcefulGenerator do
@@ -5,10 +5,3 @@ Aruba.configure do |config|
5
5
  set_env('JAVA_OPTS', "-d32 #{ENV['JAVA_OPTS']}") # force jRuby to use client JVM for faster startup times
6
6
  end
7
7
  end if RUBY_PLATFORM == 'java'
8
-
9
- # MRI 1.8.7 does not define RUBY_ENGINE
10
- if defined?(RUBY_ENGINE) && %w(jruby rbx).include?(RUBY_ENGINE)
11
- Before do
12
- @aruba_timeout_seconds = 30
13
- end
14
- end
@@ -1,7 +1,7 @@
1
1
  require 'aruba/cucumber'
2
2
 
3
3
  Before do
4
- @aruba_timeout_seconds = 10
4
+ @aruba_timeout_seconds = 30
5
5
  end
6
6
 
7
7
  def aruba_path(file_or_dir, source_foldername)
@@ -12,9 +12,10 @@ def example_app_path(file_or_dir)
12
12
  File.expand_path("../../../#{file_or_dir}", __FILE__)
13
13
  end
14
14
 
15
- def write_symlink(file_or_dir, source_foldername)
15
+ def write_symlink(file_or_dir, source_foldername, filename=nil)
16
16
  source = example_app_path(file_or_dir)
17
17
  target = aruba_path(file_or_dir, source_foldername)
18
+ target = File.join(File.dirname(target), filename) if filename
18
19
  system "ln -s #{source} #{target}"
19
20
  end
20
21
 
@@ -23,12 +24,23 @@ def copy_to_aruba_from(gem_or_app_name)
23
24
  Given a directory named "spec"
24
25
  }
25
26
 
27
+ rspec_version = ENV['RSPEC_VERSION']
28
+ rspec_major_version = (rspec_version && rspec_version != 'master') ? rspec_version.split('.')[0] : '3'
29
+
26
30
  Dir["tmp/#{gem_or_app_name}/*"].each do |file_or_dir|
27
31
  if !(file_or_dir =~ /\/spec$/)
28
32
  write_symlink(file_or_dir, gem_or_app_name)
29
33
  end
30
34
  end
35
+
31
36
  write_symlink("tmp/#{gem_or_app_name}/spec/spec_helper.rb", gem_or_app_name)
37
+
38
+ if rspec_major_version == '2'
39
+ # rspec 2.x does not create rails_helper.rb so we create a symlink to avoid cluttering tests
40
+ write_symlink("tmp/#{gem_or_app_name}/spec/spec_helper.rb", gem_or_app_name, 'rails_helper.rb')
41
+ elsif rspec_major_version == '3'
42
+ write_symlink("tmp/#{gem_or_app_name}/spec/rails_helper.rb", gem_or_app_name)
43
+ end
32
44
  end
33
45
 
34
46
  Before '@example_app' do
@@ -1,5 +1,31 @@
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.split('.')[0] : '3'
5
+
6
+ if rspec_version == '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
+
19
+ case rspec_major_version
20
+ when '2'
21
+ gem 'rails', '~> 3.2'
22
+ when '3'
23
+ gem 'rails', '>= 4.1'
24
+ else
25
+ raise "rspec version #{rspec_version} is not supported"
26
+ end
27
+
28
+
3
29
  # Specify your gem's dependencies in my_gem.gemspec
4
30
  gemspec
5
31
 
@@ -15,6 +15,5 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = MyRailsGem::VERSION
17
17
 
18
- gem.add_runtime_dependency 'rails', '>= 3.1'
19
- gem.add_development_dependency 'rspec-rails', '>=2.2'
18
+ gem.add_runtime_dependency 'rails', '>= 3.2'
20
19
  end
@@ -1,5 +1,7 @@
1
1
  require 'bundler/setup'
2
2
  require 'rails/all'
3
+ # This prevents 'uninitialized constant Jquery::Rails::Railtie::PROTOTYPE_JS (NameError)'
4
+ require 'jquery/rails'
3
5
 
4
6
  module MyRailsGem
5
7
  module TestApp
@@ -1,5 +1,31 @@
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.split('.')[0] : '3'
5
+
6
+ if rspec_version == '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
+
19
+ case rspec_major_version
20
+ when '2'
21
+ gem 'railties', '~> 3.2'
22
+ when '3'
23
+ gem 'railties', '>= 4.1'
24
+ else
25
+ raise "rspec version #{rspec_version} is not supported"
26
+ end
27
+
28
+
3
29
  # Specify your gem's dependencies in my_gem.gemspec
4
30
  gemspec
5
31
 
@@ -15,6 +15,5 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = MyRailtiesGem::VERSION
17
17
 
18
- gem.add_runtime_dependency 'railties', '>= 3.1'
19
- gem.add_development_dependency 'rspec-rails', '>= 2.2'
18
+ gem.add_runtime_dependency 'railties', '>= 3.2'
20
19
  end
@@ -2,9 +2,9 @@ require 'rspec/core'
2
2
  if RSpec::Core::Version::STRING < '3'
3
3
  require 'ammeter/rspec/rspec_2_compatibility' # if rspec2
4
4
  end
5
+ require 'rails'
5
6
  require 'ammeter/rspec/generator/example.rb'
6
7
  require 'ammeter/rspec/generator/matchers.rb'
7
- require 'rails'
8
8
 
9
9
  if Rails.respond_to?(:application) && Rails.application.respond_to?(:load_generators)
10
10
  Rails.application.load_generators
@@ -1,3 +1,5 @@
1
1
  require 'ammeter/rspec/generator/matchers/be_a_migration'
2
2
  require 'ammeter/rspec/generator/matchers/contain'
3
3
  require 'ammeter/rspec/generator/matchers/exist'
4
+ require 'ammeter/rspec/generator/matchers/have_method'
5
+ require 'ammeter/rspec/generator/matchers/have_correct_syntax'
@@ -7,6 +7,6 @@ RSpec::Matchers.define :be_a_migration do
7
7
  else
8
8
  migration_file_path = Dir.glob("#{dirname}/[0-9]*_*.rb").grep(/\d+_#{file_name}$/).first
9
9
  end
10
- File.exist?(migration_file_path)
10
+ migration_file_path && File.exist?(migration_file_path)
11
11
  end
12
12
  end
@@ -0,0 +1,54 @@
1
+ RSpec::Matchers.define :have_correct_syntax do
2
+ match do |file_path|
3
+ source = File.read(file_path)
4
+ extension = File.extname(file_path)
5
+ case extension
6
+ when '.rb', '.rake'
7
+ check_ruby_syntax(source)
8
+ when '.rhtml', '.erb'
9
+ check_erb_syntax(source)
10
+ when '.haml'
11
+ check_haml_syntax(source)
12
+ else
13
+ raise "Checking syntax for #{extension} files is not yet supported"
14
+ end
15
+
16
+ end
17
+
18
+ define_method :check_ruby_syntax do |code|
19
+ begin
20
+ eval('__crash_me__;' + code)
21
+ rescue SyntaxError
22
+ false
23
+ rescue NameError
24
+ true
25
+ end
26
+ end
27
+
28
+ define_method :check_erb_syntax do |code|
29
+ require 'action_view'
30
+ require 'ostruct'
31
+
32
+ begin
33
+ view = ActionView::Template::Handlers::ERB.call(OpenStruct.new(source: code))
34
+ eval('__crash_me__; ' + view)
35
+ rescue SyntaxError
36
+ false
37
+ rescue NameError
38
+ true
39
+ end
40
+ end
41
+
42
+ define_method :check_haml_syntax do |code|
43
+ require 'haml'
44
+
45
+ begin
46
+ Haml::Engine.new(code)
47
+ rescue Haml::SyntaxError
48
+ false
49
+ rescue NameError
50
+ true
51
+ end
52
+ end
53
+
54
+ end
@@ -0,0 +1,10 @@
1
+ RSpec::Matchers.define :have_method do |method|
2
+ chain :containing do |content|
3
+ @method_content = content.strip
4
+ end
5
+
6
+ match do |file_path|
7
+ content = File.read(file_path)
8
+ content =~ /(\s+)def #{method}(\(.+\))?(.*?)\n\1end/m && (@method_content.nil? ? true : $3.include?(@method_content))
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module Ammeter
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  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
- allow(File).to receive(:exist?).and_return(false)
9
8
  migration_files.each do |migration_file|
10
9
  allow(File).to receive(:exist?).with(migration_file).and_return(true)
11
10
  end
12
- allow(Dir).to receive(:glob).with('db/migrate/[0-9]*_*.rb').and_return(migration_files)
13
11
  end
14
12
  it 'should find for the migration file adding the filename timestamp for us' do
13
+ expect(Dir).to receive(:glob).with('db/migrate/[0-9]*_*.rb').and_return(migration_files)
15
14
  expect('db/migrate/create_users.rb').to be_a_migration
16
15
  end
17
16
  it 'should find for the migration file when we know the filename timestamp' do
18
17
  expect('db/migrate/20110504132601_create_posts.rb').to be_a_migration
19
18
  end
20
19
  it 'should know when a migration does not exist' do
20
+ expect(Dir).to receive(:glob).with('db/migrate/[0-9]*_*.rb').and_return([])
21
21
  expect('db/migrate/create_comments.rb').to_not be_a_migration
22
22
  end
23
23
  end
@@ -0,0 +1,106 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'have_correct_syntax' do
4
+
5
+ describe 'ruby files' do
6
+ subject { '/test.rb' }
7
+ it 'checks if Ruby file has a proper syntax' do
8
+ stub_file subject, "class SomeClass\n def some_method\n puts 'Hello world!'\n end\nend"
9
+ expect(subject).to have_correct_syntax
10
+ end
11
+
12
+ it 'checks if Ruby file has an incorrect syntax' do
13
+ stub_file subject, "class SomeClass\ndef some_method\nputs 'Hello world!'"
14
+ expect(subject).to_not have_correct_syntax
15
+ end
16
+ end
17
+
18
+ describe 'erb files' do
19
+ subject { '/test.erb' }
20
+ it 'checks if simple ERB file has a proper syntax' do
21
+ stub_file subject, '<% if nonexistent_var == 1 %><a href="#"></a><% end %>'
22
+ expect(subject).to have_correct_syntax
23
+ end
24
+
25
+ it 'checks if simple ERB file has an incorrect syntax' do
26
+ stub_file subject, '<% if 1 + 1 %> abc'
27
+ expect(subject).to_not have_correct_syntax
28
+ end
29
+
30
+ it 'checks if complex ERB file has a proper syntax' do
31
+ stub_file subject, <<-EOF
32
+ <header>
33
+ <h1><%= application_title %></h1>
34
+ </header>
35
+ <div id="body">
36
+ <table>
37
+ <% @elements.each do |element| %>
38
+ <tr>
39
+ <td><%= element.id %></td>
40
+ <td><%= element.title %></td>
41
+ <td><%= link_to 'Show', element_path(element) %></td>
42
+ </tr>
43
+ <% end %>
44
+ </table>
45
+ </div>
46
+ EOF
47
+ expect(subject).to have_correct_syntax
48
+ end
49
+
50
+ it 'checks if complex ERB file has an incorrect syntax' do
51
+ stub_file subject, <<-EOF
52
+ <div id="broken-example">
53
+ <p>This test should fail because I didn't close an each loop.</p>
54
+ <% @elements.each do |element| %>
55
+ <tr>
56
+ <td><%= element.id %></td>
57
+ </tr>
58
+ </div>
59
+ EOF
60
+ expect(subject).to_not have_correct_syntax
61
+ end
62
+ end
63
+
64
+ describe 'haml files' do
65
+ subject { '/test.haml' }
66
+ it 'checks if simple Haml file has a proper syntax' do
67
+ stub_file subject, <<-EOF
68
+ %a{:href => "#"}= @order.id
69
+ EOF
70
+ expect(subject).to have_correct_syntax
71
+ end
72
+
73
+ it 'checks if simple Haml file has an incorrect syntax' do
74
+ stub_file subject, <<-EOF
75
+ %a{
76
+ EOF
77
+ expect(subject).to_not have_correct_syntax
78
+ end
79
+
80
+ it 'checks if complex Haml file has a proper syntax' do
81
+ stub_file subject, <<-EOF
82
+ %header
83
+ %h1= application_title
84
+ #body
85
+ %table
86
+ - @elements.each do |element|
87
+ %tr
88
+ %td= element.id
89
+ %td= element.title
90
+ %td= link_to 'Show', element_path(element)
91
+ EOF
92
+ expect(subject).to have_correct_syntax
93
+ end
94
+
95
+ it 'checks if complex Haml file has an incorrect syntax' do
96
+ stub_file subject, <<-EOF
97
+ #broken-example
98
+ %p This test should fail because of broken indentation
99
+ - @elements.each do |element|
100
+ %tr
101
+ $td= element.id
102
+ EOF
103
+ expect(subject).to_not have_correct_syntax
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'have_method' do
4
+ let(:contents) { "class SomeClass\n def some_method\n puts 'Hello world!'\n end\nend" }
5
+
6
+ subject { '/some/file/path' }
7
+ before { allow(File).to receive(:read).with('/some/file/path').and_return(contents) }
8
+
9
+ it { is_expected.to have_method(:some_method) }
10
+ it { is_expected.to have_method(:some_method).containing("puts 'Hello world!'")}
11
+ it { is_expected.to_not have_method(:some_method).containing("puts 'Good bye cruel world!' ") }
12
+ it { is_expected.to_not have_method(:some_other_method) }
13
+ end
@@ -1,6 +1,8 @@
1
1
  require 'rails/all'
2
2
  require 'rspec/rails'
3
3
 
4
+ ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
5
+
4
6
  module TestApp
5
7
  class Application < Rails::Application
6
8
  config.root = File.dirname(__FILE__)
@@ -17,3 +19,7 @@ RSpec.configure do |c|
17
19
  c.include RSpec2MemoizedHelpersCompatibility
18
20
  end
19
21
  end
22
+
23
+ def stub_file(filename, content)
24
+ allow(File).to receive(:read).with(filename).and_return(content)
25
+ 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.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Rothenberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-07 00:00:00.000000000 Z
11
+ date: 2014-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: 2.0.2
153
+ - !ruby/object:Gem::Dependency
154
+ name: haml-rails
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0.4'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0.4'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: cucumber
155
169
  requirement: !ruby/object:Gem::Requirement
@@ -231,12 +245,16 @@ files:
231
245
  - lib/ammeter/rspec/generator/matchers/be_a_migration.rb
232
246
  - lib/ammeter/rspec/generator/matchers/contain.rb
233
247
  - lib/ammeter/rspec/generator/matchers/exist.rb
248
+ - lib/ammeter/rspec/generator/matchers/have_correct_syntax.rb
249
+ - lib/ammeter/rspec/generator/matchers/have_method.rb
234
250
  - lib/ammeter/rspec/rspec_2_compatibility.rb
235
251
  - lib/ammeter/version.rb
236
252
  - spec/ammeter/rspec/generator/example/generator_example_group_spec.rb
237
253
  - spec/ammeter/rspec/generator/matchers/be_a_migration_spec.rb
238
254
  - spec/ammeter/rspec/generator/matchers/contain_spec.rb
239
255
  - spec/ammeter/rspec/generator/matchers/exist_spec.rb
256
+ - spec/ammeter/rspec/generator/matchers/have_correct_syntax_spec.rb
257
+ - spec/ammeter/rspec/generator/matchers/have_method_spec.rb
240
258
  - spec/spec_helper.rb
241
259
  - spec/support/helpers.rb
242
260
  - spec/support/matchers.rb
@@ -284,6 +302,8 @@ test_files:
284
302
  - spec/ammeter/rspec/generator/matchers/be_a_migration_spec.rb
285
303
  - spec/ammeter/rspec/generator/matchers/contain_spec.rb
286
304
  - spec/ammeter/rspec/generator/matchers/exist_spec.rb
305
+ - spec/ammeter/rspec/generator/matchers/have_correct_syntax_spec.rb
306
+ - spec/ammeter/rspec/generator/matchers/have_method_spec.rb
287
307
  - spec/spec_helper.rb
288
308
  - spec/support/helpers.rb
289
309
  - spec/support/matchers.rb