您好!欢迎光临工博士商城
产品分类
新闻中心
上银导轨模型|上银驱动器使用手册_东莞上银直线导轨的实际应用
发布时间:2021-06-01        浏览次数:155        返回列表
下面东莞上银直线导轨厂家的小编就来为大家介绍一下相关内容:
 
以便保证这类精密度,线形导轨在应用过程中规定机器设备正确引导优良,稳定运作情况都是数控车床生产加工的先决条件。可是,在该类机器设备运作过程中,因为气体或浓烟中带有很多气体,将会会产生直线导轨的应用,这种难题的关键缘故是线形导轨的表层更为污迹。
 
上银导轨
以便合理保证直线导轨的优良运作,在一定水平上保证了生产加工钢件的品质。因而,务必实行直线导轨的平时维护保养。清理时,一定要应用毛巾,一定要应用柔软性好的湿布,清理结束后,立即擦抹润滑脂。
 
在实际操作过程中,直线导轨的关键方式是在清理以前将其激光切割头合理地挪动到左边,随后在一定水平上它的直线导轨会出現在人们眼前。在这样的事情下,它用到整洁的毛巾不断擦洗,将擦洗器正确引导到更亮的水准。这时,提前准备好的润滑剂能够匀称涂敷在直线导轨上。

上银导轨模型
上银导轨

Creating tests for your Rails app or API is a critical step in creating a production-level application. If you’re new to Rails, testing may seem esoteric and time-consuming.

为Rails应用程序或API创建测试是创建生产级应用程序的关键步骤。 如果您是Rails的新手,那么测试似乎很深奥且耗时。

As it turns out, it’s actually not difficult to get started and testing will save you a ton of time. Once your back-end is iron clad and easily testable your front-end work will be smooth as butter.

事实证明,开始实际上并不难,测试将为您节省大量时间。 一旦您的后端被铁覆盖并易于测试,您的前端工作将像黄油一样光滑。

For detailed info here are the docs: https://guides.rubyonrails.org/testing.html

有关详细信息,请参见以下文档: https : //guides.rubyonrails.org/testing.html

If you are using Rails Generator to generate your controllers and models. There should be a “test” folder in the root of the application. Inside, the generator will generate files for you corresponding with the controllers and models you are generating.

如果使用Rails Generator生成控制器和模型。 在应用程序的根目录中应该有一个“ test”文件夹。 在内部,生成器将为您生成与要生成的控制器和模型相对应的文件。

测试模型 (Testing for Models)

Let’s write some simple tests for the User model.

让我们为User模型编写一些简单的测试。

Hop into the user_test.rb file in the test/models folder. Now let’s write some code.

跳到test / models文件夹中的user_test.rb文件。 现在让我们编写一些代码。

So we will use the assert_raises method to check if this raises an error or not. If it does it will give us the green! If not it will be red red red! See, testing made simple. (there are many assertions we can use to test, an assertion is just a check)

因此,我们将使用assert_raises方法检查这是否引发错误。 如果这样做,将会给我们绿色! 如果不是,它将是红色红色红色! 看,测试变得简单。 (有很多断言可以用来测试,断言只是一个检查)

test "should not save user without username" do   assert_raises(NameError) do     user = User.new     user.save   endend

Now to run our tests:

现在运行我们的测试:

rails test test/models/user_test.rb
Image for post

As you can see our test gave us no failures and a little green dot. This is good! That means trying to save a User without any username or password is throwing an error. If you are throwing an error, make sure you have some validations in your darn User model!

如您所见,我们的测试没有给我们带来任何失败,并且给了我们一点绿色。 很好! 这意味着试图保存没有任何用户名或密码的用户会引发错误。 如果抛出错误,请确保您的织补用户模型中有一些验证!

测试控制器 (Testing for Controllers)

Let’s write some tests for our controllers.

让我们为控制器编写一些测试。

First, let’s test out our index function. In a normal application you may or may not want to allow a “get” all of your users. But for the purposes of this demo we’ll assume that we can.

首先,让我们测试一下索引功能。 在普通应用程序中,您可能会或可能不希望允许“获取”所有用户。 但是出于演示目的,我们假设可以。

First, you should see that there is a UsersControllerTest already set up in your test/models folder. (If you don’t you need to “rails g” a user controller).

首先,您应该看到在test / models文件夹中已经设置了一个UsersControllerTest。 (如果不这样做,则需要“限制”用户控制器)。

Now, we have access to a few functions that will allow us to create faux HTTP requests.

现在,我们可以访问一些函数,这些函数将允许我们创建伪HTTP请求。

  • get

    get

  • post

    post

  • patch

    patch

  • put

    put

  • head

    head

  • delete

    delete

So for this situation we want to create a “get” to “/users”. We can do that two ways; with a string or with the users_url helper. I will do it with the helper here. But keep in mind this can be replaced with “/users”.

因此,对于这种情况,我们想为“ / users”创建一个“ get”。 我们可以通过两种方式做到这一点; 使用字符串或users_url帮助器。 我将在这里与助手一起做。 但是请记住,可以将其替换为“ / users”。

test "should get index" do   get users_url # could be "/users"   assert_response :successend

Now, to run tests, just use one of the following 3 commands:

现在,要运行测试,只需使用以下三个命令之一:

## to run all tests:rails test## run all tests in the user_controller_test filerails test test/controllers/user_controller_test.rb## to run a specific testrails test test/controllers/user_controller_test.rb:7## 7 being the line that that function method begins

You will see:

你会看见:

Image for post

This means the test has passed. If you see a lot of red and an error or a failure… well that means there was an error thrown or the test failed.

这意味着测试已通过。 如果您看到很多红色,并且有错误或失败…那么这意味着抛出错误或测试失败。

Each green dot represents a test passed!

每个绿色的点代表一个测试通过!

更多信息 (More Info)

This is just the tip of the iceberg when it comes to testing. Hopefully these basic methods get you started when it comes to testing.

这只是测试方面的冰山一角。 希望这些基本方法可以帮助您入门进行测试。

For more information please visit the Ruby Docs. This section is particularly well written:

有关更多信息,请访问Ruby Docs。 本节的写法特别出色:

 

Thank you for reading, please follow me on Twitter or IG @thedrewprint and connect with me on LinkedIn — Andrew Richards


 

 了解更多工博士自主产品:工博士导轨




联系热线:15002112015 联系人:赵工 联系地址:上海市宝山区富联一路98弄6号

技术和报价服务:星期一至星期六8:00-22:00 自动化生产方案服务商