Permalink
Browse files

Make specs a little more readable, since they are my description

  • Loading branch information...
1 parent 1abbc54 commit d4d0074fbbf93687fa21579b89a08d25f337e422 @iain committed Mar 30, 2012
Showing with 38 additions and 29 deletions.
  1. +8 −6 README.md
  2. +30 −23 spec/i18n-airbrake_spec.rb
View
@@ -1,11 +1,13 @@
# I18n::Airbrake
-* translates known keys normally
-* translates defaults normally
-* notifies airbrake in production environment
-* titleizes the key in production environment
-* raises the error in development environment
-* raises the error in test environment
+* when the translation can be found
+ * translates known keys normally
+ * uses the default normally
+* when the translation cannot be found
+ * notifies airbrake in production environment
+ * titleizes the key in production environment
+ * raises the error in development environment
+ * raises the error in test environment
(straight from the specs)
@@ -1,7 +1,6 @@
require 'i18n-airbrake'
require 'airbrake'
-
describe I18n::Airbrake do
let(:env) { stub "env", :development? => false, :test? => false }
@@ -15,34 +14,42 @@ module Rails
Rails.stub(:env) { env }
end
- it "translates known keys normally" do
- I18n.t(:known).should == translation
- end
+ context "when the translation can be found" do
- it "translates defaults normally" do
- I18n.t(:unknown, :default => "With Default").should == "With Default"
- end
+ it "translates normally" do
+ I18n.t(:known).should == translation
+ end
- it "notifies airbrake in production environment" do
- ::Airbrake.should_receive(:notify).with(an_instance_of(I18n::MissingTranslationData))
- I18n.t(:unknown)
- end
+ it "uses the default normally" do
+ I18n.t(:unknown, :default => "With Default").should == "With Default"
+ end
- it "titleizes the key in production environment" do
- ::Airbrake.stub(:notify)
- I18n.t(:unknown).should == "Unknown"
end
- it "raises the error in development environment" do
- Rails.env.stub(:development?) { true }
- ::Airbrake.should_not_receive(:notify)
- expect { I18n.t(:unknown) }.to raise_error I18n::MissingTranslationData
- end
+ context "when the translation cannot be found" do
+
+ it "notifies airbrake in production environment" do
+ ::Airbrake.should_receive(:notify).with(an_instance_of(I18n::MissingTranslationData))
+ I18n.t(:unknown)
+ end
+
+ it "titleizes the key in production environment" do
+ ::Airbrake.stub(:notify)
+ I18n.t(:unknown).should == "Unknown"
+ end
+
+ it "raises the error in development environment" do
+ Rails.env.stub(:development?) { true }
+ ::Airbrake.should_not_receive(:notify)
+ expect { I18n.t(:unknown) }.to raise_error I18n::MissingTranslationData
+ end
+
+ it "raises the error in test environment" do
+ Rails.env.stub(:test?) { true }
+ ::Airbrake.should_not_receive(:notify)
+ expect { I18n.t(:unknown) }.to raise_error I18n::MissingTranslationData
+ end
- it "raises the error in test environment" do
- Rails.env.stub(:test?) { true }
- ::Airbrake.should_not_receive(:notify)
- expect { I18n.t(:unknown) }.to raise_error I18n::MissingTranslationData
end
end

0 comments on commit d4d0074

Please sign in to comment.