Git Product home page Git Product logo

ammeter's Introduction

Ammeter Ammeter CI Code Climate Gem Version

A gem that makes it easy to write specs for your Rails 3 Generators.

RSpec is using ammeter to spec its own generators and we think you may find it useful too.

An ammeter is used to measure electrical current and electricity can be produced by a generator.

Installation

Add this line to your Gemfile (or gemspec):

gem 'ammeter'

And then execute:

$ bundle

Add:

require 'ammeter/init'

To your spec/spec_helper.rb.

Example

require 'spec_helper'

# Generators are not automatically loaded by Rails
require 'generators/rspec/model/model_generator'

describe Rspec::Generators::ModelGenerator, :type => :generator do
  # Tell the generator where to put its output (what it thinks of as Rails.root)
  destination File.expand_path("../../../../../tmp", __FILE__)
  before do
    prepare_destination
  end

  # using mocks to ensure proper methods are called
  # invoke_all - will call all the tasks in the generator
  it 'should run all tasks in the generator' do
    gen = generator %w(posts)
    gen.should_receive :create_model_spec
    gen.should_receive :create_fixture_file
    capture(:stdout) { gen.invoke_all }
  end

  # invoke_task - will call just the named task in the generator
  it 'should run a specific tasks in the generator' do
    gen = generator %w(posts)
    gen.should_receive     :create_model_spec
    gen.should_not_receive :create_fixture_file
    capture(:stdout) { gen.invoke_task :create_model_spec }
  end

  # custom matchers make it easy to verify what the generator creates
  describe 'the generated files' do
    before do
      run_generator %w(posts)
    end
    describe 'the spec' do
      # file - gives you the absolute path where the generator will create the file
      subject { file('spec/models/posts_spec.rb') }

      # is_expected_to contain - verifies the file's contents
      it { is_expected_to contain /require 'spec_helper'/ }
      it { is_expected_to contain /describe Posts/ }
    end
    describe 'the migration' do
      subject { migration_file('db/migrate/create_posts.rb') }

      # is_expected_to be_a_migration - verifies the file exists with a migration timestamp as part of the filename
      it { is_expected_to be_a_migration }
      it { is_expected_to contain /create_table/ }
    end
  end
end

Available matchers

  • contain - verifies the file's contents
  • be_a_migration - verifies the file exists with a migration timestamp as part of the filename
  • have_method - verifies the file (or a class withing it) implements a method
  • have_correct_syntax - verifies the file has correct syntax and is not broken (works for .rb, .erb and .haml files)

Contributing

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet
  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright © 2011 Alex Rothenberg. See LICENSE.txt for further details.

ammeter's People

Contributors

adamstegman avatar alexrothenberg avatar alindeman avatar aonashi avatar bigtunacan avatar cupakromer avatar d4rky-pl avatar dchelimsky avatar eppo avatar halida avatar junaruga avatar leshill avatar maxcal avatar mjonuschat avatar pabloh avatar pirj avatar skoba avatar tmobaird avatar twalpole avatar voxik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ammeter's Issues

Installing ammeter affects helpers that are available in Rails views

After adding ammeter to my gem file and running bundle install, I get an error like this:

4) FlashHelper#render_flash doesn't include blank messages
     Failure/Error: = fa_icon 'close'

     ActionView::Template::Error:
       undefined method `fa_icon' for #<#<Class:0x007ffabbdbbd08>:0x007ffac2cd9d48>

on some of my feature specs. I only see this for the method fa_icon which comes from the gem font-awesome-rails, so let me know if you think I should submit an issue to them instead.

I only included ammeter in my test group. When I run my app in development mode, I don't get the errors that I see when I run my specs.

activerecord still loaded when testing mongoid baked generator

Hi,

I'm in a situation where I would like to test my generator which supports active_record and mongoid using hook_for :orm to determine which kind of generator to load.
When I run the generator by hand and a bare new app, it just works. Using the generator specs, it fails miserably. I suspect the cause is that ActiveRecord is already loaded when the mongoid specs runs:

     Failure/Error: run_generator
     NoMethodError:
       undefined method `collection_name' for #<Class:0x007ff99c74c988>
     # /Users/eppo/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.13/lib/active_record/dynamic_matchers.rb:55:in `method_missing'
     # ./lib/generators/mongoid/rolify_generator.rb:47:in `model_contents'
     # ./lib/generators/mongoid/rolify_generator.rb:16:in `inject_role_class'

collection_name is provided by the Mongoid::Document module include but it goes through ActiveRecord anyway and doesn't find the corresponding method.
How to avoid loading ActiveRecord in the specific specs ? or maybe I should write my specs differently... do you have any tips regarding that ?

destination_root_is_set? is protected in rails master

From http://travis-ci.org/#!/rspec/rspec-rails/builds/83813

NoMethodError:
  protected method `destination_root_is_set?' called for #<Rails::Generators::TestCase:0xbac66c8>
    # /home/vagrant/.rvm/gems/ruby-1.9.2-p290/bundler/gems/rspec-expectations-d49eba7ed785/lib/rspec/matchers/method_missing.rb:9:in `method_missing'
    # /home/vagrant/.rvm/gems/ruby-1.9.2-p290/gems/ammeter-0.1.0/lib/ammeter/rspec/generator/example/generator_example_group.rb:18:in `destination_root_is_set?'

Passing options to a generator

I have a generator that inherits from NamedBase and defines a --sql class_option.

I invoke it with run_generator["foo", "--sql bar"] but inside the generator options[:bar] is nil. I looked at the implementation of run_generator and generator and saw that it's using Thor to parse the options. I verified that Thor::Options.splt works as expected on the array I'm passing to run_generator... and yet, still the option in nil in the generatornd it seems that indeed args and opts are getting set correctly. And yet, the option is still nil in my tests.

Compounding the problem (and limiting my normal debug tools) is that it seems pry does not work inside the generator. It works in my non-generator spec and even works when I run the generator from the command line, outside of my tests. But in my generator specs, pry opens but no statements return anything. I can call methods, non-existent methods, pry method -- none of them do anything.

The generator runs as expected when I try it from the command line so the problem is indeed limited to the specs.

Rails 5 support

We're trying to get Rails 5 working with Draper: drapergem/draper#752

Currently we've disabled the tests that use Ammeter because of this error:
to_app: missing run or map statement (RuntimeError)

It specifically happens on the third line here:

require 'spec_helper'
require 'rails'
require 'ammeter/init'

Here's the full stack trace:

gems/rack-2.0.1/lib/rack/builder.rb:146:in `to_app': missing run or map statement (RuntimeError)
gems/rack-2.0.1/lib/rack/builder.rb:160:in `block in generate_map'
gems/rack-2.0.1/lib/rack/builder.rb:160:in `each'
gems/rack-2.0.1/lib/rack/builder.rb:160:in `generate_map'
gems/rack-2.0.1/lib/rack/builder.rb:145:in `to_app'
gems/capybara-2.7.1/lib/capybara/rails.rb:13:in `<top (required)>'
gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `require'
gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `block in require'
gems/activesupport-5.0.0/lib/active_support/dependencies.rb:259:in `load_dependency'
gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `require'
gems/rspec-rails-3.5.0/lib/rspec/rails/vendor/capybara.rb:7:in `<top (required)>'
gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `require'
gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `block in require'
gems/activesupport-5.0.0/lib/active_support/dependencies.rb:259:in `load_dependency'
gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `require'
gems/rspec-rails-3.5.0/lib/rspec/rails.rb:14:in `<top (required)>'
gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `require'
gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `block in require'
gems/activesupport-5.0.0/lib/active_support/dependencies.rb:259:in `load_dependency'
gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `require'
gems/ammeter-1.1.3/lib/ammeter/init.rb:2:in `<top (required)>'
gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `require'
gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `block in require'
gems/activesupport-5.0.0/lib/active_support/dependencies.rb:259:in `load_dependency'
gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `require'
  from spec/generators/controller/controller_generator_spec.rb:3:in `<top (required)>'

Here's another project that has had to deal with this issue: jfirebaugh/konacha#216

It appears to specifically be an issue with sprockets-rails.

Must require all of 'rspec-rails', not just components of it

I installed ammeter to create tests for a generator I'm writing. An error was thrown by the line include RSpec::Rails::FixtureSupport in rspec/rails/example/rails_example_group.rb
It happens because I'm not using Fixtures, so RSpec::Rails::FixtureSupport is undefined. Thinking it was a problem by rspec-rails, I submitted an issue with rspec/rspec-rails: rspec/rspec-rails#1407, and they pointed out that the reason this state occurs is because ammeter is requiring only selected rspec-rails components, which shouldn't be done. (A stack trace is included in that issue.) They can't guarantee a coherent system state if that's done; they can only guarantee a coherent system state if require rspec-rails is used so that all of rspec-rails is required.

I'd suggest that the line require 'rspec/rails/adapters' and require 'rspec/rails/example/rails_example_group' in lib/ammeter/rspec/generator/example/generator_example_group.rb be replaced with the single line require 'rspec-rails'. The require line could go into init.rb instead, to ensure that any future code that might use rspec-rails will not cause an error. I can do a PR easily enough if you'd like.

Railtie initializer preventing devise from loading

While developing a new gem that is an extension for devise, I added this gem for testing my generator. The tests themselves work great, but when I went back to run my test rails app for the integration tests, the rails app wouldn't load due to the following error from devise:

lib/devise/rails/routes.rb:443:in `raise_no_devise_method_error!': Admin does not respond to 'devise' method. This usually means you haven't loaded your ORM file or it's being loaded too late. To fix it, be sure to require 'devise/orm/YOUR_ORM' inside 'config/initializers/devise.rb' or before your application definition in 'config/application.rb' (RuntimeError)

After some searching and the realization that this has worked fine before, I removed the ammeter gem from my gemspec and everything works fine again (other than the tests of course). I played around some more after adding the gem back to my gemspec and I have found that the problem seems to have something to do with the order that the initializers are being run. If I remove the :after=> :disable_dependency_loading from the ammeter initializer, everything seems to load fine in the rails app and tests also work fine.

Not sure if this is an acceptable fix for the problem or if you have any other ideas?

Uninitialized constant RSpec::Rails::FixtureSupport

After installing the ammeter gem I get this error when trying to run any specs.

/Users/bigtunacan/.rvm/gems/ruby-1.9.3-p547@rails3/gems/rspec-rails-3.3.2/lib/rspec/rails/example/rails_example_group.rb:14:in `<module:RailsExampleGroup>': uninitialized constant RSpec::Rails::FixtureSupport (NameError)

Undefined method `destination`

I have the following configuration for my generator specs:

RSpec.configure do |config|
  config.before(:example, :generator) do
    destination File.expand_path("../../../tmp", __FILE__)
    prepare_destination
  end
end

This yields the error in the subject of this issue. If I remove the call to destination then the call to prepare_destination fails similarly. It's as if ammeter isn't required, or perhaps the underlying test-unit stuff is not required? At a loss...

how to test inject_into_file behavior

Hi, I'm struggling when testing an inject_into_file, My problem is that I can't generate my template file inside my dummy/tmp directory before running my generator that modifies that file. The file that I want to change is generated by another generator. Does ammeter has a clean way to test this?

Possible to test generator reversal?

Rails generators can be reversed with the destroy subcommand to rails: rails destroy GENERATOR_NAME. Is it possible using ammeter to test this?

False-negative in `check_erb_syntax` on Ruby 2.7+

This test passes on Ruby 2.6 and fails on Ruby 2.7 and 3.0:

# frozen_string_literal: true

require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"
  gem "rspec", "3.10"
  gem "ammeter", "1.1.5"
end

require "ammeter/rspec/generator/matchers/have_correct_syntax"
require "rspec/autorun"

class Sandbox
  include RSpec::Matchers
end

RSpec.describe Sandbox do
  let(:matcher) { subject.have_correct_syntax }
  let(:code) do
    <<-ERB
<!DOCTYPE html>
<html>
  <head>
    <title>Page Title</title>
    <%= csrf_meta_tags %>
    <%= csp_meta_tag %>

    <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
    <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
  </head>

  <body>
    <%= yield %>
  <%= render 'shared/talkable_offer', offer: @offer %>
</body>
</html>
    ERB
  end

  it "succeeds" do
    expect(matcher.check_erb_syntax(code)).to eq(true)
  end
end

If you have rbenv installed, you can save the contents to check_erb_syntax.rb and then run like:

RBENV_VERSION=2.6.9 ruby check_erb_syntax.rb
RBENV_VERSION=2.7.5 ruby check_erb_syntax.rb
RBENV_VERSION=3.0.3 ruby check_erb_syntax.rb

When using contain on a migration it does not work

After I test to see if a file is a migration, I am not able to use contain. For example:

subject { file('db/migrate/some_migration.rb') }
it { is_expected.to be_a_migration } #this is fine
it { is_expected.to contain(/t.integer :id, null: false/) } #this gives error. Cannot find file.

How to test injected class ?

Hi,

I'am trying to create some specs for a generator that inject some code into a class using inject_into_class thor method.
Problem is that I need to provide a king of template in my spec in order to test it but as the destination folder is wiped out at every rspec run, I didn't find a clean way to add a class template at rspec runtime so that the generator doesn't fail telling it didn't find the model file.
Any idea appreciated.

tmp directory cleanup after running generator

When I run my specs on this gem, the tmp directory used to test the generator remains after spec finishes, and contains app, config and db folders, along with the files generated by the generator. I don't know if it comes from my specs code or if it's a bug.

Rails 4.2 beta has deprecated `capture` causing ammeter to fail

Rails 4.2 beta was just released. They have deprecated (and made private) the capture and quietly methods (see rails/rails@3121412). Naturally, this is causing failures.

Here's the related stack trace from a rspec-rails failure:

Failure/Error: capture(:stdout) { gen.invoke_all }
     NoMethodError:
       protected method `capture' called for #<Rails::Generators::TestCase:0x00000005efb668>
     # /home/travis/build/rspec/bundle/ruby/2.1.0/gems/ammeter-1.0.0/lib/ammeter/rspec/generator/example/generator_example_group.rb:21:in `capture'
     # /home/travis/build/rspec/bundle/ruby/2.1.0/gems/ammeter-1.0.0/lib/ammeter/rspec/generator/example/generator_example_group.rb:58:in `capture'
     # ./spec/generators/rspec/model/model_generator_spec.rb:16:in `block (2 levels) in <top (required)>'

migration_file and be_a_migration

Hi,

when I use migration_file in a subject block in my specs, I cannot use be_a_migration in a it block underneath.

    Failure/Error: it { should be_a_migration }
     TypeError:
       can't convert nil into String

If i use file instead, it works.

Cheers,
Florent

File.exist? not working

I have generator that edit application_controller. I check whether the file exist or not:

module Sth
  module Generators
    class ConfigGenerator < ::Rails::Generators::Base
      desc 'Configs application controller'
      def edit_application_Controller
        if File.exist?("app/controllers/application_controller.rb")
          insert_into_file "app/controllers/application_controller.rb", TXT, :after => "protect_from_forgery"
        else
          raise 'Couldn\'t find application_controller file'
        end
      end
    end
  end
end

My test doesn't work with the if statement that checks the file existence. but it works well without it. here is my test:

require 'spec_helper'
require 'generators/sth/config_generator'

def copy_files
  application_controller = File.expand_path("../templates/config/application_controller.rb", __FILE__)
  destination = File.join(destination_root, "app/controllers")

  FileUtils.mkdir_p(destination)
  FileUtils.cp application_controller, destination
end

describe UnderConstruction::Generators::ConfigGenerator do
  destination File.expand_path("../tmp", __FILE__)

  before do
    prepare_destination
    copy_files
  end

  it "configs the application controller" do
    run_generator
    f = file('app/controllers/application_controller.rb')
    f.should contain(/#{TXT}/)
  end
end

missing run or map statement when requiring 'ammeter/init'

I am trying to use ammeter inside a rails engine (rails 5.0.4) and rspec-rails (3.6.0).

I reduced my implementation as much as possible for this example:

# spec/generators/alchemy/elements_generator_spec.rb
require 'rails/all'
require 'rails/generators'
require 'rails/generators/alchemy/elements/elements_generator'
require 'ammeter/init'

module Alchemy
  RSpec.describe Generators::ElementsGenerator, type: :generator do
    destination File.expand_path("../../../tmp", __FILE__)

    before do
      before { prepare_destination }
      run_generator %w(elements)
    end

    describe "the view partial" do
      subject { file('views/alchemy/elements/all_you_can_eat_view.html.erb') }
      it { is_expected.to exist }
      ...
    end
  end
end

Stacktrace

$ bundle exec rspec spec/generators
An error occurred while loading ./spec/generators/alchemy/elements_generator_spec.rb.
Failure/Error: require 'ammeter/init'

RuntimeError:
  missing run or map statement
# ./spec/generators/alchemy/elements_generator_spec.rb:5:in `require'
# ./spec/generators/alchemy/elements_generator_spec.rb:5:in `<top (required)>'

Any ideas? What information could I provide more?

Thanks!

migration_file in subject

It would be nice to have a migration_file method in a subject to test the content of the migration file, something like

describe ActiveRecord::Generators::MigrationGenerator do
  destination File.expand_path("../../tmp", __FILE__)

  before do
    prepare_destination
    run_generator %w(create_posts)
  end
  subject { migration_file('db/migrate/create_posts.rb') }
  it { should exist }
  it { should contain 'class CreatePosts < ActiveRecord::Migration' }
end

cheers.

Generators calling 'generate' method fail.

I have a generator that calls the generate method to take advantage of built-in migration functionality but my specs fail when checking for the existence of the created migrations.

The generator is in a gem.

The console contains this output: /home/rails/.rbenv/versions/1.9.2-p290/bin/ruby: No such file or directory -- script/rails (LoadError)

I've tried all the examples I could find from the blog http://www.alexrothenberg.com/2011/10/10/ammeter-the-way-to-write-specs-for-your-rails-generators.html, to the readme to the rspec repository and nothing I try seems to work; I don't think the generate calls are working correctly (as evidenced by the LoadError above).

Cheers,
Devon

Sample Generator:

module Winner
module Generators
class MigrationsGenerator < Rails::Generators::Base
argument :models, :type => :array, :banner => "model1 model2 model3...", :required => true

  #Create the migrations
  def create_migrations
    generate("migration", "AwesomeSauce")

    models.each do |model|
      create_migration(model)
    end
  end

  protected

  def create_migration(model_name)
    generate("migration", "AddFieldsTo#{model_name} newfield1:string newfield2:datetime")
  end

end

end
end

Sample Test:

require 'spec_helper'

require 'rails/generators/winner/migrations_generator'

describe Winner::Generators::MigrationsGenerator do
destination File.expand_path("../../../../tmp", FILE) #it's in lib/generators/winner/ NOT lib/generators/winner/models/

before { prepare_destination }

it 'should create a single migration with one argument' do
run_generator %w(Model1)

migration_file('db/migrate/add_fields_to_model1.rb').should exist

end

end

Rails 6 support?

Not sure if this gem is still maintained, but FYI:

This line - https://github.com/alexrothenberg/ammeter/blob/master/lib/ammeter/rspec/generator/matchers/have_correct_syntax.rb#L33

Has an issue with Rails 6 because that method now expects two params - https://github.com/rails/rails/blob/master/actionview/lib/action_view/template/handlers.rb#L48

I believe the fix here is to provide an empty struct as first param and the source code as second, but am not familiar enough to be confident.

RSpec 3 compatibility

Updated ammeter to work with latest rspec3 from git towards fixing rspec/rspec-rails#961. Ammeter tests pass with latest rspec3 but have not yet tested that rspec-rails tests pass with this ammeter.

What is the best practice for depending on an unreleased gem? Right now

  • Gemfile depends on git:// version of rspec gems
  • ammeter.gemspec requires s.add_runtime_dependency 'rspec-rails', '>=3.0.0.beta2'

If I publish this as-is it will break once rspec 3.0 is released and if I change the dependency to ">= 3.0" it wont work as there is no published 3.0. Do I publish as is a beta version of ammeter and republish when rspec publishes their 3.0?

Is there a better approach that other gems follow?

cc @cupakromer @myronmarston

rspec 2.99 support

Rspec 2.99 was released exactly on June 1, 2014. Current version is 3.4, so the question is: is it viable to still support 2.99 at this point?

I'm asking because Travis is currently set to test 2.99, 3.0 and master. I think it'd be a good idea to update versions there.

Testing generators that depend on ActiveRecord Model

I've got a generator that calls hook_for to invoke ActiveRecord's model generator. I know the generator works because I can execute it and it creates the model and migration successfully, but when I'm testing, it seems like the model_generator isn't being called. I'm not sure if I need to tell my testcase to include rails generators or rails or what exactly. Have you run into this?

I tried setting the orm to :active_record like you recommend in your blog, but I'm still getting failures about --orm not being defined.

My Generator:

require 'rails/generators'
require 'rails/generators/resource_helpers'

module Tandem
  module Generators
    class ResourceGenerator < ::Rails::Generators::NamedBase
      include ::Rails::Generators::ResourceHelpers

      desc "Create a tandem resource"

      argument :attributes, :type => :array, :default => [], :banner => "field[:type][:index] field[:type][:index]"

      hook_for :orm, :in => :rails, :as => :model, :required => true

      source_root File.expand_path('../templates', __FILE__)

      def create_tandem_resource_controller
        template 'controller.rb', File.join('app/controllers/tandem', "#{controller_file_name}_controller.rb")
      end

      def create_views
        [:index, :show, :new, :edit, :_form].each do |view|
          template "#{view}.html.slim", File.join('app/views/tandem', "#{file_name.pluralize}", "#{view}.html.slim")
        end
      end

      def add_resource_route
        route "resources :#{file_name.pluralize}, :module => 'tandem'"
      end
    end
  end
end

And a small version of my spec file that demonstrates the problem:

require 'spec_helper'
require 'generators/tandem/resource/resource_generator'

describe Tandem::Generators::ResourceGenerator do
  destination File.expand_path("#{ENGINE_RAILS_ROOT}/spec/dummy/tmp", __FILE__)

  before do
    prepare_destination

    ::Rails::Generators.options[:rails][:orm] = :active_record

    FileUtils.mkdir_p("#{destination_root}/config")
    FileUtils.cp "#{ENGINE_RAILS_ROOT}/config/routes.rb", "#{destination_root}/config/routes.rb"
  end

  describe 'tandem resource controller' do
    before do
      run_generator %w(Spoke) 
    end

    subject { file('app/controllers/tandem/spokes_controller.rb') }

    it { should contain(/module Tandem/) }
    it { should contain(/class SpokesController < ::Tandem::ResourceController/) }
  end
end

Is this supposed to work or should I just be stubbing out the hook_for call?

Update README.md

Examples in README are based on rspec 2.x instead of 3.x, we should default to the latest version even if we're maintaining backwards compatibility.

Also, there should be at least a rudimentary documentation other than simply an example, listing and explaining all matchers.

ammeter breaks RSpec's built-in `exist` matcher

Example app demonstrating the problem here.

RSpec has a matcher built in that just calls the exist? or exists? method on the subject and passes if it returns true (or truthy I guess). requiring ammeter/init clobbers that matcher and breaks any tests that rely on the default RSpec behaviour.

routes specs

I tried to test the route method of generator and it doesn't work.

route "get 'my_controller#my_action'"

Maybe I missed the documentation entry but I couldn't find.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.