File: observer_generator_test.rb

package info (click to toggle)
ruby-rails-observers 0.1.1-1~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 272 kB
  • sloc: ruby: 1,522; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 1,046 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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