magic_lamp 1.6.0 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -1
- data/lib/magic_lamp/fixture_creator.rb +1 -0
- data/lib/magic_lamp/version.rb +1 -1
- data/spec/dummy/app/views/orders/_symbol_form_for.html.erb +3 -0
- data/spec/lib/fixture_creator_spec.rb +10 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ee1c1e9465b1b32277c6eb82cdbf3713c0a5f2e
|
4
|
+
data.tar.gz: eca8ec0a9a41a09bbdd3fc8fe68f6ff308ab48ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b3d8c9ec0dd46e13dded1c75c3551d9c89c699a13941d49bf1287de6c1d60109c1c9bee7230018da5c94051b6d1c72cc5894b2cc5c57cc394f1ba7a5e8ac4b9
|
7
|
+
data.tar.gz: 132f6d6dcf53d6feffa7c1ede7c12afab62d4a818d648e0d38be346a12080965e06ef0ab332331cb328e5e1358105e165fbd7bbc45d9d34778aa4f64f63166c0
|
data/README.md
CHANGED
@@ -54,6 +54,14 @@ If your JavaScript doesn't support XHR requests, you can drop this in instead:
|
|
54
54
|
|
55
55
|
`//= require magic_lamp/all_fixtures` will load all of your fixtures without making any XHR requests.
|
56
56
|
|
57
|
+
**Note:** when loading your fixtures via Sprockets directives you will likely want to disable Sprockets caching in whatever environment your JavaScript tests are running. You can do so by putting the following in the appropriate environment config file:
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
config.assets.configure do |env|
|
61
|
+
env.cache = ActiveSupport::Cache.lookup_store(:null_store)
|
62
|
+
end
|
63
|
+
```
|
64
|
+
|
57
65
|
Now you've got the basic setup.
|
58
66
|
|
59
67
|
### Debugging
|
@@ -68,6 +76,16 @@ Simply `load` your helpers in the `magic_lamp_config.rb` file like so:
|
|
68
76
|
Dir[Rails.root.join("spec", "support", "magic_lamp_helpers/**/*.rb")].each { |f| load f }
|
69
77
|
```
|
70
78
|
|
79
|
+
### Supported test runners
|
80
|
+
Magic Lamp has been shown to work with:
|
81
|
+
|
82
|
+
* [Jasmine Rails](https://github.com/searls/jasmine-rails)
|
83
|
+
* [Jasmine](https://github.com/jasmine/jasmine-gem)
|
84
|
+
* [Konacha](https://github.com/jfirebaugh/konacha)
|
85
|
+
* [Teaspoon](https://github.com/modeset/teaspoon)
|
86
|
+
|
87
|
+
It will likely work with any test runner that supports XHR requests or Sprockets directives.
|
88
|
+
|
71
89
|
### With Database Cleaner
|
72
90
|
|
73
91
|
You don't need [Database Cleaner](https://github.com/DatabaseCleaner/database_cleaner) to use this gem, but this is probably the setup most people want.
|
@@ -443,7 +461,7 @@ Example:
|
|
443
461
|
```
|
444
462
|
### load
|
445
463
|
Call `MagicLamp.load` to load a fixture. It requires the name of the fixture and which will be loaded into a `div` with a class of `magic-lamp`. It will destroy the previous fixture container if present so you never end up with duplicate fixture containers or end up with dom elements from previous loads. It will hit the network only on the first request for a given
|
446
|
-
fixture. If you never want `load` to hit the network, call [`MagicLamp.preload()`](#preload) before your specs.
|
464
|
+
fixture. If you never want `load` to hit the network, call [`MagicLamp.preload()`](#preload) or use `//= require magic_lamp/all_fixtures` before your specs.
|
447
465
|
|
448
466
|
You can load multiple fixtures into the dom at the same time by simply passing more arguments to `load`.
|
449
467
|
|
@@ -472,6 +490,8 @@ network.
|
|
472
490
|
|
473
491
|
The call to get your templates is completely synchronous.
|
474
492
|
|
493
|
+
**Note:** this is completely unnecessary if you use `//= require magic_lamp/all_fixtures`
|
494
|
+
|
475
495
|
Example:
|
476
496
|
```js
|
477
497
|
// Probably should be in your `spec_helper.js`
|
@@ -7,6 +7,7 @@ module MagicLamp
|
|
7
7
|
def generate_template(controller_class, extensions, &block)
|
8
8
|
execute_callbacks_around do
|
9
9
|
controller = new_controller(controller_class, extensions, &block)
|
10
|
+
controller.request.env["action_dispatch.request.path_parameters"] = { action: "index", controller: controller.controller_name }
|
10
11
|
fetch_rendered(controller, block)
|
11
12
|
end
|
12
13
|
end
|
data/lib/magic_lamp/version.rb
CHANGED
@@ -30,6 +30,16 @@ describe MagicLamp::FixtureCreator do
|
|
30
30
|
expect(rendered).to eq("foo\n")
|
31
31
|
end
|
32
32
|
|
33
|
+
context "form_for with a symbol in the template" do
|
34
|
+
it "renders the form" do
|
35
|
+
expect do
|
36
|
+
subject.generate_template(OrdersController, []) do
|
37
|
+
render partial: "symbol_form_for"
|
38
|
+
end
|
39
|
+
end.to_not raise_error
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
33
43
|
context "render json (non string)" do
|
34
44
|
let!(:rendered) do
|
35
45
|
subject.generate_template(OrdersController, []) do
|
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.6.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Crismali
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -286,6 +286,7 @@ files:
|
|
286
286
|
- spec/dummy/app/models/order.rb
|
287
287
|
- spec/dummy/app/views/layouts/application.html.erb
|
288
288
|
- spec/dummy/app/views/orders/_form.html.erb
|
289
|
+
- spec/dummy/app/views/orders/_symbol_form_for.html.erb
|
289
290
|
- spec/dummy/app/views/orders/bar.html.erb
|
290
291
|
- spec/dummy/app/views/orders/edit.html.erb
|
291
292
|
- spec/dummy/app/views/orders/foo.html.erb
|
@@ -386,6 +387,7 @@ test_files:
|
|
386
387
|
- spec/dummy/app/models/order.rb
|
387
388
|
- spec/dummy/app/views/layouts/application.html.erb
|
388
389
|
- spec/dummy/app/views/orders/_form.html.erb
|
390
|
+
- spec/dummy/app/views/orders/_symbol_form_for.html.erb
|
389
391
|
- spec/dummy/app/views/orders/bar.html.erb
|
390
392
|
- spec/dummy/app/views/orders/edit.html.erb
|
391
393
|
- spec/dummy/app/views/orders/foo.html.erb
|