magic_lamp 1.0.0 → 1.1.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.
- checksums.yaml +4 -4
- data/README.md +163 -33
- data/VERSION +1 -0
- data/app/assets/javascripts/magic_lamp/genie.js +1 -1
- data/lib/magic_lamp.rb +50 -39
- data/lib/magic_lamp/configuration.rb +2 -1
- data/lib/magic_lamp/constants.rb +24 -0
- data/lib/magic_lamp/defaults_manager.rb +62 -0
- data/lib/magic_lamp/fixture_creator.rb +13 -3
- data/lib/magic_lamp/version.rb +1 -1
- data/spec/dummy/app/views/orders/needs_extending.html.erb +2 -0
- data/spec/dummy/log/development.log +51060 -0
- data/spec/dummy/log/test.log +244175 -0
- data/spec/dummy/spec/magical/a_lamp_file_with_a_different_name_lamp.rb +57 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/04a1e26a9e3fde1f448cb2a9d382fbbc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/09bc89d8ac4ccacfcf2f4db466e7735f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/0b3144442052dbb8af7f57ca27cd7a15 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/18650d8ff9b0a83b32e55b58917ec791 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/292405ba7ff52dbb279572aee49ba174 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2ccef21649a61deac2c84f622753b77b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/32b0c6aea545968d6da4939bcbab9b5e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3823434d99b44359ee75dffba2817055 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3a2dd1069a3d0cd57769e33920561e09 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3c8cdd0e5d5eee39df490048c656a2c5 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/40f78fd7fa893a3ba0bb52949d4d6e21 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/51333e0ed6511483c511470803d3803a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/5b03eeac2e4ecbaaf227c5aa35808fee +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/5bbf09297502a156801e9c65f4bd3db7 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6f968441247482ba7e1ac7ce9f34dfdb +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/759e97d6d411bc4cef7055a778e1bef3 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/7f5b2f45d9f12db1fb26a605759b360a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/7f7dcf7837dbb7f150b7364ad7920712 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/80a68d71946643e61d91cc216f7aa32f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/86023efec2465a88617e5a47a38f1f55 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/87c6d9a5c985ccb321255862fd8c2f48 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/88fe64427f1fff8e41ca8ad0170da88a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8a0862dca044d19cadb655c53acb20ab +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8ed4b4f20fb65446181984e6df7d7c9b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8f4a370f455559b7a209ecd758a3bb3d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/96210dc070e479fcee862294afe5efc1 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/972b6b0bb1fc0b1123077b4b2f4394bd +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/9825272284630c2926f661645205382a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/acbd4771ecb2a173a35382fbff9317cf +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b226a96bfa85a5a853dd6566d1706231 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b2a142b210c2cbfe4a58040684b3c33c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/bb57f340ac9df9041014540af079a7f3 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/bfa154e8a12acdbc85028ad8130d9043 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c84af5f8f55b15818667b16b15416431 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cf573b52d944e8aea7f1dc03f9be9b2c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d98de652252dc6ae11b5b6db5588705b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f0aa53eb377a5d7cc83657ef33b02d25 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f12e838fbbcc1647156ec47ebbeaac9a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f30abc368796858ff89a5ff6daf33e6a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f5d1b7d2ec1c89dc32cc982b43502dc8 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f5e8036e8de24870e4db21ccb209e272 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f6256b2e4e609981d9eb420aae5bef46 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f62fb3331d14ad448ad997f1fbdb7e23 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/fd203e335fb22b3109d0354b99f45c6e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/fdc3718e0a84d340a897f87179d95c84 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/javascripts/genie_spec.js +12 -2
- data/spec/javascripts/magic_lamp_spec.js +14 -1
- data/spec/lib/callbacks_spec.rb +1 -2
- data/spec/lib/configuration_spec.rb +8 -8
- data/spec/lib/defaults_manager_spec.rb +160 -0
- data/spec/lib/fixture_creator_spec.rb +31 -8
- data/spec/lib/magic_lamp_spec.rb +147 -54
- data/spec/lib/render_catcher_spec.rb +1 -2
- data/spec/spec_helper.rb +26 -0
- data/spec/tasks/fixture_names_task_spec.rb +4 -12
- data/spec/tasks/lint_task_spec.rb +4 -10
- metadata +40 -4
data/spec/lib/magic_lamp_spec.rb
CHANGED
|
@@ -2,22 +2,35 @@ require "rails_helper"
|
|
|
2
2
|
|
|
3
3
|
describe MagicLamp do
|
|
4
4
|
context "attr_accessor" do
|
|
5
|
-
it { is_expected.to
|
|
6
|
-
it { is_expected.to
|
|
7
|
-
|
|
8
|
-
it { is_expected.to respond_to :configuration }
|
|
9
|
-
it { is_expected.to respond_to :configuration= }
|
|
5
|
+
it { is_expected.to attr_accessorize(:registered_fixtures) }
|
|
6
|
+
it { is_expected.to attr_accessorize(:configuration) }
|
|
10
7
|
end
|
|
11
8
|
|
|
12
9
|
context "aliases" do
|
|
13
|
-
|
|
10
|
+
MagicLamp::REGISTER_FIXTURE_ALIASES.each do |method_name|
|
|
11
|
+
it { is_expected.to alias_the_method(:register_fixture).to(method_name) }
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
describe "#define" do
|
|
16
|
+
let(:block) { proc { "foo" } }
|
|
17
|
+
let(:options) { { foo: :bar } }
|
|
18
|
+
|
|
19
|
+
it "creates a new defaults manager and evaluates the block in its context" do
|
|
20
|
+
suspect = subject.define(options) do |block_arg|
|
|
21
|
+
@foo = "foo"
|
|
22
|
+
end
|
|
23
|
+
expect(suspect).to be_a(MagicLamp::DefaultsManager)
|
|
24
|
+
expect(suspect.instance_variable_get(:@foo)).to eq("foo")
|
|
25
|
+
expect(suspect.configuration).to eq(subject.configuration)
|
|
26
|
+
expect(suspect.defaults).to eq(options)
|
|
27
|
+
expect(suspect.parent).to be_nil
|
|
17
28
|
end
|
|
18
29
|
|
|
19
|
-
it "
|
|
20
|
-
expect
|
|
30
|
+
it "raises an error if it's not given a block" do
|
|
31
|
+
expect do
|
|
32
|
+
subject.define
|
|
33
|
+
end.to raise_error(MagicLamp::ArgumentError, /define requires a block/)
|
|
21
34
|
end
|
|
22
35
|
end
|
|
23
36
|
|
|
@@ -53,12 +66,16 @@ describe MagicLamp do
|
|
|
53
66
|
|
|
54
67
|
describe "#register_fixture" do
|
|
55
68
|
let(:fixture_name) { "foo" }
|
|
56
|
-
let(:controller_class) {
|
|
69
|
+
let(:controller_class) { ::ApplicationController }
|
|
57
70
|
let(:block) { proc { "so?" } }
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
71
|
+
let(:extensions) { [1, 2, 3] }
|
|
72
|
+
|
|
73
|
+
it "caches the controller class, block, and extensions" do
|
|
74
|
+
subject.register_fixture(controller: controller_class, name: fixture_name, extend: extensions, &block)
|
|
75
|
+
at_fixture_name = subject.registered_fixtures[fixture_name]
|
|
76
|
+
expect(at_fixture_name[:controller]).to eq(controller_class)
|
|
77
|
+
expect(at_fixture_name[:render_block]).to eq(block)
|
|
78
|
+
expect(at_fixture_name[:extend]).to eq(extensions)
|
|
62
79
|
end
|
|
63
80
|
|
|
64
81
|
it "raises an error without a block" do
|
|
@@ -67,7 +84,7 @@ describe MagicLamp do
|
|
|
67
84
|
end.to raise_error(MagicLamp::ArgumentError, /register_fixture requires a block/)
|
|
68
85
|
end
|
|
69
86
|
|
|
70
|
-
context "
|
|
87
|
+
context "without name inference" do
|
|
71
88
|
it "raises an error without a specified name" do
|
|
72
89
|
subject.configuration.infer_names = false
|
|
73
90
|
expect do
|
|
@@ -81,7 +98,24 @@ describe MagicLamp do
|
|
|
81
98
|
|
|
82
99
|
it "uses ApplicationController as the default controller" do
|
|
83
100
|
subject.register_fixture { render :index }
|
|
84
|
-
expect(at_index
|
|
101
|
+
expect(at_index[:controller]).to eq(::ApplicationController)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
context "extend" do
|
|
105
|
+
it "defaults to an empty array" do
|
|
106
|
+
subject.register_fixture { render :index }
|
|
107
|
+
expect(at_index[:extend]).to eq([])
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it "wraps a bare object in an array" do
|
|
111
|
+
subject.register_fixture(extend: "foo") { render :index }
|
|
112
|
+
expect(at_index[:extend]).to eq(["foo"])
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it "does not double wrap an array" do
|
|
116
|
+
subject.register_fixture(extend: ["foo"]) { render :index }
|
|
117
|
+
expect(at_index[:extend]).to eq(["foo"])
|
|
118
|
+
end
|
|
85
119
|
end
|
|
86
120
|
|
|
87
121
|
context "fixture name" do
|
|
@@ -92,18 +126,31 @@ describe MagicLamp do
|
|
|
92
126
|
end.to raise_error(MagicLamp::AlreadyRegisteredFixtureError, "a fixture called 'index' has already been registered")
|
|
93
127
|
end
|
|
94
128
|
|
|
95
|
-
context "
|
|
96
|
-
it "
|
|
97
|
-
|
|
98
|
-
subject.
|
|
129
|
+
context "namespacing" do
|
|
130
|
+
it "removes 'application'" do
|
|
131
|
+
subject.register_fixture(namespace: "application/orders/application/foos") { render :foo }
|
|
132
|
+
expect(subject.registered_fixtures).to_not have_key("application/orders/application/foos/foo")
|
|
133
|
+
expect(subject.registered_fixtures).to have_key("orders/foos/foo")
|
|
134
|
+
end
|
|
99
135
|
|
|
100
|
-
|
|
136
|
+
it "prevents double namespacing" do
|
|
137
|
+
subject.register_fixture(namespace: "orders/orders/foos/orders/orders/bars") { render :foo }
|
|
138
|
+
expect(subject.registered_fixtures).to_not have_key("orders/orders/foos/orders/orders/bars/foo")
|
|
139
|
+
expect(subject.registered_fixtures).to have_key("orders/foos/orders/bars/foo")
|
|
101
140
|
end
|
|
141
|
+
end
|
|
102
142
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
143
|
+
context "with ApplicationController" do
|
|
144
|
+
let(:index) { "index" }
|
|
145
|
+
|
|
146
|
+
it "is the first argument to render when given 2" do
|
|
147
|
+
subject.register_fixture(controller: ::ApplicationController) { render :index, foo: :bar }
|
|
148
|
+
expect(subject.registered_fixtures).to have_key(index)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it "is the only argument when it isn't a hash" do
|
|
152
|
+
subject.register_fixture(controller: ::ApplicationController) { render :index }
|
|
153
|
+
expect(subject.registered_fixtures).to have_key(index)
|
|
107
154
|
end
|
|
108
155
|
|
|
109
156
|
it "passes its configuration object to the render catcher" do
|
|
@@ -111,39 +158,70 @@ describe MagicLamp do
|
|
|
111
158
|
subject.register_fixture { render :foo }
|
|
112
159
|
end
|
|
113
160
|
|
|
114
|
-
context "1 hash argument" do
|
|
161
|
+
context "and 1 hash argument to render" do
|
|
115
162
|
it "raises an error if it can't figure out a default name" do
|
|
116
163
|
expect do
|
|
117
164
|
subject.register_fixture(controller: ::ApplicationController) { render collection: [1, 2, 3] }
|
|
118
165
|
end.to raise_error(MagicLamp::AmbiguousFixtureNameError, /Unable to infer fixture name/)
|
|
119
166
|
end
|
|
120
167
|
|
|
121
|
-
it "
|
|
122
|
-
|
|
123
|
-
subject.
|
|
124
|
-
expect(at_index).to eq([::ApplicationController, render_block])
|
|
168
|
+
it "is the name at the template key" do
|
|
169
|
+
subject.register_fixture(controller: ::ApplicationController) { render template: :index }
|
|
170
|
+
expect(subject.registered_fixtures).to have_key(index)
|
|
125
171
|
end
|
|
126
172
|
|
|
127
|
-
it "
|
|
128
|
-
|
|
129
|
-
subject.
|
|
130
|
-
expect(at_index).to eq([::ApplicationController, render_block])
|
|
173
|
+
it "is the name at the partial key" do
|
|
174
|
+
subject.register_fixture(controller: ::ApplicationController) { render partial: :partial }
|
|
175
|
+
expect(subject.registered_fixtures).to have_key("partial")
|
|
131
176
|
end
|
|
132
177
|
end
|
|
133
|
-
end
|
|
134
178
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
179
|
+
context "namespacing" do
|
|
180
|
+
it "prepends the namespace to the front of the fixture name when inferred" do
|
|
181
|
+
subject.register_fixture(controller: ::ApplicationController, namespace: "foo") do
|
|
182
|
+
render :bar
|
|
183
|
+
end
|
|
184
|
+
expect(subject.registered_fixtures).to have_key("foo/bar")
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
it "prepends the namespace to the front of the fixture name when specified" do
|
|
188
|
+
subject.register_fixture(controller: ::ApplicationController, namespace: "foo", name: "baz") do
|
|
189
|
+
render :bar
|
|
190
|
+
end
|
|
191
|
+
expect(subject.registered_fixtures).to have_key("foo/baz")
|
|
192
|
+
end
|
|
140
193
|
end
|
|
194
|
+
end
|
|
141
195
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
196
|
+
context "with another controller" do
|
|
197
|
+
context "namespacing" do
|
|
198
|
+
context "unspecified namespace" do
|
|
199
|
+
it "namespaces the fixture name with the controller's name" do
|
|
200
|
+
subject.register_fixture(controller: OrdersController) { render partial: :index }
|
|
201
|
+
expect(subject.registered_fixtures).to_not have_key("index")
|
|
202
|
+
expect(subject.registered_fixtures).to have_key("orders/index")
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
it "does not prepend the controller's name when it is already the beginning of the string" do
|
|
206
|
+
subject.register_fixture(controller: OrdersController) { render partial: "orders/order" }
|
|
207
|
+
expect(subject.registered_fixtures).to_not have_key("orders/orders/order")
|
|
208
|
+
expect(subject.registered_fixtures).to have_key("orders/order")
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
context "specified namespace" do
|
|
213
|
+
it "does not use the controller's name as a namespace" do
|
|
214
|
+
subject.register_fixture(controller: OrdersController, namespace: "foo") { render partial: :index }
|
|
215
|
+
expect(subject.registered_fixtures).to_not have_key("orders/index")
|
|
216
|
+
expect(subject.registered_fixtures).to have_key("foo/index")
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
it "does not prepend the namespace when the fixture name starts with the string" do
|
|
220
|
+
subject.register_fixture(controller: OrdersController, namespace: "foo") { render partial: "foo/order" }
|
|
221
|
+
expect(subject.registered_fixtures).to_not have_key("foo/foo/order")
|
|
222
|
+
expect(subject.registered_fixtures).to have_key("foo/order")
|
|
223
|
+
end
|
|
224
|
+
end
|
|
147
225
|
end
|
|
148
226
|
end
|
|
149
227
|
end
|
|
@@ -159,14 +237,14 @@ describe MagicLamp do
|
|
|
159
237
|
it "does not raise an error if there's no config" do
|
|
160
238
|
allow(Dir).to receive(:[]).and_return([])
|
|
161
239
|
expect(subject).to_not receive(:registered_fixtures)
|
|
162
|
-
subject.load_config
|
|
240
|
+
expect { subject.load_config }.to_not raise_error
|
|
163
241
|
end
|
|
164
242
|
end
|
|
165
243
|
|
|
166
244
|
describe "#load_lamp_files" do
|
|
167
245
|
it "loads all lamp files" do
|
|
168
246
|
subject.load_lamp_files
|
|
169
|
-
expect(subject.registered_fixtures["orders/foo"]).to
|
|
247
|
+
expect(subject.registered_fixtures["orders/foo"]).to be_a(Hash)
|
|
170
248
|
end
|
|
171
249
|
|
|
172
250
|
it "blows out registered_fixtures on each call" do
|
|
@@ -186,7 +264,6 @@ describe MagicLamp do
|
|
|
186
264
|
end
|
|
187
265
|
|
|
188
266
|
describe "#registered?" do
|
|
189
|
-
|
|
190
267
|
it "returns true if the fixture is registered" do
|
|
191
268
|
subject.registered_fixtures["foo"] = :something
|
|
192
269
|
expect(subject.registered?("foo")).to eq(true)
|
|
@@ -199,13 +276,19 @@ describe MagicLamp do
|
|
|
199
276
|
|
|
200
277
|
describe "#generate_fixture" do
|
|
201
278
|
let(:block) { proc { render :foo } }
|
|
279
|
+
let(:fixture_name) { "foo_test" }
|
|
280
|
+
let(:extensions) { 3.times.map { Module.new } }
|
|
202
281
|
|
|
203
282
|
before do
|
|
204
|
-
subject.registered_fixtures[
|
|
283
|
+
subject.registered_fixtures[fixture_name] = {
|
|
284
|
+
controller: OrdersController,
|
|
285
|
+
render_block: block,
|
|
286
|
+
extend: extensions
|
|
287
|
+
}
|
|
205
288
|
end
|
|
206
289
|
|
|
207
290
|
it "returns the template" do
|
|
208
|
-
expect(subject.generate_fixture(
|
|
291
|
+
expect(subject.generate_fixture(fixture_name)).to eq("foo\n")
|
|
209
292
|
end
|
|
210
293
|
|
|
211
294
|
it "raises an error when told to generate a template that is not registered" do
|
|
@@ -214,11 +297,21 @@ describe MagicLamp do
|
|
|
214
297
|
end.to raise_error(MagicLamp::UnregisteredFixtureError, /is not a registered fixture/)
|
|
215
298
|
end
|
|
216
299
|
|
|
217
|
-
it "passes its configuration object to the
|
|
218
|
-
subject.registered_fixtures["foo"] = []
|
|
300
|
+
it "passes its configuration object to the fixture creator" do
|
|
219
301
|
dummy = double(generate_template: :generate_template)
|
|
220
302
|
expect(MagicLamp::FixtureCreator).to receive(:new).with(subject.configuration).and_return(dummy)
|
|
221
|
-
subject.generate_fixture(
|
|
303
|
+
subject.generate_fixture(fixture_name)
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
it "passes the controller, extensions, and block to the fixture creator's generate_template method" do
|
|
307
|
+
dummy = double
|
|
308
|
+
allow(MagicLamp::FixtureCreator).to receive(:new).and_return(dummy)
|
|
309
|
+
expect(dummy).to receive(:generate_template) do |controller, extend_args, &passed_block|
|
|
310
|
+
expect(controller).to eq(OrdersController)
|
|
311
|
+
expect(extend_args).to eq(extensions)
|
|
312
|
+
expect(passed_block).to eq(block)
|
|
313
|
+
end
|
|
314
|
+
subject.generate_fixture(fixture_name)
|
|
222
315
|
end
|
|
223
316
|
end
|
|
224
317
|
|
|
@@ -6,8 +6,7 @@ describe MagicLamp::RenderCatcher do
|
|
|
6
6
|
it { is_expected.to be_kind_of(MagicLamp::Callbacks) }
|
|
7
7
|
|
|
8
8
|
context "attr_accessor" do
|
|
9
|
-
it { is_expected.to
|
|
10
|
-
it { is_expected.to respond_to :render_argument= }
|
|
9
|
+
it { is_expected.to attr_accessorize :render_argument }
|
|
11
10
|
end
|
|
12
11
|
|
|
13
12
|
describe "#render" do
|
data/spec/spec_helper.rb
CHANGED
|
@@ -14,7 +14,32 @@
|
|
|
14
14
|
# users commonly want.
|
|
15
15
|
#
|
|
16
16
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
|
17
|
+
require "fantaskspec"
|
|
18
|
+
MAIN_OBJECT = self
|
|
19
|
+
|
|
20
|
+
RSpec::Matchers.define :alias_the_method do |method_name|
|
|
21
|
+
match do |actual|
|
|
22
|
+
if actual.respond_to?(method_name) && actual.respond_to?(@other_method_name)
|
|
23
|
+
aliased_method = actual.method(@other_method_name)
|
|
24
|
+
original_method = actual.method(method_name)
|
|
25
|
+
aliased_method.original_name == original_method.name
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
chain :to do |other_method_name|
|
|
30
|
+
@other_method_name = other_method_name
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
RSpec::Matchers.define :attr_accessorize do |attribute_name|
|
|
35
|
+
match do |actual|
|
|
36
|
+
actual.respond_to?(attribute_name) && actual.respond_to?("#{attribute_name}=")
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
17
40
|
RSpec.configure do |config|
|
|
41
|
+
config.infer_rake_task_specs_from_file_location!
|
|
42
|
+
|
|
18
43
|
config.before(:each) do
|
|
19
44
|
MagicLamp.registered_fixtures = {}
|
|
20
45
|
MagicLamp.configuration = MagicLamp::Configuration.new
|
|
@@ -65,6 +90,7 @@ RSpec.configure do |config|
|
|
|
65
90
|
# For more details, see:
|
|
66
91
|
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
|
67
92
|
expectations.syntax = :expect
|
|
93
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
68
94
|
end
|
|
69
95
|
|
|
70
96
|
# rspec-mocks config goes here. You can use an alternate test double
|
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
require "rails_helper"
|
|
2
2
|
|
|
3
|
-
describe "
|
|
4
|
-
|
|
3
|
+
describe "magic_lamp:fixture_names" do
|
|
4
|
+
it { is_expected.to depend_on(:environment) }
|
|
5
5
|
|
|
6
6
|
it "outputs a sorted list of all the fixture names" do
|
|
7
|
-
|
|
8
|
-
task_proc = task.actions.first
|
|
9
|
-
|
|
10
|
-
expect(dummy).to receive(:puts) do |output|
|
|
7
|
+
expect(MAIN_OBJECT).to receive(:puts) do |output|
|
|
11
8
|
fixture_names = MagicLamp.registered_fixtures.keys.sort
|
|
12
9
|
expect(output).to_not be_empty
|
|
13
10
|
expect(output).to eq(fixture_names)
|
|
14
11
|
end
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it "depends on the environment task" do
|
|
20
|
-
prereqs = task.all_prerequisite_tasks
|
|
21
|
-
expect(prereqs).to include(Rake::Task["environment"])
|
|
13
|
+
subject.execute
|
|
22
14
|
end
|
|
23
15
|
end
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
require "rails_helper"
|
|
2
2
|
|
|
3
|
-
describe "
|
|
4
|
-
|
|
3
|
+
describe "magic_lamp:lint" do
|
|
4
|
+
it { is_expected.to depend_on(:environment) }
|
|
5
5
|
|
|
6
6
|
it "generates all fixtures" do
|
|
7
7
|
expect(MagicLamp).to receive(:generate_all_fixtures)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
dummy.instance_eval(&task_proc)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it "depends on the environment task" do
|
|
14
|
-
prereqs = task.all_prerequisite_tasks
|
|
15
|
-
expect(prereqs).to include(Rake::Task["environment"])
|
|
8
|
+
allow(MAIN_OBJECT).to receive(:puts).and_return(:puts)
|
|
9
|
+
subject.execute
|
|
16
10
|
end
|
|
17
11
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: magic_lamp
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Crismali
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
11
|
+
date: 2014-10-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '4.0'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '4.0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rake
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -108,6 +108,20 @@ dependencies:
|
|
|
108
108
|
- - ">="
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: fantaskspec
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
111
125
|
- !ruby/object:Gem::Dependency
|
|
112
126
|
name: pry
|
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -136,6 +150,20 @@ dependencies:
|
|
|
136
150
|
- - ">="
|
|
137
151
|
- !ruby/object:Gem::Version
|
|
138
152
|
version: '0'
|
|
153
|
+
- !ruby/object:Gem::Dependency
|
|
154
|
+
name: pry-doc
|
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
|
156
|
+
requirements:
|
|
157
|
+
- - ">="
|
|
158
|
+
- !ruby/object:Gem::Version
|
|
159
|
+
version: '0'
|
|
160
|
+
type: :development
|
|
161
|
+
prerelease: false
|
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
163
|
+
requirements:
|
|
164
|
+
- - ">="
|
|
165
|
+
- !ruby/object:Gem::Version
|
|
166
|
+
version: '0'
|
|
139
167
|
- !ruby/object:Gem::Dependency
|
|
140
168
|
name: bundler
|
|
141
169
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -174,6 +202,7 @@ extra_rdoc_files: []
|
|
|
174
202
|
files:
|
|
175
203
|
- LICENSE
|
|
176
204
|
- README.md
|
|
205
|
+
- VERSION
|
|
177
206
|
- app/assets/javascripts/magic_lamp.js
|
|
178
207
|
- app/assets/javascripts/magic_lamp/application.js
|
|
179
208
|
- app/assets/javascripts/magic_lamp/boot.js
|
|
@@ -188,6 +217,8 @@ files:
|
|
|
188
217
|
- lib/magic_lamp.rb
|
|
189
218
|
- lib/magic_lamp/callbacks.rb
|
|
190
219
|
- lib/magic_lamp/configuration.rb
|
|
220
|
+
- lib/magic_lamp/constants.rb
|
|
221
|
+
- lib/magic_lamp/defaults_manager.rb
|
|
191
222
|
- lib/magic_lamp/engine.rb
|
|
192
223
|
- lib/magic_lamp/fixture_creator.rb
|
|
193
224
|
- lib/magic_lamp/render_catcher.rb
|
|
@@ -210,6 +241,7 @@ files:
|
|
|
210
241
|
- spec/dummy/app/views/orders/edit.html.erb
|
|
211
242
|
- spec/dummy/app/views/orders/foo.html.erb
|
|
212
243
|
- spec/dummy/app/views/orders/index.html.erb
|
|
244
|
+
- spec/dummy/app/views/orders/needs_extending.html.erb
|
|
213
245
|
- spec/dummy/app/views/orders/new.html.erb
|
|
214
246
|
- spec/dummy/app/views/orders/show.html.erb
|
|
215
247
|
- spec/dummy/bin/bundle
|
|
@@ -368,6 +400,7 @@ files:
|
|
|
368
400
|
- spec/javascripts/support/underscore-1.6.js
|
|
369
401
|
- spec/lib/callbacks_spec.rb
|
|
370
402
|
- spec/lib/configuration_spec.rb
|
|
403
|
+
- spec/lib/defaults_manager_spec.rb
|
|
371
404
|
- spec/lib/fixture_creator_spec.rb
|
|
372
405
|
- spec/lib/magic_lamp_spec.rb
|
|
373
406
|
- spec/lib/render_catcher_spec.rb
|
|
@@ -415,6 +448,7 @@ test_files:
|
|
|
415
448
|
- spec/dummy/app/views/orders/edit.html.erb
|
|
416
449
|
- spec/dummy/app/views/orders/foo.html.erb
|
|
417
450
|
- spec/dummy/app/views/orders/index.html.erb
|
|
451
|
+
- spec/dummy/app/views/orders/needs_extending.html.erb
|
|
418
452
|
- spec/dummy/app/views/orders/new.html.erb
|
|
419
453
|
- spec/dummy/app/views/orders/show.html.erb
|
|
420
454
|
- spec/dummy/bin/bundle
|
|
@@ -575,6 +609,7 @@ test_files:
|
|
|
575
609
|
- spec/javascripts/support/underscore-1.6.js
|
|
576
610
|
- spec/lib/callbacks_spec.rb
|
|
577
611
|
- spec/lib/configuration_spec.rb
|
|
612
|
+
- spec/lib/defaults_manager_spec.rb
|
|
578
613
|
- spec/lib/fixture_creator_spec.rb
|
|
579
614
|
- spec/lib/magic_lamp_spec.rb
|
|
580
615
|
- spec/lib/render_catcher_spec.rb
|
|
@@ -583,3 +618,4 @@ test_files:
|
|
|
583
618
|
- spec/tasks/fixture_names_task_spec.rb
|
|
584
619
|
- spec/tasks/lint_task_spec.rb
|
|
585
620
|
- spec/teaspoon_env.rb
|
|
621
|
+
has_rdoc:
|