Sha256: 9e8bb028cdb2d8752640ecf2fcf82c7219f174e3d09c129c9a340249f17b2df0
Contents?: true
Size: 1.82 KB
Versions: 4
Compression:
Stored size: 1.82 KB
Contents
module Padrino module Generators module Components module Tests module RiotGen RIOT_SETUP = (<<-TEST).gsub(/^ {10}/, '') class Riot::Situation include Rack::Test::Methods def app CLASS_NAME.tap { |app| app.set :environment, :test } end end TEST def setup_test require_dependencies 'riot', :env => :testing insert_test_suite_setup RIOT_SETUP end RIOT_CONTROLLER_TEST = (<<-TEST).gsub(/^ {10}/, '') require File.dirname(__FILE__) + '/../test_config.rb' context "!NAME!Controller" do context "description here" do setup { get '/' } asserts("the response body") { last_response.body }.equals "Hello World" end end TEST # Generates a controller test given the controllers name def generate_controller_test(name, root) riot_contents = RIOT_CONTROLLER_TEST.gsub(/!NAME!/, name.to_s.camelize) create_file File.join(root, "test/controllers/#{name}_controller_test.rb"), riot_contents end RIOT_MODEL_TEST = (<<-TEST).gsub(/^ {10}/, '') require File.dirname(__FILE__) + '/../test_config.rb' context "!NAME! Model" do context 'can be created' do setup { @!DNAME! = !NAME!.new } asserts("that record is not nil") { !@!DNAME!.nil? } end end TEST def generate_model_test(name) riot_contents = RIOT_MODEL_TEST.gsub(/!NAME!/, name.to_s.camelize).gsub(/!DNAME!/, name.downcase.underscore) create_file app_root_path("test/models/#{name.to_s.downcase}.rb"), riot_contents end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems