aboutsummaryrefslogtreecommitdiffstats
path: root/railties/doc/guides/source/creating_plugins/string_to_squawk.txt
diff options
context:
space:
mode:
Diffstat (limited to 'railties/doc/guides/source/creating_plugins/string_to_squawk.txt')
-rw-r--r--railties/doc/guides/source/creating_plugins/string_to_squawk.txt21
1 files changed, 10 insertions, 11 deletions
diff --git a/railties/doc/guides/source/creating_plugins/string_to_squawk.txt b/railties/doc/guides/source/creating_plugins/string_to_squawk.txt
index 50516cef69..63f1131442 100644
--- a/railties/doc/guides/source/creating_plugins/string_to_squawk.txt
+++ b/railties/doc/guides/source/creating_plugins/string_to_squawk.txt
@@ -10,10 +10,10 @@ Most plugins store their code classes in the plugin's lib directory. When you a
First, you need to write the tests. Testing plugins is very similar to testing rails apps. The generated test file should look something like this:
+*vendor/plugins/yaffle/test/core_ext_test.rb*
+
[source, ruby]
--------------------------------------------------------
-# File: vendor/plugins/yaffle/test/core_ext_test.rb
-
require 'test/unit'
class CoreExtTest < Test::Unit::TestCase
@@ -26,11 +26,10 @@ end
Start off by removing the default test, and adding a require statement for your test helper.
+*vendor/plugins/yaffle/test/core_ext_test.rb*
+
[source, ruby]
--------------------------------------------------------
-# File: vendor/plugins/yaffle/test/core_ext_test.rb
-
-require 'test/unit'
require File.dirname(__FILE__) + '/test_helper.rb'
class CoreExtTest < Test::Unit::TestCase
@@ -53,10 +52,10 @@ No tests were specified
Great - now you are ready to start development. The first thing we'll do is to add a method to String called `to_squawk` which will prefix the string with the word ``squawk!''. The test will look something like this:
+*vendor/plugins/yaffle/init.rb*
+
[source, ruby]
--------------------------------------------------------
-# File: vendor/plugins/yaffle/init.rb
-
class CoreExtTest < Test::Unit::TestCase
def test_string_should_respond_to_squawk
assert_equal true, "".respond_to?(:to_squawk)
@@ -72,17 +71,17 @@ class CoreExtTest < Test::Unit::TestCase
end
--------------------------------------------------------
+*vendor/plugins/yaffle/init.rb*
+
[source, ruby]
--------------------------------------------------------
-# File: vendor/plugins/yaffle/init.rb
-
require "core_ext"
--------------------------------------------------------
+*vendor/plugins/yaffle/lib/core_ext.rb*
+
[source, ruby]
--------------------------------------------------------
-# File: vendor/plugins/yaffle/lib/core_ext.rb
-
String.class_eval do
def to_squawk
"squawk! #{self}".strip