testing commands usage
arnaud sellenet
committed Apr 07, 2014
commit 8d2b56f6e865eee7df519bf3fa9cc4adac0e3b3f
Showing 3
changed files with
31 additions
and 19 deletions
spec/integration/cli/generate_spec.rb
+30
-0
| @@ | @@ -0,0 +1,30 @@ |
| + | require File.dirname(__FILE__) + '/../integration_helper' |
| + | require 'locomotive/wagon/cli' |
| + | |
| + | |
| + | describe Locomotive::Wagon::CLI::Generate do |
| + | let(:path) { File.join(File.dirname(__FILE__), '../../fixtures', 'default') } |
| + | before { Locomotive::Wagon::CLI::Generate.options[:path] = path } |
| + | |
| + | describe '#generate' do |
| + | subject { capture(:stdout) { Locomotive::Wagon::CLI::Generate.new([], path: path).invoke(:content_type, ['post', *fields]) } } |
| + | |
| + | describe '#content_type' do |
| + | context 'no fields provided' do |
| + | let(:fields) { nil } |
| + | it 'displays and error and doesnt generate' do |
| + | should match 'The fields are missing' |
| + | Locomotive::Wagon.should_not_receive :generate |
| + | end |
| + | end |
| + | |
| + | context 'with fields provided' do |
| + | let(:fields) { ['title', 'content'] } |
| + | it 'displays and error and doesnt generate' do |
| + | Locomotive::Wagon.should_receive(:generate).and_return |
| + | subject |
| + | end |
| + | end |
| + | end |
| + | end |
| + | end |
| \ No newline at end of file | |
spec/integration/cli/serve_spec.rb
+1
-0
| @@ | @@ -8,6 +8,7 @@ require 'locomotive/wagon/cli' |
| describe Locomotive::Wagon::CLI::Main do | |
| describe '#serve' do | |
| let(:output) { capture(:stdout) { subject.serve path } } | |
| + | |
| context 'when no site in path' do | |
| let(:path) { 'a/path/with/no/site' } | |
| it 'outputs an explicit error' do | |
spec/integration/cli_spec.rb
+0
-19
| @@ | @@ -1,19 +0,0 @@ |
| - | # encoding: utf-8 |
| - | |
| - | require File.dirname(__FILE__) + '/integration_helper' |
| - | require 'locomotive/wagon/cli' |
| - | |
| - | describe Locomotive::Wagon::CLI do |
| - | it "overrides subdomains and domains in different environments" do |
| - | clone_site |
| - | deploy = YAML.load_file('site/config/deploy.yml') |
| - | deploy["staging"] = deploy["production"].merge("domains" => ["staging.example.com"], "subdomain" => "staging", "host" => "staging.example.com:3000") |
| - | File.write('site/config/deploy.yml', deploy.to_yaml) |
| - | VCR.use_cassette("staging") do |
| - | Locomotive::Wagon::CLI::Main.start(['push', 'staging', 'site', '-f']) |
| - | end |
| - | |
| - | WebMock.should_not have_requested(:put, /sites\/.+.json\?auth_token=.+/).with(body: /site\[subdomain\]=sample/) |
| - | WebMock.should have_requested(:put, /sites\/.+.json\?auth_token=.+/).with(body: /site\[subdomain\]=staging&site\[domains\]\[\]=staging.example.com/).once |
| - | end |
| - | end |
| \ No newline at end of file | |