class Object
Public Instance Methods
create_missing_model(singular_name)
click to toggle source
# File lib/neverfails.rb, line 30 def create_missing_model(singular_name) # Generate the model and the migration Rails::Generators.invoke("model", [singular_name, "--orm=active_record", "--migration"]) # Run the migration ActiveRecord::Migrator.migrate "db/migrate/" end
create_missing_page_listing(objects)
click to toggle source
# File lib/neverfails.rb, line 37 def create_missing_page_listing(objects) # Generate the controller Rails::Generators.invoke("controller", [objects.classify.pluralize, "index"]) # Add an extra route match "/models" => "model#index" @@missing_view_file = "app/views/#{objects}/index.html.erb" routes_file = 'config/routes.rb' old_routes = File.read(routes_file) File.open(routes_file, "w") do |file| file.puts old_routes.gsub(/get "#{objects}\/index"/, "get \"#{objects}/index\"\nmatch \"/#{objects}\" => \"#{objects}#index\"") end # Reload routes ::Rails.application.reload_routes! end
create_missing_text(text)
click to toggle source
# File lib/neverfails.rb, line 52 def create_missing_text(text) File.open(@@missing_view_file, "w") do |file| file.puts "#{text}\n" end Capybara.current_session.visit $last_url end