Sha256: dc3eb2d18b26e8adccff2516b6a6f95dc21643f3bd49f4fdb9165449d1adfc9c

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

require 'generators/generators_test_helper'
require 'generators/rails/observer/observer_generator'

class ObserverGeneratorTest < Rails::Generators::TestCase
  tests Rails::Generators::ObserverGenerator
  destination File.expand_path("../../tmp", __FILE__)
  arguments %w(account)

  def setup
    super
    prepare_destination
  end

  def test_invokes_default_orm
    run_generator
    assert_file "app/models/account_observer.rb", /class AccountObserver < ActiveRecord::Observer/
  end

  def test_invokes_default_orm_with_class_path
    run_generator ["admin/account"]
    assert_file "app/models/admin/account_observer.rb", /class Admin::AccountObserver < ActiveRecord::Observer/
  end

  def test_invokes_default_test_framework
    run_generator
    assert_file "test/unit/account_observer_test.rb", /class AccountObserverTest < ActiveSupport::TestCase/
  end

  def test_logs_if_the_test_framework_cannot_be_found
    content = run_generator ["account", "--test-framework=rspec"]
    assert_match(/rspec \[not found\]/, content)
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/rails-observers-0.1.2/test/generators/observer_generator_test.rb
rails-observers-0.1.2 test/generators/observer_generator_test.rb
rails-observers-0.1.1 test/generators/observer_generator_test.rb
rails-observers-0.1.0 test/generators/observer_generator_test.rb