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