scribbler 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.irbrc +2 -0
- data/.rvmrc +1 -1
- data/README.md +87 -40
- data/bin/scribbler +1 -1
- data/lib/scribbler.rb +63 -2
- data/lib/scribbler/base.rb +15 -191
- data/lib/scribbler/{cli.rb → cli_client.rb} +29 -29
- data/lib/scribbler/configurator.rb +61 -13
- data/lib/scribbler/executable.rb +12 -4
- data/lib/scribbler/includeables.rb +13 -43
- data/lib/scribbler/log_location.rb +13 -0
- data/lib/scribbler/logger.rb +152 -0
- data/lib/scribbler/version.rb +1 -1
- data/scribbler.gemspec +1 -0
- data/spec/lib/scribbler/base_spec.rb +16 -0
- data/spec/{scribbler/cli_spec.rb → lib/scribbler/cli_client_spec.rb} +4 -4
- data/spec/{scribbler → lib/scribbler}/configurator_spec.rb +14 -3
- data/spec/lib/scribbler/executable_spec.rb +28 -0
- data/spec/lib/scribbler/includeables_spec.rb +24 -0
- data/spec/lib/scribbler/log_location_spec.rb +11 -0
- data/spec/lib/scribbler/logger_spec.rb +172 -0
- data/spec/{scribbler → lib/scribbler}/version_spec.rb +0 -0
- data/spec/lib/scribbler_spec.rb +47 -0
- data/spec/spec_helper.rb +6 -8
- data/spec/support/examples/scribbler_example.rb +1 -1
- data/templates/scribbler.rb +3 -3
- metadata +62 -39
- data/spec/scribbler/base_spec.rb +0 -140
- data/spec/scribbler/executable_spec.rb +0 -21
- data/spec/scribbler/includeables_spec.rb +0 -9
- data/spec/scribbler_spec.rb +0 -7
data/spec/scribbler/base_spec.rb
DELETED
@@ -1,140 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Scribbler
|
4
|
-
describe Base do
|
5
|
-
subject { Base }
|
6
|
-
|
7
|
-
before :each do
|
8
|
-
Object.send :remove_const, :Rails if defined?(Rails) == 'constant' && Rails.class == Class
|
9
|
-
Time.stub :now => "now"
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should give me a configurator" do
|
13
|
-
subject.config.should == Scribbler::Configurator
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "include_in_application" do
|
17
|
-
it "should attempt to include to the Rails app" do
|
18
|
-
module ::Rails; end
|
19
|
-
::Rails.stub(:application => stub(:class => stub(:parent => stub(:send => true))))
|
20
|
-
subject.stub(:config => stub(:application_include => true))
|
21
|
-
subject.include_in_application.should be_true
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should return nil because it caught the NameError of Rails not existing" do
|
25
|
-
subject.stub(:config => stub(:application_include => true))
|
26
|
-
subject.include_in_application.should be_nil
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should not attempt to include in app if config is false" do
|
30
|
-
subject.stub(:config => stub(:application_include => false))
|
31
|
-
subject.include_in_application.should be_nil
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "configure" do
|
36
|
-
it "kicks off the module and sends includes" do
|
37
|
-
subject.should_receive(:include_in_application).once
|
38
|
-
BaseIncluder.should_receive(:include_includeables).once
|
39
|
-
subject.configure do
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
it "sets some config variables" do
|
44
|
-
subject.configure do
|
45
|
-
config.application_include = true
|
46
|
-
end
|
47
|
-
subject.config.application_include.should be_true
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "build with template" do
|
52
|
-
let(:some_object) { stub(:id => "no id", :class => stub(:name => "SomeObject")) }
|
53
|
-
before :each do
|
54
|
-
subject.configure do
|
55
|
-
config.application_include = false
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
it "calls log, skips templater and still works" do
|
60
|
-
subject.send(:build_with_template,
|
61
|
-
:object => some_object,
|
62
|
-
:template => false,
|
63
|
-
:message => "test\n123").should == "test\n123"
|
64
|
-
end
|
65
|
-
|
66
|
-
it "calls log and gets message with template wrapper" do
|
67
|
-
subject.send(:build_with_template,
|
68
|
-
:template => true,
|
69
|
-
:object => some_object,
|
70
|
-
:message => <<-MSG
|
71
|
-
test
|
72
|
-
123
|
73
|
-
MSG
|
74
|
-
).should == <<-MSG.strip_heredoc
|
75
|
-
-------------------------------------------------
|
76
|
-
now
|
77
|
-
SomeObject: no id
|
78
|
-
test
|
79
|
-
123
|
80
|
-
|
81
|
-
MSG
|
82
|
-
end
|
83
|
-
|
84
|
-
it "calls log and gets message with custom params" do
|
85
|
-
subject.send(:build_with_template,
|
86
|
-
:template => true,
|
87
|
-
:object => some_object,
|
88
|
-
:custom_fields => {:test1 => 1, :test2 => 2},
|
89
|
-
:message => <<-MSG
|
90
|
-
test
|
91
|
-
123
|
92
|
-
MSG
|
93
|
-
).should == <<-MSG.strip_heredoc
|
94
|
-
-------------------------------------------------
|
95
|
-
now
|
96
|
-
SomeObject: no id
|
97
|
-
Test1: 1
|
98
|
-
Test2: 2
|
99
|
-
test
|
100
|
-
123
|
101
|
-
|
102
|
-
MSG
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe "apply to log" do
|
107
|
-
before :each do
|
108
|
-
subject.configure do
|
109
|
-
config.logs = %w[test_log]
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
it "should not work without location" do
|
114
|
-
subject.apply_to_log(nil, :message => "...").should be_nil
|
115
|
-
end
|
116
|
-
|
117
|
-
it "should not work without message" do
|
118
|
-
subject.should_not_receive :test_log_log_location
|
119
|
-
subject.apply_to_log(:test_log).should be_nil
|
120
|
-
end
|
121
|
-
|
122
|
-
it "should build a template and try to put it in a file" do
|
123
|
-
options = { :message => "..." }
|
124
|
-
file = mock(:puts => true)
|
125
|
-
subject.should_receive(:build_with_template).with options
|
126
|
-
subject.should_receive(:log_at).with :test_log
|
127
|
-
File.should_receive(:open).and_yield(file)
|
128
|
-
subject.apply_to_log :test_log, options
|
129
|
-
end
|
130
|
-
|
131
|
-
it "doesn't find a file method" do
|
132
|
-
# in case we have bad config data lingering
|
133
|
-
subject.stub(:respond_to?).with('test_log_log_location').and_return false
|
134
|
-
subject.should_not_receive(:test_log_log_location)
|
135
|
-
Rails.should_receive(:root).and_raise(NameError)
|
136
|
-
subject.log_at(:test_log).should == "#{subject.config.log_directory}/test_log.log"
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Scribbler
|
4
|
-
describe Executable do
|
5
|
-
subject { Executable }
|
6
|
-
describe '.install' do
|
7
|
-
it 'runs some CLI commands' do
|
8
|
-
CLI.should_receive(:run_command).with("mkdir -p #{Base.default_install_path}")
|
9
|
-
CLI.should_receive(:mass_copy).with(Base.templates, Base.default_install_path)
|
10
|
-
subject.install
|
11
|
-
end
|
12
|
-
|
13
|
-
let(:custom_path) { '/some/custom/path' }
|
14
|
-
it 'runs changes install path with given option' do
|
15
|
-
CLI.should_receive(:run_command).with("mkdir -p #{custom_path}")
|
16
|
-
CLI.should_receive(:mass_copy).with(Base.templates, custom_path)
|
17
|
-
subject.install :path => custom_path
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|