Sha256: f29d9ce239fecbb49aea8c759f715ab57cb4a6b74d10bb0a067dbfd1fe54f560

Contents?: true

Size: 1.65 KB

Versions: 10

Compression:

Stored size: 1.65 KB

Contents

require 'spec_helper'
require 'localeapp/cli/install'

describe Localeapp::CLI::Install, '.execute(key, output = $stdout)' do
  before(:each) do
    @output = StringIO.new
    @command = Localeapp::CLI::Install.new
  end

  it "displays error if key is nil" do
    @command.execute(nil, @output)
    @output.string.should match(/You must supply an API key/)
  end

  it "displays error if the key is there but isn't valid on localeapp.com" do
    @command.stub!(:check_key).and_return([false, {}])
    @command.execute('API_KEY', @output)
    @output.string.should match(/Project not found/)
  end

  it "displays project name and base locale if the key is there and valid on localeapp.com" do
    @command.stub!(:check_key).and_return([true, valid_project_data])
    @command.stub!(:write_configuration_file)
    @command.execute('API_KEY', @output)
    @output.string.should match(/Test Project/)
    @output.string.should match(/en \(English\)/)
  end

  it "displays warning if I18n.default_locale doesn't match what's configured on localeapp.com" do
    I18n.stub(:default_locale).and_return(:es)
    @command.stub!(:check_key).and_return([true, valid_project_data])
    @command.stub!(:write_configuration_file)
    @command.execute('API_KEY', @output)
    @output.string.should match(%r{WARNING: I18n.default_locale is es, change in config/environment.rb \(Rails 2\) or config/application.rb \(Rails 3\)})
  end

  it "asks the default configuration to write itself" do
    @command.stub!(:check_key).and_return([true, valid_project_data])
    @command.should_receive(:write_configuration_file).with('config/initializers/localeapp.rb')
    @command.execute('API_KEY', @output)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
localeapp-0.4.0 spec/localeapp/cli/install_spec.rb
localeapp-0.3.2 spec/localeapp/cli/install_spec.rb
localeapp-0.3.1 spec/localeapp/cli/install_spec.rb
localeapp-0.3.0 spec/localeapp/cli/install_spec.rb
localeapp-0.2.0 spec/localeapp/cli/install_spec.rb
localeapp-0.1.2 spec/localeapp/cli/install_spec.rb
localeapp-0.1.1 spec/localeapp/cli/install_spec.rb
localeapp-0.0.11 spec/localeapp/cli/install_spec.rb
localeapp-0.0.10 spec/localeapp/cli/install_spec.rb
localeapp-0.0.8 spec/localeapp/cli/install_spec.rb