magic_lamp 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59341749511aa8a67d1add3ab349b34efdf2ed38
4
- data.tar.gz: 281fb70cc9c9bfacee96a46840aca2e8d619988a
3
+ metadata.gz: 1957d591851320510b8daeb8bef2a3278aef0deb
4
+ data.tar.gz: 9bee7c895782c080098b23698e7f662843a77661
5
5
  SHA512:
6
- metadata.gz: 531159bceb7d43fa85994b61834cbb3e503b1eae418e70102b5fa50d27835273b2ad2b0b40c972308e3555c41a6ef3557dbb8faccf80fa2fea641f45286c9737
7
- data.tar.gz: 31a71c1c45690d3a65a2260f4b39301477d536f3496ff159a9f4a0d8e3fe694d06db45072eae1bad1ae186383788cdde327f2bf0bf53c6f45c793198f7dbc7e7
6
+ metadata.gz: d8592fc96c3eba5598b0b27cfc9f2ee5035aca267a2f689ea2e81955df8e5fb4cc1082a1106ec845a545c17ffdaa5355b73b6f826585a15aa5b205197a694020
7
+ data.tar.gz: 0be0404f6eb9ee5e2e657e5daeea5cf9db4a0240be215c992cbc4c3409a01a2d6644184459c5662100df851037c218fe6ac7cca2cc89d08317697f28a8180d26
data/README.md CHANGED
@@ -299,7 +299,15 @@ Ruby API
299
299
  ### fixture
300
300
  (also aliased to `register_fixture` and `register`)
301
301
 
302
- It requires a block that is invoked in the context of a controller. If render is called, it renders the specified template or partial the way the controller normally would. If `render` is not called in the block then MagicLamp will render the `to_json` representation of the return value of the block unless the return value is already a string. In that case, the string is rendered as is.
302
+ It requires a block that is invoked in the context of a controller. If `render` is called, it renders the specified template or partial the way the controller normally would minus the layout. If you'd like a particular layout to be rendered simply specify it when you call `render`:
303
+
304
+ ```ruby
305
+ render :index, layout: "admin"
306
+ ```
307
+
308
+ **Note:** Rendering the layout could be useful under some circumstances, but it is important to be aware that things will get weird if you use MagicLamp to load and entire HTML document. Especially if it contains `script` tags to your JavaScript.
309
+
310
+ If `render` is not called in the block then MagicLamp will render the `to_json` representation of the return value of the block unless the return value is already a string. In that case, the string is rendered as is.
303
311
 
304
312
  It also takes an optional hash of arguments. The arguments hash recognizes:
305
313
  * `:controller`
@@ -9,15 +9,17 @@ module MagicLamp
9
9
  MagicLamp::DoubleRenderError
10
10
  ].map(&:name)
11
11
 
12
+ RENDER_TYPE = Rails::VERSION::MAJOR == 5 ? :plain : :text
13
+
12
14
  rescue_from(*ERRORS) do |exception, message = exception.message|
13
15
  error_message_with_bactrace = parse_error(exception, message)
14
16
  logger.error(error_message_with_bactrace)
15
- render text: message, status: 400
17
+ render RENDER_TYPE => message, status: 400
16
18
  end
17
19
 
18
20
  def show
19
21
  MagicLamp.load_lamp_files
20
- render text: MagicLamp.generate_fixture(params[:name])
22
+ render RENDER_TYPE => MagicLamp.generate_fixture(params[:name])
21
23
  end
22
24
 
23
25
  def index
@@ -22,7 +22,8 @@ module MagicLamp
22
22
  controller = controller_class.new
23
23
  redefine_view_context(controller, extensions)
24
24
  extensions.each { |extension| controller.extend(extension) }
25
- controller.request = ActionDispatch::TestRequest.new
25
+ test_request_class = ActionDispatch::TestRequest
26
+ controller.request = test_request_class.respond_to?(:create) ? test_request_class.create : test_request_class.new
26
27
  redefine_redirect_to(controller)
27
28
  redefine_render(controller)
28
29
  controller
@@ -1,3 +1,3 @@
1
1
  module MagicLamp
2
- VERSION = "1.7.0"
2
+ VERSION = "1.8.0"
3
3
  end
@@ -6,3 +6,21 @@ Rails.application.config.assets.version = '1.0'
6
6
  # Precompile additional assets.
7
7
  # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
8
8
  # Rails.application.config.assets.precompile += %w( search.js )
9
+ Rails.application.config.assets.precompile += %w(
10
+ support/bind-poly.self.js
11
+ magic_lamp/magic_lamp.self.js
12
+ magic_lamp/genie.self.js
13
+ magic_lamp/boot.self.js
14
+ magic_lamp/application.self.js
15
+ support/underscore-1.6.self.js
16
+ support/chai.self.js
17
+ support/chai-fuzzy.self.js
18
+ support/sinon-chai.self.js
19
+ support/sinon.self.js
20
+ spec_helper.self.js
21
+ genie_spec.self.js
22
+ magic_lamp_spec.self.js
23
+ teaspoon.css
24
+ mocha/1.17.1.js
25
+ teaspoon-mocha.js
26
+ )
@@ -1,3 +1,3 @@
1
1
  MagicLamp.fixture(name: "from_test_directory") do
2
- render text: "something something"
2
+ render MagicLamp::FixturesController::RENDER_TYPE => "something something"
3
3
  end
@@ -42,4 +42,10 @@ RSpec.configure do |config|
42
42
  # The different available types are documented in the features, such as in
43
43
  # https://relishapp.com/rspec/rspec-rails/docs
44
44
  config.infer_spec_type_from_file_location!
45
+
46
+ if Rails::VERSION::MAJOR == 5
47
+ config.include Rails::Controller::Testing::TestProcess
48
+ config.include Rails::Controller::Testing::TemplateAssertions
49
+ config.include Rails::Controller::Testing::Integration
50
+ end
45
51
  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.7.0
4
+ version: 1.8.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: 2015-12-03 00:00:00.000000000 Z
11
+ date: 2016-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -371,7 +371,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
371
371
  version: '0'
372
372
  requirements: []
373
373
  rubyforge_project:
374
- rubygems_version: 2.2.2
374
+ rubygems_version: 2.4.5.1
375
375
  signing_key:
376
376
  specification_version: 4
377
377
  summary: Makes sure your JavaScript tests break when if your templates change.