scribbler 0.2.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
@@ -1,9 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Scribbler
4
- describe BaseIncluder do
5
- end
6
-
7
- describe Includeables do
8
- end
9
- end
@@ -1,7 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Scribbler do
4
- it "has a VERSION" do
5
- Scribbler::VERSION.should_not be_nil
6
- end
7
- end