i18n_action_mailer 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -16,18 +16,22 @@ rescue LoadError
16
16
  puts "Jeweler not available. Install it with: gem install jeweler"
17
17
  end
18
18
 
19
- desc 'Default: run unit tests.'
20
- task :default => :test
19
+ require 'spec/rake/spectask'
20
+ Spec::Rake::SpecTask.new(:spec) do |spec|
21
+ spec.libs << 'lib' << 'spec'
22
+ spec.spec_files = FileList['spec/**/*_spec.rb']
23
+ end
21
24
 
22
- require 'rake/testtask'
23
- desc 'Test the i18n_action_mailer plugin.'
24
- Rake::TestTask.new(:test) do |t|
25
- t.libs << 'lib'
26
- t.libs << 'test'
27
- t.pattern = 'test/**/*_test.rb'
28
- t.verbose = true
25
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
26
+ spec.libs << 'lib' << 'spec'
27
+ spec.pattern = 'spec/**/*_spec.rb'
28
+ spec.rcov = true
29
29
  end
30
30
 
31
+ task :spec => :check_dependencies
32
+
33
+ task :default => :spec
34
+
31
35
  require 'rake/rdoctask'
32
36
  desc 'Generate documentation for the i18n_action_mailer plugin.'
33
37
  Rake::RDocTask.new(:rdoc) do |rdoc|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{i18n_action_mailer}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Akihiro Matsumura", "Bert Goethals"]
12
- s.date = %q{2010-08-06}
12
+ s.date = %q{2010-08-10}
13
13
  s.description = %q{ActionMailer to use the I18n library without affecting the controllers language}
14
14
  s.email = %q{matsumura.aki@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -26,6 +26,11 @@ Gem::Specification.new do |s|
26
26
  "install.rb",
27
27
  "lib/i18n_action_mailer.rb",
28
28
  "rails/init.rb",
29
+ "spec/i18n_action_mailer_spec.rb",
30
+ "spec/spec.opts",
31
+ "spec/spec_helper.rb",
32
+ "spec/templates/some_mailer/some_mail.erb",
33
+ "spec/templates/some_mailer/some_mail_ja.erb",
29
34
  "tasks/i18n_action_mailer_tasks.rake",
30
35
  "test/i18n_action_mailer_test.rb",
31
36
  "test/test_helper.rb",
@@ -37,7 +42,9 @@ Gem::Specification.new do |s|
37
42
  s.rubygems_version = %q{1.3.6}
38
43
  s.summary = %q{Action mailer with i18n options}
39
44
  s.test_files = [
40
- "test/i18n_action_mailer_test.rb",
45
+ "spec/i18n_action_mailer_spec.rb",
46
+ "spec/spec_helper.rb",
47
+ "test/i18n_action_mailer_test.rb",
41
48
  "test/test_helper.rb"
42
49
  ]
43
50
 
@@ -26,7 +26,7 @@ module I18nActionMailer
26
26
  end
27
27
 
28
28
  def render_message_with_i18n(method_name, body)
29
- method_name = "#{method_name}.#{locale}" if locale and !Dir["#{template_path}/#{method_name}.#{locale}*"].empty?
29
+ method_name = "#{method_name}_#{locale}" if locale and !Dir["#{template_path}/#{method_name}_#{locale}*"].empty?
30
30
  render_message_without_i18n(method_name, body)
31
31
  end
32
32
  end
@@ -0,0 +1,37 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ class SomeMailer < ActionMailer::Base
4
+ def some_mail(locale)
5
+ set_locale locale
6
+
7
+ subject t('some_mail.title', :default => "default subject")
8
+ recipients "some_mail@example.com"
9
+ from "from@example.com"
10
+ end
11
+ end
12
+
13
+ describe "I18nActionMailer" do
14
+ it "should render en template" do
15
+ mail = SomeMailer.create_some_mail("en")
16
+ mail.body.should =~ /Hi! English/
17
+ end
18
+
19
+ it "should render ja template" do
20
+ mail = SomeMailer.create_some_mail("ja")
21
+ mail.body.should =~ /こんにちは、日本語/
22
+ end
23
+
24
+ describe "When I18n locale is set as ja" do
25
+ before do
26
+ I18n.locale = "ja"
27
+ end
28
+ it "should render en template" do
29
+ mail = SomeMailer.create_some_mail('en')
30
+ mail.body.should =~ /Hi! English/
31
+ end
32
+ it "should render ja template" do
33
+ mail = SomeMailer.create_some_mail('ja')
34
+ mail.body.should =~ /こんにちは、日本語/
35
+ end
36
+ end
37
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,15 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require "rubygems"
5
+ gem 'actionmailer', '2.3.8'
6
+ require "action_mailer"
7
+ require 'i18n_action_mailer'
8
+ require 'spec'
9
+ require 'spec/autorun'
10
+
11
+ Spec::Runner.configure do |config|
12
+ end
13
+
14
+ TEMPLATE_PATH = File.join(File.dirname(__FILE__), "templates")
15
+ ActionMailer::Base.template_root = TEMPLATE_PATH
@@ -0,0 +1 @@
1
+ Hi! English
@@ -0,0 +1 @@
1
+ こんにちは、日本語
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Akihiro Matsumura
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-06 00:00:00 +09:00
18
+ date: 2010-08-10 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -38,6 +38,11 @@ files:
38
38
  - install.rb
39
39
  - lib/i18n_action_mailer.rb
40
40
  - rails/init.rb
41
+ - spec/i18n_action_mailer_spec.rb
42
+ - spec/spec.opts
43
+ - spec/spec_helper.rb
44
+ - spec/templates/some_mailer/some_mail.erb
45
+ - spec/templates/some_mailer/some_mail_ja.erb
41
46
  - tasks/i18n_action_mailer_tasks.rake
42
47
  - test/i18n_action_mailer_test.rb
43
48
  - test/test_helper.rb
@@ -73,5 +78,7 @@ signing_key:
73
78
  specification_version: 3
74
79
  summary: Action mailer with i18n options
75
80
  test_files:
81
+ - spec/i18n_action_mailer_spec.rb
82
+ - spec/spec_helper.rb
76
83
  - test/i18n_action_mailer_test.rb
77
84
  - test/test_helper.rb