This is not something from Rails, this is the steps definition of Cucumber. Cucumber is a BDD acceptance testing framework. The part you see is a piece of code for testing assertions. Cucumber uses a DSL that is close to natural language, so the syntax is very user-friendly. However, programmers themselves do not pursue the style of Cucumber, which is mostly used for commercial test scripts. Programmers themselves prefer procedural syntax, and proper semantics are enough. In the Ruby world, MiniTest and RSpec are more popular test frameworks.
Addition, after thinking about it carefully, this may not be Cucumber. I thought it was because of Then 这个方法,但是 Cucumber 似乎是在 Scenario 里才用 Then at first, right? (memory blurred)
If it’s RSpec or something like that, is there Then? Maybe extended DSL? It's possible, so jumping to the conclusion that it's Cucumber might be wrong.
But anyway, this is definitely test code and does not belong to Rails itself.
In terms of usage, feature is used to make functional feature test cases, not only limited to Cucumber, RSpec can also use this, such as here https://github.com/agilejzl/blog-eye/tree/master/ spec/features, @nightire can have Then class process testing with gem 'rspec-example_steps'.
It’s the code of cucumber. Then is used in the .feature file to describe the process, or in the _steps.rb file to parse the process. The one mentioned above is obviously the latter one. It is located under the path ../features/step_definitions/.
This is not something from Rails, this is the steps definition of Cucumber. Cucumber is a BDD acceptance testing framework. The part you see is a piece of code for testing assertions. Cucumber uses a DSL that is close to natural language, so the syntax is very user-friendly. However, programmers themselves do not pursue the style of Cucumber, which is mostly used for commercial test scripts. Programmers themselves prefer procedural syntax, and proper semantics are enough. In the Ruby world, MiniTest and RSpec are more popular test frameworks.
Addition, after thinking about it carefully, this may not be Cucumber. I thought it was because of
Then
这个方法,但是 Cucumber 似乎是在 Scenario 里才用Then
at first, right? (memory blurred)If it’s RSpec or something like that, is there
Then
? Maybe extended DSL? It's possible, so jumping to the conclusion that it's Cucumber might be wrong.But anyway, this is definitely test code and does not belong to Rails itself.
In terms of usage, feature is used to make functional feature test cases, not only limited to Cucumber, RSpec can also use this, such as here https://github.com/agilejzl/blog-eye/tree/master/ spec/features, @nightire can have Then class process testing with gem 'rspec-example_steps'.
It’s the code of cucumber. Then is used in the .feature file to describe the process, or in the _steps.rb file to parse the process. The one mentioned above is obviously the latter one. It is located under the path ../features/step_definitions/.