Traceback (most recent call last):
File "migration/manage.py", line 2, in <module>
from migrate.versioning.shell import main
ModuleNotFoundError: No module named 'migrate'
查阅文件 migration/manage.py 文件,
12345
#!/usr/bin/env python
from migrate.versioning.shell import main
if __name__ == '__main__':
main(debug='False')
fromsqlalchemyimport*frommigrateimport*defupgrade(migrate_engine):# Upgrade operations go here. Don't create your own engine; bind# migrate_engine to your metadatapassdefdowngrade(migrate_engine):# Operations to reverse the above upgrade go here.pass
constcardTarget={hover(props,monitor,component){constdragIndex=monitor.getItem().index;consthoverIndex=props.index;// Don't replace items with themselvesif(dragIndex===hoverIndex){return;}// Determine rectangle on screenconsthoverBoundingRect=findDOMNode(component).getBoundingClientRect();// Get vertical middleconsthoverMiddleY=(hoverBoundingRect.bottom-hoverBoundingRect.top)/2;// Determine mouse positionconstclientOffset=monitor.getClientOffset();// Get pixels to the topconsthoverClientY=clientOffset.y-hoverBoundingRect.top;// Only perform the move when the mouse has crossed half of the items height// When dragging downwards, only move when the cursor is below 50%// When dragging upwards, only move when the cursor is above 50%// Dragging downwardsif(dragIndex<hoverIndex&&hoverClientY<hoverMiddleY){return;}// Dragging upwardsif(dragIndex>hoverIndex&&hoverClientY>hoverMiddleY){return;}// Time to actually perform the actionprops.changeCard(dragIndex,null,hoverIndex);// Note: we're mutating the monitor item here!// Generally it's better to avoid mutations,// but it's good here for the sake of performance// to avoid expensive index searches.monitor.getItem().index=hoverIndex;}}
U should add gem rspec-rails in ur project’s Gemfile, then bundle.
Then, u need run command rails g rspec:install.
When u use rails commands, likes rails g model User xx:xx. It will help u to create spec/models/user_spec.rb file.
Yes, Rspec will check _spec.rb file as test file.
Give me some codes:
12345678910111213141516
require'rails_helper'RSpec.describeUser,:type=>:modeldocontext"signup with"doit"email and password, then success."doexpect(User.signup("123@exmaple.com","123456").errors.size).toeq(0)endit"illege email and password, then fail."doexpect(User.signup("123sdf","123456").errors.size).toeq(1)endit"email and no password, then fail. "doexpect(User.signup("123@example.com","").errors.size).toeq(1)endendend
and then, u can use rspec to test all _spec files,
or u can only test user_spec.rb file with rspec spec/models/user_spec.rb command.
if no error, u can get
1
3examples,0failures
It is not a good view. We just not work for testing, but say something to others.
varcontext=canvas.getContext("2d");varimage=context.getImageData(0,0,canvas.width,canvas.height);varpixels=image.data;// a Uint8ClampedArray object ect// ... Your code here!// ... Hack n the raw bits in `pixels`// ... and then write them back to th canvas;context.putImageData(image,0,0);
// Create a new struct type. Every Point has two fields// named x and y.varPoint=newTypedObject.StructType({x:TypedObject.int32,y:TypedObject.int32});// Now create an instance of that type.varp=newPoint({x:800,y:600});console.log(p.x);// 800