Sha256: 7a7c75e978c11acee072c2b6c2188230644338ad794dc10eaea1ce27fed07f7b

Contents?: true

Size: 1.56 KB

Versions: 9

Compression:

Stored size: 1.56 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 => @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

9 entries across 9 versions & 1 rubygems

Version Path
localeapp-0.9.3 spec/localeapp/cli/add_spec.rb
localeapp-0.9.2 spec/localeapp/cli/add_spec.rb
localeapp-0.9.1 spec/localeapp/cli/add_spec.rb
localeapp-0.9.0 spec/localeapp/cli/add_spec.rb
localeapp-0.8.1 spec/localeapp/cli/add_spec.rb
localeapp-0.8.0 spec/localeapp/cli/add_spec.rb
localeapp-0.7.2 spec/localeapp/cli/add_spec.rb
localeapp-0.7.1 spec/localeapp/cli/add_spec.rb
localeapp-0.7.0 spec/localeapp/cli/add_spec.rb