Sha256: 7e58601ceacb8fae76ee58c0ea212e3bcd3998c2fcd04ab6b492f5efed5f4e28

Contents?: true

Size: 1.55 KB

Versions: 11

Compression:

Stored size: 1.55 KB

Contents

require 'spec_helper'

describe Localeapp::CLI::Add, "#execute(key, *translations)" do
  def do_action(key = 'test.key', args = nil)
    args ||= ['en:test en', 'es:test es']
    @command.execute(key, *args)
  end

  before(:each) do
    @output = StringIO.new
    @command = Localeapp::CLI::Add.new(@output)
  end

  it "adds the translations to missing_translations" do
    with_configuration do
      Localeapp.sender.stub!(:post_missing_translations)
      do_action
    end
    en_missing = Localeapp.missing_translations['en']
    en_missing.size.should == 1
    en_missing['test.key'].locale.should == 'en'
    en_missing['test.key'].description.should == 'test en'
    es_missing = Localeapp.missing_translations['es']
    es_missing.size.should == 1
    es_missing['test.key'].locale.should == 'es'
    es_missing['test.key'].description.should == 'test es'
  end

  it "ignores badly formed arguments" do
    with_configuration do
      Localeapp.sender.stub!(:post_missing_translations)
      do_action('test.key', ["en:this is fine", "esbad"])
    end
    Localeapp.missing_translations['en'].size.should == 1
    Localeapp.missing_translations['es'].size.should == 0
    Localeapp.missing_translations['esbad'].size.should == 0
    @output.string.should include("Ignoring bad translation esbad")
    @output.string.should include("format should be <locale>:<translation content>")
  end

  it "tells the sender to send the missing translations" do
    with_configuration do
      Localeapp.sender.should_receive(:post_missing_translations)
      do_action
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
localeapp-0.5.2 spec/localeapp/cli/add_spec.rb
localeapp-0.5.1 spec/localeapp/cli/add_spec.rb
localeapp-0.5.0 spec/localeapp/cli/add_spec.rb
localeapp-0.4.3 spec/localeapp/cli/add_spec.rb
localeapp-0.4.2 spec/localeapp/cli/add_spec.rb
localeapp-0.4.1 spec/localeapp/cli/add_spec.rb
localeapp-0.4.0 spec/localeapp/cli/add_spec.rb
localeapp-0.3.2 spec/localeapp/cli/add_spec.rb
localeapp-0.3.1 spec/localeapp/cli/add_spec.rb
localeapp-0.3.0 spec/localeapp/cli/add_spec.rb
localeapp-0.2.0 spec/localeapp/cli/add_spec.rb