Sha256: f66ccf7c1c1bd8e965a25f4092b23851c03a87814bb37326ee8f58cf22c97519
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
<% if File.exist?(File.join %w[spec rails_helper.rb]) -%> require 'rails_helper' <% else -%> require 'spec_helper' <% end -%> <% module_namespacing do -%> describe <%= class_name %>, type: :model do <% if options[:fixture_replacement] == :factory_girl -%> subject { create :<%= singular_name %> } <% else -%> before :each do @valid_attrs = { } end subject { <%= class_name %>.create @valid_attrs } <% end -%> it { should be_valid } describe :class do it 'should respond to :ordered' do <% if options[:fixture_replacement] == :factory_girl -%> <%= singular_name %>1 = create :<%= singular_name %> <%= singular_name %>2 = create :<%= singular_name %> <% else -%> <%= singular_name %>1 = <%= class_name %>.create @valid_attrs <%= singular_name %>2 = <%= class_name %>.create @valid_attrs <% end -%> <% attribute = attributes.detect{|a| a.name == 'position'} || attributes.detect{|a| a.name == 'name'} || attributes.detect{|a| a.name == 'title'} || attributes.first -%> expect(<%= class_name %>.ordered).to eq <%= class_name %>.order(:<%=attribute.name %>) end end end <% end -%>
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_record_model_and_rspec_enhanced_templates-1.0.2 | lib/templates/rspec/model/model_spec.rb |