deface 1.0.1 → 1.0.2
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/.gitignore +1 -0
- data/Gemfile +3 -2
- data/README.markdown +3 -11
- data/deface.gemspec +4 -4
- data/lib/deface/applicator.rb +1 -1
- data/lib/deface/dsl/loader.rb +42 -34
- data/lib/deface/railtie.rb +2 -2
- data/lib/deface/slim_converter.rb +15 -0
- data/lib/deface/sources/copy.rb +1 -1
- data/lib/deface/sources/slim.rb +2 -2
- data/lib/deface/template_helper.rb +1 -1
- data/spec/deface/action_view_template_spec.rb +12 -12
- data/spec/deface/actions/add_to_attributes_spec.rb +8 -8
- data/spec/deface/actions/insert_after_spec.rb +1 -1
- data/spec/deface/actions/insert_before_spec.rb +1 -1
- data/spec/deface/actions/insert_bottom_spec.rb +2 -2
- data/spec/deface/actions/insert_top_spec.rb +2 -2
- data/spec/deface/actions/remove_from_attributes_spec.rb +9 -9
- data/spec/deface/actions/remove_spec.rb +2 -2
- data/spec/deface/actions/replace_contents_spec.rb +2 -2
- data/spec/deface/actions/replace_spec.rb +10 -10
- data/spec/deface/actions/set_attributes_spec.rb +11 -11
- data/spec/deface/actions/surround_contents_spec.rb +5 -5
- data/spec/deface/actions/surround_spec.rb +5 -5
- data/spec/deface/applicator_spec.rb +6 -6
- data/spec/deface/dsl/context_spec.rb +7 -7
- data/spec/deface/dsl/loader_spec.rb +74 -77
- data/spec/deface/environment_spec.rb +38 -38
- data/spec/deface/haml_converter_spec.rb +24 -24
- data/spec/deface/override_spec.rb +90 -90
- data/spec/deface/parser_spec.rb +54 -54
- data/spec/deface/precompiler_spec.rb +7 -7
- data/spec/deface/search_spec.rb +7 -7
- data/spec/deface/slim_converter_spec.rb +32 -0
- data/spec/deface/template_helper_spec.rb +21 -22
- data/spec/deface/utils/failure_finder_spec.rb +11 -11
- data/spec/spec_helper.rb +25 -17
- metadata +33 -69
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 362600d10ec6ef2e0156d59d64d4dd8f3fb92a20
|
4
|
+
data.tar.gz: 9900d892be3f317070b21aa8f0d81d2c12d9b44b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 665ab9e4c61bfcb42d9812688f7d3abdd5f8a79724c0e7e4f7be062f2abff6e5c578644d6088cf6786110fca1cb878920be2e37cfac1f3841d990a37f2a67e0e
|
7
|
+
data.tar.gz: 46e41b81bb39faa7bb21b5f7581c66f0edc73e423b80ddd7b5519a23a3f087caf0de53e739939576212baa87fe461fab15752d67f5c36d72ef836b191855cc3a
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.markdown
CHANGED
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
<a href="http://secure.travis-ci.org/spree/deface">
|
3
|
-
<img src="https://secure.travis-ci.org/spree/deface.png?branch=master">
|
4
|
-
</a>
|
5
|
-
</p>
|
1
|
+
[](https://travis-ci.org/DefaceCommunity/deface)
|
6
2
|
|
7
3
|
Deface
|
8
4
|
======
|
@@ -308,7 +304,7 @@ allowing overrides in different engines with identical filenames to co-exist.
|
|
308
304
|
|
309
305
|
### DSL usage for overrides that do not include markup
|
310
306
|
|
311
|
-
If your override does not require any markup, for example actions including ````:remove, :set_attributes, :remove_from_attributes, :
|
307
|
+
If your override does not require any markup, for example actions including ````:remove, :set_attributes, :remove_from_attributes, :add_to_attributes```` you can exclude the "html.erb" or "html.haml" from the file name and you do not need to wrap the arguments in a comment.
|
312
308
|
|
313
309
|
So the override filename becomes simply:
|
314
310
|
|
@@ -412,11 +408,7 @@ Deface uses the amazing Nokogiri library (and in turn libxml) for parsing HTML /
|
|
412
408
|
|
413
409
|
1. Ensure that your layout views include doctype, html, head and body tags in a single file, as Nokogiri will create such elements if it detects any of these tags have been incorrectly nested.
|
414
410
|
|
415
|
-
2. Parsing will fail and result in invalid output if ERB blocks are responsible for closing an HTML tag that was opened normally, i.e. don't do this:
|
416
|
-
|
417
|
-
```html
|
418
|
-
<div <%= ">" %>
|
419
|
-
```
|
411
|
+
2. Parsing will fail and result in invalid output if ERB blocks are responsible for closing an HTML tag that was opened normally, i.e. don't do this: `<div <%= ">" %>`
|
420
412
|
|
421
413
|
3. Gems or Spree Extensions that add overrides to your application will load them in the order they are added to your Gemfile.
|
422
414
|
|
data/deface.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "deface"
|
3
|
-
s.version = "1.0.
|
3
|
+
s.version = "1.0.2"
|
4
4
|
|
5
5
|
s.authors = ["Brian D Quinn"]
|
6
6
|
s.description = "Deface is a library that allows you to customize ERB, Haml and Slim views in a Rails application without editing the underlying view."
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
]
|
11
11
|
s.files = `git ls-files`.split("\n")
|
12
12
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
13
|
-
s.homepage = "https://github.com/
|
13
|
+
s.homepage = "https://github.com/DefaceCommunity/deface"
|
14
14
|
s.rdoc_options = ["--charset=UTF-8"]
|
15
15
|
s.require_paths = ["lib"]
|
16
16
|
s.summary = "Deface is a library that allows you to customize ERB, Haml and Slim views in Rails"
|
@@ -20,9 +20,9 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_dependency('colorize', '>= 0.5.8')
|
21
21
|
s.add_dependency('polyglot')
|
22
22
|
|
23
|
-
s.add_development_dependency('rspec', '>=
|
23
|
+
s.add_development_dependency('rspec', '>= 3.1.0')
|
24
24
|
s.add_development_dependency('haml', '>= 3.1.4')
|
25
|
-
s.add_development_dependency('slim', '2.0.0') # 2.0.1 breaks slim loader specs
|
25
|
+
s.add_development_dependency('slim', '>= 2.0.0') # 2.0.1 breaks slim loader specs
|
26
26
|
s.add_development_dependency('simplecov', '>= 0.6.4')
|
27
27
|
s.add_development_dependency('generator_spec', '~> 0.8')
|
28
28
|
end
|
data/lib/deface/applicator.rb
CHANGED
@@ -16,7 +16,7 @@ module Deface
|
|
16
16
|
#convert haml to erb before parsing before
|
17
17
|
source = Deface::HamlConverter.new(source).result
|
18
18
|
when :slim
|
19
|
-
source =
|
19
|
+
source = Deface::SlimConverter.new(source).result
|
20
20
|
end
|
21
21
|
|
22
22
|
doc = Deface::Parser.convert(source)
|
data/lib/deface/dsl/loader.rb
CHANGED
@@ -19,42 +19,50 @@ module Deface
|
|
19
19
|
|
20
20
|
file_contents = file.read
|
21
21
|
|
22
|
-
|
23
|
-
dsl_commands, the_rest = extract_dsl_commands_from_erb(file_contents)
|
24
|
-
|
25
|
-
context_name = context_name.gsub('.html.erb', '')
|
26
|
-
context = Context.new(context_name)
|
27
|
-
context.virtual_path(determine_virtual_path(filename))
|
28
|
-
context.instance_eval(dsl_commands)
|
29
|
-
context.erb(the_rest)
|
30
|
-
context.create_override
|
31
|
-
elsif context_name.end_with?('.html.haml')
|
32
|
-
dsl_commands, the_rest = extract_dsl_commands_from_haml(file_contents)
|
33
|
-
|
34
|
-
context_name = context_name.gsub('.html.haml', '')
|
35
|
-
context = Context.new(context_name)
|
36
|
-
context.virtual_path(determine_virtual_path(filename))
|
37
|
-
context.instance_eval(dsl_commands)
|
38
|
-
context.haml(the_rest)
|
39
|
-
context.create_override
|
40
|
-
elsif context_name.end_with?('.html.slim')
|
41
|
-
dsl_commands, the_rest = extract_dsl_commands_from_slim(file_contents)
|
42
|
-
|
43
|
-
context_name = context_name.gsub('.html.slim', '')
|
44
|
-
context = Context.new(context_name)
|
45
|
-
context.virtual_path(determine_virtual_path(filename))
|
46
|
-
context.instance_eval(dsl_commands)
|
47
|
-
context.slim(the_rest)
|
48
|
-
context.create_override
|
49
|
-
else
|
50
|
-
context = Context.new(context_name)
|
51
|
-
context.virtual_path(determine_virtual_path(filename))
|
52
|
-
context.instance_eval(file_contents)
|
53
|
-
context.create_override
|
54
|
-
end
|
22
|
+
build_context(context_name, filename, file_contents)
|
55
23
|
end
|
56
24
|
end
|
57
25
|
|
26
|
+
def self.build_context(context_name, filename, file_contents)
|
27
|
+
send build_context_method_name(context_name), context_name, filename, file_contents
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.build_context_method_name(context_name)
|
31
|
+
ext = File.extname(context_name).gsub(".", '')
|
32
|
+
ext = "other" if ext.empty?
|
33
|
+
"build_#{ext}_context"
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.build_erb_context(context_name, filename, file_contents)
|
37
|
+
build_context_and_extract_dsl_from('erb', context_name, filename, file_contents)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.build_haml_context(context_name, filename, file_contents)
|
41
|
+
build_context_and_extract_dsl_from('haml', context_name, filename, file_contents)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.build_slim_context(context_name, filename, file_contents)
|
45
|
+
build_context_and_extract_dsl_from('slim', context_name, filename, file_contents)
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.build_context_and_extract_dsl_from(type, context_name, filename, file_contents)
|
49
|
+
dsl_commands, the_rest = send "extract_dsl_commands_from_#{type}", (file_contents)
|
50
|
+
|
51
|
+
context_name = context_name.gsub(".html.#{type}", '')
|
52
|
+
context = Context.new(context_name)
|
53
|
+
context.virtual_path(determine_virtual_path(filename))
|
54
|
+
context.instance_eval(dsl_commands)
|
55
|
+
context.send type, the_rest
|
56
|
+
context.create_override
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.build_other_context(context_name, filename, file_contents)
|
60
|
+
context = Context.new(context_name)
|
61
|
+
context.virtual_path(determine_virtual_path(filename))
|
62
|
+
context.instance_eval(file_contents)
|
63
|
+
context.create_override
|
64
|
+
end
|
65
|
+
|
58
66
|
def self.register
|
59
67
|
Polyglot.register('deface', Deface::DSL::Loader)
|
60
68
|
end
|
@@ -140,4 +148,4 @@ module Deface
|
|
140
148
|
end
|
141
149
|
end
|
142
150
|
end
|
143
|
-
end
|
151
|
+
end
|
data/lib/deface/railtie.rb
CHANGED
@@ -46,7 +46,7 @@ module Deface
|
|
46
46
|
end
|
47
47
|
|
48
48
|
railties.each do |railtie|
|
49
|
-
next unless railtie.respond_to? :
|
49
|
+
next unless railtie.respond_to?(:root) && railtie.config.respond_to?(:eager_load_paths)
|
50
50
|
railtie.config.eager_load_paths.reject! {|path| path =~ /app\/overrides\z/ }
|
51
51
|
end
|
52
52
|
end
|
@@ -70,7 +70,7 @@ module Deface
|
|
70
70
|
|
71
71
|
if defined?(Slim)
|
72
72
|
app.config.deface.slim_support = true
|
73
|
-
require '
|
73
|
+
require 'deface/slim_converter'
|
74
74
|
end
|
75
75
|
|
76
76
|
# catchs any overrides that we required manually
|
data/lib/deface/sources/copy.rb
CHANGED
@@ -7,7 +7,7 @@ module Deface
|
|
7
7
|
range = Deface::Matchers::Range.new('Copy', copy[:start], copy[:end]).matches(override.parsed_document).first
|
8
8
|
Deface::Parser.undo_erb_markup! range.map(&:to_s).join
|
9
9
|
else
|
10
|
-
|
10
|
+
Deface::Parser.undo_erb_markup! override.parsed_document.css(copy).first.to_s.clone
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
data/lib/deface/sources/slim.rb
CHANGED
@@ -3,11 +3,11 @@ module Deface
|
|
3
3
|
class Slim < Source
|
4
4
|
def self.execute(override)
|
5
5
|
if Rails.application.config.deface.slim_support
|
6
|
-
::
|
6
|
+
Deface::SlimConverter.new(override.args[:slim]).result
|
7
7
|
else
|
8
8
|
raise Deface::NotSupportedError, "`#{override.name}` supplies :slim source, but slim_support is not detected."
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
13
|
-
end
|
13
|
+
end
|
@@ -23,7 +23,7 @@ module Deface
|
|
23
23
|
if view.handler.to_s == "Haml::Plugin"
|
24
24
|
Deface::HamlConverter.new(view.source).result
|
25
25
|
elsif view.handler.class.to_s == "Slim::RailsTemplate"
|
26
|
-
|
26
|
+
Deface::SlimConverter.new(view.source).result
|
27
27
|
else
|
28
28
|
view.source
|
29
29
|
end
|
@@ -10,20 +10,20 @@ module ActionView
|
|
10
10
|
@template = ActionView::Template.new("<p>test</p>", "/some/path/to/file.erb", ActionView::Template::Handlers::ERB, {:virtual_path=>"posts/index", :format=>:html, :updated_at => @updated_at})
|
11
11
|
#stub for Rails < 3.1
|
12
12
|
unless defined?(@template.updated_at)
|
13
|
-
@template.
|
13
|
+
allow(@template).to receive(:updated_at).and_return(@updated_at)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should initialize new template object" do
|
18
|
-
@template.is_a?(ActionView::Template).
|
18
|
+
expect(@template.is_a?(ActionView::Template)).to eq(true)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should return unmodified source" do
|
22
|
-
@template.source.
|
22
|
+
expect(@template.source).to eq("<p>test</p>")
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should not change updated_at" do
|
26
|
-
@template.updated_at.
|
26
|
+
expect(@template.updated_at).to eq(@updated_at)
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
@@ -35,16 +35,16 @@ module ActionView
|
|
35
35
|
@template = ActionView::Template.new("<p>test</p><%= raw(text) %>", "/some/path/to/file.erb", ActionView::Template::Handlers::ERB, {:virtual_path=>"posts/index", :format=>:html, :updated_at => @updated_at})
|
36
36
|
#stub for Rails < 3.1
|
37
37
|
unless defined?(@template.updated_at)
|
38
|
-
@template.
|
38
|
+
allow(@template).to receive(:updated_at).and_return(@updated_at + 500)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should return modified source" do
|
43
|
-
@template.source.
|
43
|
+
expect(@template.source).to eq("<%= raw(text) %>")
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should change updated_at" do
|
47
|
-
@template.updated_at.
|
47
|
+
expect(@template.updated_at).to be > @updated_at
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -54,11 +54,11 @@ module ActionView
|
|
54
54
|
it "should return hash of overrides plus original method_name " do
|
55
55
|
deface_hash = Deface::Override.digest(:virtual_path => 'posts/index')
|
56
56
|
|
57
|
-
template.send(:method_name).
|
57
|
+
expect(template.send(:method_name)).to eq("_#{Digest::MD5.new.update("#{deface_hash}_#{template.send(:method_name_without_deface)}").hexdigest}")
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should alias original method_name method" do
|
61
|
-
template.send(:method_name_without_deface).
|
61
|
+
expect(template.send(:method_name_without_deface)).to match /\A__some_path_to_file_erb_+[0-9]+_+[0-9]+\z/
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -70,7 +70,7 @@ module ActionView
|
|
70
70
|
|
71
71
|
it "should return unmodified source" do
|
72
72
|
#if processed, source would include "=>"
|
73
|
-
@template.source.
|
73
|
+
expect(@template.source).to eq("xml.post => :blah")
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -85,9 +85,9 @@ module ActionView
|
|
85
85
|
ActionView::Template::Handlers::Builder => false }
|
86
86
|
expectations.each do |handler, expected|
|
87
87
|
@template = ActionView::Template.new("xml.post => :blah", "/some/path/to/file.erb", handler, {:virtual_path=>"posts/index", :format=>:xml, :updated_at => (Time.now - 100)})
|
88
|
-
@template.is_a?(ActionView::Template).
|
88
|
+
expect(@template.is_a?(ActionView::Template)).to eq(true)
|
89
89
|
syntax = @template.send(:determine_syntax, handler)
|
90
|
-
@template.send(:should_be_defaced?, syntax).
|
90
|
+
expect(@template.send(:should_be_defaced?, syntax)).to eq(expected), "unexpected result for handler "+handler.to_s
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
@@ -14,8 +14,8 @@ module Deface
|
|
14
14
|
it "should return modified source" do
|
15
15
|
attrs = attributes_to_sorted_array(Dummy.apply(source, {:virtual_path => "posts/index"}))
|
16
16
|
|
17
|
-
attrs["class"].value.
|
18
|
-
attrs["alt"].value.
|
17
|
+
expect(attrs["class"].value).to eq("button pretty")
|
18
|
+
expect(attrs["alt"].value).to eq("something interesting")
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -27,8 +27,8 @@ module Deface
|
|
27
27
|
it "should return modified source" do
|
28
28
|
attrs = attributes_to_sorted_array(Dummy.apply(source, {:virtual_path => "posts/index"}))
|
29
29
|
|
30
|
-
attrs["class"].value.
|
31
|
-
attrs["src"].value.
|
30
|
+
expect(attrs["class"].value).to eq("button <%= add_class %>")
|
31
|
+
expect(attrs["src"].value).to eq("path/to/button.png")
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -40,8 +40,8 @@ module Deface
|
|
40
40
|
it "should return modified source" do
|
41
41
|
attrs = attributes_to_sorted_array(Dummy.apply(source, {:virtual_path => "posts/index"}))
|
42
42
|
|
43
|
-
attrs["class"].value.
|
44
|
-
attrs["src"].value.
|
43
|
+
expect(attrs["class"].value).to eq("button <%= add_class %>")
|
44
|
+
expect(attrs["src"].value).to eq("path/to/button.png")
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -53,8 +53,8 @@ module Deface
|
|
53
53
|
it "should return modified source" do
|
54
54
|
attrs = attributes_to_sorted_array(Dummy.apply(source, {:virtual_path => "posts/index"}))
|
55
55
|
|
56
|
-
attrs["class"].value.
|
57
|
-
attrs["src"].value.
|
56
|
+
expect(attrs["class"].value).to eq("<%= get_class %> <%= get_some_other_class %>")
|
57
|
+
expect(attrs["src"].value).to eq("path/to/button.png")
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -11,7 +11,7 @@ module Deface
|
|
11
11
|
let(:source) { "<div><img class=\"button\" src=\"path/to/button.png\"></div>" }
|
12
12
|
|
13
13
|
it "should return modified source" do
|
14
|
-
Dummy.apply(source, {:virtual_path => "posts/index"}).gsub("\n", "").
|
14
|
+
expect(Dummy.apply(source, {:virtual_path => "posts/index"}).gsub("\n", "")).to eq("<div><img class=\"button\" src=\"path/to/button.png\"><% help %></div>")
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -11,7 +11,7 @@ module Deface
|
|
11
11
|
let(:source) { "<ul><li>first</li><li>second</li><li>third</li></ul>" }
|
12
12
|
|
13
13
|
it "should return modified source" do
|
14
|
-
Dummy.apply(source, {:virtual_path => "posts/index"}).gsub("\n", "").
|
14
|
+
expect(Dummy.apply(source, {:virtual_path => "posts/index"}).gsub("\n", "")).to eq("<ul><li>first</li><li>second</li><li>third</li><%= help %></ul>")
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -11,7 +11,7 @@ module Deface
|
|
11
11
|
let(:source) { "<ul><li>first</li><li>second</li><li>third</li></ul>" }
|
12
12
|
|
13
13
|
it "should return modified source" do
|
14
|
-
Dummy.apply(source, {:virtual_path => "posts/index"}).gsub("\n", "").
|
14
|
+
expect(Dummy.apply(source, {:virtual_path => "posts/index"}).gsub("\n", "")).to eq("<ul><li>first</li><li>second</li><li>third</li><li>I'm always last</li></ul>")
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -20,7 +20,7 @@ module Deface
|
|
20
20
|
let(:source) { "<ul></ul>" }
|
21
21
|
|
22
22
|
it "should return modified source" do
|
23
|
-
Dummy.apply(source, {:virtual_path => "posts/index"}).gsub("\n", "").
|
23
|
+
expect(Dummy.apply(source, {:virtual_path => "posts/index"}).gsub("\n", "")).to eq("<ul><li>I'm always last</li></ul>")
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -11,7 +11,7 @@ module Deface
|
|
11
11
|
let(:source) { "<ul><li>first</li><li>second</li><li>third</li></ul>" }
|
12
12
|
|
13
13
|
it "should return modified source" do
|
14
|
-
Dummy.apply(source, {:virtual_path => "posts/index"}).gsub("\n", "").
|
14
|
+
expect(Dummy.apply(source, {:virtual_path => "posts/index"}).gsub("\n", "")).to eq("<ul><li>me first</li><li>first</li><li>second</li><li>third</li></ul>")
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -20,7 +20,7 @@ module Deface
|
|
20
20
|
let(:source) { "<ul></ul>" }
|
21
21
|
|
22
22
|
it "should return modified source" do
|
23
|
-
Dummy.apply(source, {:virtual_path => "posts/index"}).gsub("\n", "").
|
23
|
+
expect(Dummy.apply(source, {:virtual_path => "posts/index"}).gsub("\n", "")).to eq("<ul><li>first</li><li>second</li><li>third</li></ul>")
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -14,7 +14,7 @@ module Deface
|
|
14
14
|
it "should return modified source" do
|
15
15
|
attrs = attributes_to_sorted_array(Dummy.apply(source, {:virtual_path => "posts/index"}))
|
16
16
|
|
17
|
-
attrs["class"].value.
|
17
|
+
expect(attrs["class"].value).to eq("button")
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -26,8 +26,8 @@ module Deface
|
|
26
26
|
it "should return modified source" do
|
27
27
|
attrs = attributes_to_sorted_array(Dummy.apply(source, {:virtual_path => "posts/index"}))
|
28
28
|
|
29
|
-
attrs["class"].value.
|
30
|
-
attrs["src"].value.
|
29
|
+
expect(attrs["class"].value).to eq("button")
|
30
|
+
expect(attrs["src"].value).to eq("path/to/button.png")
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -39,8 +39,8 @@ module Deface
|
|
39
39
|
it "should return modified source" do
|
40
40
|
attrs = attributes_to_sorted_array(Dummy.apply(source, {:virtual_path => "posts/index"}))
|
41
41
|
|
42
|
-
attrs["class"].value.
|
43
|
-
attrs["src"].value.
|
42
|
+
expect(attrs["class"].value).to eq("button")
|
43
|
+
expect(attrs["src"].value).to eq("path/to/button.png")
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -50,7 +50,7 @@ module Deface
|
|
50
50
|
let(:source) { "<img class=\"button\" src=\"path/to/button.png\">" }
|
51
51
|
|
52
52
|
it "should return unmodified source" do
|
53
|
-
Dummy.apply(source, {:virtual_path => "posts/index"}).
|
53
|
+
expect(Dummy.apply(source, {:virtual_path => "posts/index"})).to eq("<img class=\"button\" src=\"path/to/button.png\">")
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -60,7 +60,7 @@ module Deface
|
|
60
60
|
let(:source) { "<img src=\"path/to/button.png\">" }
|
61
61
|
|
62
62
|
it "should return unmodified source" do
|
63
|
-
Dummy.apply(source, {:virtual_path => "posts/index"}).
|
63
|
+
expect(Dummy.apply(source, {:virtual_path => "posts/index"})).to eq("<img src=\"path/to/button.png\">")
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -72,8 +72,8 @@ module Deface
|
|
72
72
|
it "should return modified source" do
|
73
73
|
attrs = attributes_to_sorted_array(Dummy.apply(source, {:virtual_path => "posts/index"}))
|
74
74
|
|
75
|
-
attrs["class"].value.
|
76
|
-
attrs["src"].value.
|
75
|
+
expect(attrs["class"].value).to eq("<%= get_class %>")
|
76
|
+
expect(attrs["src"].value).to eq("path/to/button.png")
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|