Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
c4dc0cf3
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c4dc0cf3
编写于
8月 19, 2014
作者:
Y
Yves Senn
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #16552 from untidy-hair/update_plugin_guide
[ci skip] Update plugin doc with the latest rails
上级
abbf7bfa
629bb0e3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
21 addition
and
21 deletion
+21
-21
guides/source/plugins.md
guides/source/plugins.md
+21
-21
未找到文件。
guides/source/plugins.md
浏览文件 @
c4dc0cf3
...
...
@@ -57,7 +57,7 @@ You can navigate to the directory that contains the plugin, run the `bundle inst
You should see:
```
bash
2 tests, 2
assertions, 0 failures, 0 errors, 0 skips
1 runs, 1
assertions, 0 failures, 0 errors, 0 skips
```
This will tell you that everything got generated properly and you are ready to start adding functionality.
...
...
@@ -85,9 +85,9 @@ Run `rake` to run the test. This test should fail because we haven't implemented
```
bash
1
)
Error:
test_to_squawk_prepends_the_word_squawk
(
CoreExtTest
)
:
NoMethodError: undefined method
`
to_squawk
' for
[Hello World](String)
test/core_ext_test.rb:5:in `test_to_squawk_prepends_the_word_squawk'
CoreExtTest#test_to_squawk_prepends_the_word_squawk
:
NoMethodError: undefined method
`
to_squawk
' for
"Hello World":String
/path/to/yaffle/
test/core_ext_test.rb:5:in `test_to_squawk_prepends_the_word_squawk'
```
Great - now you are ready to start development.
...
...
@@ -118,7 +118,7 @@ end
To test that your method does what it says it does, run the unit tests with
`rake`
from your plugin directory.
```
bash
3 tests, 3
assertions, 0 failures, 0 errors, 0 skips
2 runs, 2
assertions, 0 failures, 0 errors, 0 skips
```
To see this in action, change to the test/dummy directory, fire up a console and start squawking:
...
...
@@ -196,16 +196,16 @@ When you run `rake`, you should see the following:
```
1) Error:
test_a_hickwalls_yaffle_text_field_should_be_last_squawk(ActsAsYaffleTest)
:
ActsAsYaffleTest#test_a_hickwalls_yaffle_text_field_should_be_last_squawk
:
NameError: uninitialized constant ActsAsYaffleTest::Hickwall
test/acts_as_yaffle_test.rb:6:in `test_a_hickwalls_yaffle_text_field_should_be_last_squawk'
/path/to/yaffle/
test/acts_as_yaffle_test.rb:6:in `test_a_hickwalls_yaffle_text_field_should_be_last_squawk'
2) Error:
test_a_wickwalls_yaffle_text_field_should_be_last_tweet(ActsAsYaffleTest)
:
ActsAsYaffleTest#test_a_wickwalls_yaffle_text_field_should_be_last_tweet
:
NameError: uninitialized constant ActsAsYaffleTest::Wickwall
test/acts_as_yaffle_test.rb:10:in `test_a_wickwalls_yaffle_text_field_should_be_last_tweet'
/path/to/yaffle/
test/acts_as_yaffle_test.rb:10:in `test_a_wickwalls_yaffle_text_field_should_be_last_tweet'
5 tests, 3
assertions, 0 failures, 2 errors, 0 skips
4 runs, 2
assertions, 0 failures, 2 errors, 0 skips
```
This tells us that we don't have the necessary models (Hickwall and Wickwall) that we are trying to test.
...
...
@@ -270,18 +270,18 @@ You can then return to the root directory (`cd ../..`) of your plugin and rerun
```
1) Error:
test_a_hickwalls_yaffle_text_field_should_be_last_squawk(ActsAsYaffleTest)
:
NoMethodError: undefined method `yaffle_text_field' for #<Class:0x00
0001016661b
8>
/Users/xxx/.rvm/gems/ruby-1.9.2-p136@xxx/gems/activerecord-3.0.3/lib/active_record/base.rb:1008
:in `method_missing'
test/acts_as_yaffle_test.rb:5
:in `test_a_hickwalls_yaffle_text_field_should_be_last_squawk'
ActsAsYaffleTest#test_a_hickwalls_yaffle_text_field_should_be_last_squawk
:
NoMethodError: undefined method `yaffle_text_field' for #<Class:0x00
7fd105e3b21
8>
activerecord (4.1.5) lib/active_record/dynamic_matchers.rb:26
:in `method_missing'
/path/to/yaffle/test/acts_as_yaffle_test.rb:6
:in `test_a_hickwalls_yaffle_text_field_should_be_last_squawk'
2) Error:
test_a_wickwalls_yaffle_text_field_should_be_last_tweet(ActsAsYaffleTest)
:
NoMethodError: undefined method `yaffle_text_field' for #<Class:0x00
000101653748
>
Users/xxx/.rvm/gems/ruby-1.9.2-p136@xxx/gems/activerecord-3.0.3/lib/active_record/base.rb:1008
:in `method_missing'
test/acts_as_yaffle_test.rb:9:in `test_a_wickwalls_yaffle_text_field_should_be_last_tweet'
ActsAsYaffleTest#test_a_wickwalls_yaffle_text_field_should_be_last_tweet
:
NoMethodError: undefined method `yaffle_text_field' for #<Class:0x00
7fd105e409c0
>
activerecord (4.1.5) lib/active_record/dynamic_matchers.rb:26
:in `method_missing'
/path/to/yaffle/test/acts_as_yaffle_test.rb:10:in `test_a_wickwalls_yaffle_text_field_should_be_last_tweet'
5 tests, 3
assertions, 0 failures, 2 errors, 0 skips
4 runs, 2
assertions, 0 failures, 2 errors, 0 skips
```
...
...
@@ -312,7 +312,7 @@ ActiveRecord::Base.send :include, Yaffle::ActsAsYaffle
When you run
`rake`
, you should see the tests all pass:
```
bash
5 tests, 5
assertions, 0 failures, 0 errors, 0 skips
4 runs, 4
assertions, 0 failures, 0 errors, 0 skips
```
### Add an Instance Method
...
...
@@ -386,7 +386,7 @@ ActiveRecord::Base.send :include, Yaffle::ActsAsYaffle
Run `
rake
` one final time and you should see:
```
7 tests, 7
assertions, 0 failures, 0 errors, 0 skips
6 runs, 6
assertions, 0 failures, 0 errors, 0 skips
```
NOTE: The use of `
write_attribute
` to write to the field in model is just one example of how a plugin can interact with the model, and will not always be the right method to use. For example, you could also use:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录