erb_sandbox 0.0.2 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5a17355b42bb940a844b091c3153ab90e978d20
4
- data.tar.gz: f1e0b695e0d31d539cdb20665259aa90073697b4
3
+ metadata.gz: 8bb82867229a983ff1d0a02bf4a5d2840f03ee17
4
+ data.tar.gz: 1e489677a85e5210406ecf2b81195e77be086a3d
5
5
  SHA512:
6
- metadata.gz: 2461110f8d61b154b9c51732a80cfd08a88c680d4fd4be5b3b2b34d8e8b548029f4acf3d41a152462ce46999c4b3650a700e17504c7c725c1d95052981cc088e
7
- data.tar.gz: 331decddf5e4906777361a187aa22ad4aa6101af6f238c2646399ce50b210c33e167887bb69a4ea3da8a3f78af393fce0a25920434ec74632c44e975b1cdb018
6
+ metadata.gz: eda72dd9b44e94c8961434116892c7784d0c9a9066805ea5b01f552443a3081abe5de55a7b98a2ebe4fa453a984f434e983e38fc7390ad3bc95c38bac1eeef4b
7
+ data.tar.gz: d3a0bdc9151eca3d0bda722ec605e657cf544483df6159b77ed847aa3db10b7462e8844d25f4003dac5e823b196a64f57c261386b45e1696d418b7c50190fe5f
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # ERB Sandbox v0.0.1
1
+ # ERB Sandbox v0.1.0
2
2
  ERB Sandbox allows you to encapsulate your program from ERB.
3
3
 
4
4
  ### Problem
data/erb_sandbox.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'erb_sandbox'
3
- s.version = '0.0.2'
3
+ s.version = '0.1.0'
4
4
  s.date = '2015-12-04'
5
5
  s.summary = 'ERB Sandbox'
6
6
  s.description = 'Gem allows you to render ERB templates in sandbox with predefined vars'
@@ -15,4 +15,5 @@ Gem::Specification.new do |s|
15
15
 
16
16
  s.required_ruby_version = '>= 2.0.0'
17
17
  s.add_development_dependency 'rubocop', '~> 0.35'
18
+ s.add_development_dependency 'rspec', '~> 3.4'
18
19
  end
data/lib/erb_sandbox.rb CHANGED
@@ -19,7 +19,7 @@ module ErbSandbox
19
19
  # @raise [ErbSandbox::StatusIsNotZero]
20
20
  #
21
21
  def self.render(template, variables = {})
22
- file = Tempfile.new 'erb_sandbox'
22
+ file = Tempfile.new 'erb_sandbox', encoding: 'UTF-8'
23
23
  file.write variables_init_code variables
24
24
  file.write template
25
25
  file.close
@@ -0,0 +1,16 @@
1
+ require_relative '../lib/erb_sandbox'
2
+
3
+ RSpec.describe ErbSandbox do
4
+ it 'renders erb template from code' do
5
+ expect(ErbSandbox.render 'Hello, <%= user %>', user: 'dude').to eq('Hello, dude')
6
+ expect { ErbSandbox.render 'RSpec = <%= RSpec %>' }.to raise_error(ErbSandbox::StatusIsNotZero)
7
+ end
8
+
9
+ it 'renders erb template from file' do
10
+ path = File.expand_path('../test_templates/try_to_use_rspec.erb', __FILE__)
11
+ expect { ErbSandbox.render_file path }.to raise_error(ErbSandbox::StatusIsNotZero)
12
+
13
+ path = File.expand_path('../test_templates/x_equals.erb', __FILE__)
14
+ expect(ErbSandbox.render_file path, x: 1).to eq('x = 1')
15
+ end
16
+ end
@@ -0,0 +1,94 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+ RSpec.configure do |config|
20
+ # rspec-expectations config goes here. You can use an alternate
21
+ # assertion/expectation library such as wrong or the stdlib/minitest
22
+ # assertions if you prefer.
23
+ config.expect_with :rspec do |expectations|
24
+ # This option will default to `true` in RSpec 4. It makes the `description`
25
+ # and `failure_message` of custom matchers include text for helper methods
26
+ # defined using `chain`, e.g.:
27
+ # be_bigger_than(2).and_smaller_than(4).description
28
+ # # => "be bigger than 2 and smaller than 4"
29
+ # ...rather than:
30
+ # # => "be bigger than 2"
31
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32
+ end
33
+
34
+ # rspec-mocks config goes here. You can use an alternate test double
35
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
36
+ config.mock_with :rspec do |mocks|
37
+ # Prevents you from mocking or stubbing a method that does not exist on
38
+ # a real object. This is generally recommended, and will default to
39
+ # `true` in RSpec 4.
40
+ mocks.verify_partial_doubles = true
41
+ end
42
+
43
+ # The settings below are suggested to provide a good initial experience
44
+ # with RSpec, but feel free to customize to your heart's content.
45
+ # # These two settings work together to allow you to limit a spec run
46
+ # # to individual examples or groups you care about by tagging them with
47
+ # # `:focus` metadata. When nothing is tagged with `:focus`, all examples
48
+ # # get run.
49
+ # config.filter_run :focus
50
+ # config.run_all_when_everything_filtered = true
51
+ #
52
+ # # Allows RSpec to persist some state between runs in order to support
53
+ # # the `--only-failures` and `--next-failure` CLI options. We recommend
54
+ # # you configure your source control system to ignore this file.
55
+ # config.example_status_persistence_file_path = "spec/examples.txt"
56
+ #
57
+ # # Limits the available syntax to the non-monkey patched syntax that is
58
+ # # recommended. For more details, see:
59
+ # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
60
+ # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
61
+ # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
62
+ # config.disable_monkey_patching!
63
+ #
64
+ # # This setting enables warnings. It's recommended, but in some cases may
65
+ # # be too noisy due to issues in dependencies.
66
+ # config.warnings = true
67
+ #
68
+ # # Many RSpec users commonly either run the entire suite or an individual
69
+ # # file, and it's useful to allow more verbose output when running an
70
+ # # individual spec file.
71
+ # if config.files_to_run.one?
72
+ # # Use the documentation formatter for detailed output,
73
+ # # unless a formatter has already been configured
74
+ # # (e.g. via a command-line flag).
75
+ # config.default_formatter = 'doc'
76
+ # end
77
+ #
78
+ # # Print the 10 slowest examples and example groups at the
79
+ # # end of the spec run, to help surface which specs are running
80
+ # # particularly slow.
81
+ # config.profile_examples = 10
82
+ #
83
+ # # Run specs in random order to surface order dependencies. If you find an
84
+ # # order dependency and want to debug it, you can fix the order by providing
85
+ # # the seed, which is printed after each run.
86
+ # # --seed 1234
87
+ # config.order = :random
88
+ #
89
+ # # Seed global randomization in this process using the `--seed` CLI option.
90
+ # # Setting this allows you to use `--seed` to deterministically reproduce
91
+ # # test failures related to randomization by passing the same `--seed` value
92
+ # # as the one that triggered the failure.
93
+ # Kernel.srand config.seed
94
+ end
@@ -0,0 +1 @@
1
+ RSpec = <%= RSpec %>
@@ -0,0 +1 @@
1
+ x = <%= x %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erb_sandbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitriy Non
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.35'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.4'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.4'
27
41
  description: Gem allows you to render ERB templates in sandbox with predefined vars
28
42
  email: non.dmitriy@gmail.com
29
43
  executables: []
@@ -31,12 +45,17 @@ extensions: []
31
45
  extra_rdoc_files: []
32
46
  files:
33
47
  - ".gitignore"
48
+ - ".rspec"
34
49
  - ".rubocop.yml"
35
50
  - LICENSE.txt
36
51
  - README.md
37
52
  - erb_sandbox.gemspec
38
53
  - lib/erb_sandbox.rb
39
54
  - lib/erb_sandbox/exceptions.rb
55
+ - spec/erb_sandbox_spec.rb
56
+ - spec/spec_helper.rb
57
+ - spec/test_templates/try_to_use_rspec.erb
58
+ - spec/test_templates/x_equals.erb
40
59
  homepage: https://github.com/Nondv/erb_sandbox
41
60
  licenses:
42
61
  - MIT