Sha256: 6d2ebdfc07264e33ff63d02609b04797149371249accf2a89371a0a3010c3f01

Contents?: true

Size: 1.36 KB

Versions: 17

Compression:

Stored size: 1.36 KB

Contents

require 'spec_helper'

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

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

  before { prepare_destination }

  it 'should run both the model and fixture tasks' do
    gen = generator %w(posts)
    gen.should_receive :create_model_spec
    gen.should_receive :create_fixture_file
    capture(:stdout) { gen.invoke_all }
  end

  describe 'the generated files' do
    describe 'with fixtures' do
      before do
        run_generator %w(posts --fixture)
      end

      describe 'the spec' do
        subject { file('spec/models/posts_spec.rb') }

        it { should exist }
        it { should contain(/require 'spec_helper'/) }
        it { should contain(/describe Posts/) }
      end

      describe 'the fixtures' do
        subject { file('spec/fixtures/posts.yml') }

        it { should contain(Regexp.new('# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html')) }
      end
    end

    describe 'without fixtures' do
      before do
        run_generator %w(posts)
      end

      describe 'the fixtures' do
        subject { file('spec/fixtures/posts.yml') }

        it { should_not exist }
      end
    end
  end
end

Version data entries

17 entries across 12 versions & 3 rubygems

Version Path
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/spec/generators/rspec/model/model_generator_spec.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/spec/generators/rspec/model/model_generator_spec.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/spec/generators/rspec/model/model_generator_spec.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/spec/generators/rspec/model/model_generator_spec.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/spec/generators/rspec/model/model_generator_spec.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/spec/generators/rspec/model/model_generator_spec.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/spec/generators/rspec/model/model_generator_spec.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/spec/generators/rspec/model/model_generator_spec.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/spec/generators/rspec/model/model_generator_spec.rb
rails-uploader-0.0.4 vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/spec/generators/rspec/model/model_generator_spec.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/spec/generators/rspec/model/model_generator_spec.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/spec/generators/rspec/model/model_generator_spec.rb
rails-uploader-0.0.1 vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/spec/generators/rspec/model/model_generator_spec.rb
rspec-rails-2.10.1 spec/generators/rspec/model/model_generator_spec.rb
rspec-rails-2.10.0 spec/generators/rspec/model/model_generator_spec.rb
rspec-rails-2.9.0 spec/generators/rspec/model/model_generator_spec.rb
rspec-rails-2.9.0.rc2 spec/generators/rspec/model/model_generator_spec.rb