lib/crosstie/templates/resources.rb in crosstie-0.0.6 vs lib/crosstie/templates/resources.rb in crosstie-0.0.7

- old
+ new

@@ -1,22 +1,34 @@ # scaffold resources -resources_path = '/tmp/crosstie/resources.yml' -if File.exist? resources_path - YAML.load(File.read(resources_path)).each do |resource, fields| + +if config['resources'] + + config['resources'].each do |resource, fields| + generate "scaffold", resource, *fields + rake "db:migrate" - inject_into_file "spec/controllers/#{resource.tableize}_controller_spec.rb", after: "RSpec.describe #{resource.pluralize.camelize}Controller, type: :controller do\n" do + + inject_into_file "spec/controllers/#{resource.tableize}_controller_spec.rb", after: "RSpec.describe #{resource.tableize.camelize}Controller, type: :controller do\n" do <<-EOF - before { sign_in_user } + before do + sign_in_user + @#{resource} = FactoryGirl.build(:#{resource}) + end EOF end gsub_file "spec/controllers/#{resource.tableize}_controller_spec.rb", 'skip("Add a hash of attributes valid for your model")', - "FactoryGirl.build(:#{resource}).attributes" - end + "@#{resource}.attributes" - File.delete resources_path + inject_into_file "app/views/layouts/_navigation_links.html.slim", after: "- if user_signed_in?\n" do +<<-EOF + li = link_to '#{resource.tableize.titleize}', #{resource.tableize}_path +EOF + end + + end run "bundle exec annotate" end