page_magic 1.2.7 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +23 -4
  3. data/.simplecov +5 -3
  4. data/.zsh_config +6 -0
  5. data/Dockerfile +11 -0
  6. data/Gemfile +13 -13
  7. data/Gemfile.lock +135 -144
  8. data/Makefile +17 -0
  9. data/README.md +48 -4
  10. data/Rakefile +12 -2
  11. data/VERSION +1 -1
  12. data/circle.yml +4 -2
  13. data/lib/active_support/core_ext/object/to_query.rb +84 -0
  14. data/lib/page_magic.rb +22 -20
  15. data/lib/page_magic/class_methods.rb +5 -2
  16. data/lib/page_magic/comparator.rb +37 -0
  17. data/lib/page_magic/comparator/fuzzy.rb +23 -0
  18. data/lib/page_magic/comparator/literal.rb +22 -0
  19. data/lib/page_magic/comparator/null.rb +26 -0
  20. data/lib/page_magic/comparator/parameter_map.rb +52 -0
  21. data/lib/page_magic/driver.rb +3 -0
  22. data/lib/page_magic/drivers.rb +6 -5
  23. data/lib/page_magic/drivers/poltergeist.rb +2 -0
  24. data/lib/page_magic/drivers/rack_test.rb +3 -1
  25. data/lib/page_magic/drivers/selenium.rb +4 -2
  26. data/lib/page_magic/element.rb +35 -15
  27. data/lib/page_magic/element/locators.rb +8 -5
  28. data/lib/page_magic/element/not_found.rb +38 -0
  29. data/lib/page_magic/element/query.rb +21 -20
  30. data/lib/page_magic/element/query/multiple_results.rb +21 -0
  31. data/lib/page_magic/element/query/prefetched_result.rb +26 -0
  32. data/lib/page_magic/element/query/single_result.rb +20 -0
  33. data/lib/page_magic/element/selector.rb +41 -16
  34. data/lib/page_magic/element/selector/methods.rb +18 -0
  35. data/lib/page_magic/element/selector/model.rb +21 -0
  36. data/lib/page_magic/element_context.rb +7 -21
  37. data/lib/page_magic/element_definition_builder.rb +20 -24
  38. data/lib/page_magic/elements.rb +65 -68
  39. data/lib/page_magic/elements/config.rb +103 -0
  40. data/lib/page_magic/elements/inheritance_hooks.rb +15 -0
  41. data/lib/page_magic/elements/types.rb +25 -0
  42. data/lib/page_magic/exceptions.rb +6 -1
  43. data/lib/page_magic/instance_methods.rb +8 -3
  44. data/lib/page_magic/mapping.rb +79 -0
  45. data/lib/page_magic/session.rb +15 -35
  46. data/lib/page_magic/session_methods.rb +3 -1
  47. data/lib/page_magic/transitions.rb +49 -0
  48. data/lib/page_magic/utils/string.rb +18 -0
  49. data/lib/page_magic/utils/url.rb +20 -0
  50. data/lib/page_magic/wait_methods.rb +3 -0
  51. data/lib/page_magic/watcher.rb +12 -17
  52. data/lib/page_magic/watchers.rb +31 -15
  53. data/page_magic.gemspec +17 -13
  54. data/spec/lib/active_support/core_ext/object/to_query_test.rb +78 -0
  55. data/spec/page_magic/class_methods_spec.rb +66 -37
  56. data/spec/page_magic/comparator/fuzzy_spec.rb +44 -0
  57. data/spec/page_magic/comparator/literal_spec.rb +41 -0
  58. data/spec/page_magic/comparator/null_spec.rb +35 -0
  59. data/spec/page_magic/comparator/parameter_map_spec.rb +75 -0
  60. data/spec/page_magic/driver_spec.rb +26 -28
  61. data/spec/page_magic/drivers/poltergeist_spec.rb +6 -7
  62. data/spec/page_magic/drivers/rack_test_spec.rb +6 -9
  63. data/spec/page_magic/drivers/selenium_spec.rb +11 -12
  64. data/spec/page_magic/drivers_spec.rb +38 -29
  65. data/spec/page_magic/element/locators_spec.rb +28 -25
  66. data/spec/page_magic/element/not_found_spec.rb +24 -0
  67. data/spec/page_magic/element/query/multiple_results_spec.rb +14 -0
  68. data/spec/page_magic/element/query/single_result_spec.rb +21 -0
  69. data/spec/page_magic/element/query_spec.rb +26 -45
  70. data/spec/page_magic/element/selector_spec.rb +120 -110
  71. data/spec/page_magic/element_context_spec.rb +47 -87
  72. data/spec/page_magic/element_definition_builder_spec.rb +14 -71
  73. data/spec/page_magic/element_spec.rb +256 -0
  74. data/spec/page_magic/elements/config_spec.rb +200 -0
  75. data/spec/page_magic/elements_spec.rb +90 -127
  76. data/spec/page_magic/instance_methods_spec.rb +65 -63
  77. data/spec/page_magic/mapping_spec.rb +181 -0
  78. data/spec/page_magic/session_methods_spec.rb +29 -25
  79. data/spec/page_magic/session_spec.rb +109 -199
  80. data/spec/page_magic/transitions_spec.rb +43 -0
  81. data/spec/page_magic/utils/string_spec.rb +29 -0
  82. data/spec/page_magic/utils/url_spec.rb +9 -0
  83. data/spec/page_magic/wait_methods_spec.rb +16 -22
  84. data/spec/page_magic/watcher_spec.rb +22 -0
  85. data/spec/page_magic/watchers_spec.rb +58 -62
  86. data/spec/page_magic_spec.rb +31 -30
  87. data/spec/spec_helper.rb +9 -2
  88. data/spec/support/shared_contexts.rb +3 -1
  89. data/spec/support/shared_examples.rb +17 -17
  90. metadata +101 -48
  91. data/lib/page_magic/element/query_builder.rb +0 -48
  92. data/lib/page_magic/element/selector_methods.rb +0 -13
  93. data/lib/page_magic/matcher.rb +0 -121
  94. data/spec/element_spec.rb +0 -249
  95. data/spec/page_magic/element/query_builder_spec.rb +0 -108
  96. data/spec/page_magic/matcher_spec.rb +0 -336
  97. data/spec/support/shared_contexts/files_context.rb +0 -7
  98. data/spec/support/shared_contexts/nested_elements_html_context.rb +0 -16
  99. data/spec/support/shared_contexts/rack_application_context.rb +0 -9
  100. data/spec/support/shared_contexts/webapp_fixture_context.rb +0 -39
  101. data/spec/watcher_spec.rb +0 -61
@@ -1,32 +1,37 @@
1
- require 'page_magic/watcher'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'watcher'
2
4
 
3
5
  module PageMagic
4
6
  # module Watchers - contains methods for adding watchers and checking them
5
7
  module Watchers
6
- ELEMENT_MISSING_MSG = 'Unable to defined watcher: Element or method with the name %s can not be found'.freeze
8
+ ELEMENT_MISSING_MSG = 'Unable to defined watcher: Element or method with the name %s can not be found'
7
9
 
8
10
  # @param [Symbol] name - the name of the watcher
9
11
  # @return [Boolean] true if a change is detected
10
12
  def changed?(name)
11
13
  watched_element = watcher(name)
12
- watched_element.last != watched_element.check(self).last
14
+ watched_element.observed_value != watched_element.check.observed_value
13
15
  end
14
16
 
15
17
  # register a new watcher
16
- # @param [Object] name of the watcher/element
17
- # @param [Symbol] method - the method on the watched element to check
18
- # @yieldreturn [Object] the value that should be checked
19
- # @example
20
- # watch(:price, :text)
21
- # @example
22
- # watch(:something) do
18
+ # @overload watch(:price, context: object, method: :text)
19
+ # @param [Symbol] name of the watcher/element
20
+ # @param [Object] context the object that is being watched - defaults to self
21
+ # @param [Symbol] method - the method on the watched element to check
22
+ # @overload watch(:text)
23
+ # @param [Symbol] method - the method on the watched element to check
24
+ # @overload watch(:text, &blk)
25
+ # @param [Symbol] name of the watcher/element
26
+ # @yieldreturn [Object] the value that should be checked
27
+ # @example
28
+ # watch(:something) do
23
29
  # # more complicated code to get value
24
- # end
25
- def watch(name, method = nil, &block)
26
- raise ElementMissingException, (ELEMENT_MISSING_MSG % name) unless block || respond_to?(name)
27
- watched_element = block ? Watcher.new(name, &block) : Watcher.new(name, method)
30
+ # end
31
+ def watch(name, context: self, method: nil, &blk)
32
+ watcher = blk ? Watcher.new(name, context: context, &blk) : watch_method(name, context: context, method: method)
28
33
  watchers.delete_if { |w| w.name == name }
29
- watchers << watched_element.check(self)
34
+ watchers << watcher.check
30
35
  end
31
36
 
32
37
  # retrieve a watcher given its name
@@ -40,5 +45,16 @@ module PageMagic
40
45
  def watchers
41
46
  @watchers ||= []
42
47
  end
48
+
49
+ private
50
+
51
+ def watch_method(name, context:, method:)
52
+ subject = method || name
53
+ raise ElementMissingException, (ELEMENT_MISSING_MSG % subject) unless context.respond_to?(subject)
54
+
55
+ Watcher.new(name, context: context) do
56
+ public_send(subject)
57
+ end
58
+ end
43
59
  end
44
60
  end
data/page_magic.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: page_magic 1.2.7 ruby lib
5
+ # stub: page_magic 1.2.9 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "page_magic"
9
- s.version = "1.2.7"
9
+ s.version = "1.2.9"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Leon Davis"]
14
- s.date = "2017-02-17"
14
+ s.date = "2017-10-03"
15
15
  s.description = "Framework for modeling and interacting with webpages which wraps capybara"
16
16
  s.email = "info@lad-tech.com"
17
17
  s.extra_rdoc_files = [
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
30
30
  "Rakefile",
31
31
  "VERSION",
32
32
  "circle.yml",
33
+ "lib/active_support/core_ext/object/to_query.rb",
33
34
  "lib/page_magic.rb",
34
35
  "lib/page_magic/class_methods.rb",
35
36
  "lib/page_magic/driver.rb",
@@ -51,11 +52,13 @@ Gem::Specification.new do |s|
51
52
  "lib/page_magic/matcher.rb",
52
53
  "lib/page_magic/session.rb",
53
54
  "lib/page_magic/session_methods.rb",
55
+ "lib/page_magic/utils/string.rb",
54
56
  "lib/page_magic/wait_methods.rb",
55
57
  "lib/page_magic/watcher.rb",
56
58
  "lib/page_magic/watchers.rb",
57
59
  "page_magic.gemspec",
58
60
  "spec/element_spec.rb",
61
+ "spec/lib/active_support/core_ext/object/to_query_test.rb",
59
62
  "spec/page_magic/class_methods_spec.rb",
60
63
  "spec/page_magic/driver_spec.rb",
61
64
  "spec/page_magic/drivers/poltergeist_spec.rb",
@@ -73,6 +76,7 @@ Gem::Specification.new do |s|
73
76
  "spec/page_magic/matcher_spec.rb",
74
77
  "spec/page_magic/session_methods_spec.rb",
75
78
  "spec/page_magic/session_spec.rb",
79
+ "spec/page_magic/utils/string_spec.rb",
76
80
  "spec/page_magic/wait_methods_spec.rb",
77
81
  "spec/page_magic/watchers_spec.rb",
78
82
  "spec/page_magic_spec.rb",
@@ -88,37 +92,37 @@ Gem::Specification.new do |s|
88
92
  s.homepage = "https://github.com/ladtech/page_magic"
89
93
  s.licenses = ["ruby"]
90
94
  s.required_ruby_version = Gem::Requirement.new(">= 2.1")
91
- s.rubygems_version = "2.4.8"
95
+ s.rubygems_version = "2.4.6"
92
96
  s.summary = "Framework for modeling and interacting with webpages"
93
97
 
94
98
  if s.respond_to? :specification_version then
95
99
  s.specification_version = 4
96
100
 
97
101
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
102
+ s.add_runtime_dependency(%q<activesupport-inflector>, [">= 0"])
98
103
  s.add_runtime_dependency(%q<capybara>, [">= 2.5"])
99
- s.add_runtime_dependency(%q<activesupport>, ["~> 4"])
104
+ s.add_development_dependency(%q<github-markup>, ["~> 1.4"])
100
105
  s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
106
+ s.add_development_dependency(%q<redcarpet>, ["~> 3.3"])
101
107
  s.add_development_dependency(%q<rubocop>, ["~> 0.34"])
102
108
  s.add_development_dependency(%q<yard>, ["~> 0.8"])
103
- s.add_development_dependency(%q<redcarpet>, ["~> 3.3"])
104
- s.add_development_dependency(%q<github-markup>, ["~> 1.4"])
105
109
  else
110
+ s.add_dependency(%q<activesupport-inflector>, [">= 0"])
106
111
  s.add_dependency(%q<capybara>, [">= 2.5"])
107
- s.add_dependency(%q<activesupport>, ["~> 4"])
112
+ s.add_dependency(%q<github-markup>, ["~> 1.4"])
108
113
  s.add_dependency(%q<jeweler>, ["~> 2.0"])
114
+ s.add_dependency(%q<redcarpet>, ["~> 3.3"])
109
115
  s.add_dependency(%q<rubocop>, ["~> 0.34"])
110
116
  s.add_dependency(%q<yard>, ["~> 0.8"])
111
- s.add_dependency(%q<redcarpet>, ["~> 3.3"])
112
- s.add_dependency(%q<github-markup>, ["~> 1.4"])
113
117
  end
114
118
  else
119
+ s.add_dependency(%q<activesupport-inflector>, [">= 0"])
115
120
  s.add_dependency(%q<capybara>, [">= 2.5"])
116
- s.add_dependency(%q<activesupport>, ["~> 4"])
121
+ s.add_dependency(%q<github-markup>, ["~> 1.4"])
117
122
  s.add_dependency(%q<jeweler>, ["~> 2.0"])
123
+ s.add_dependency(%q<redcarpet>, ["~> 3.3"])
118
124
  s.add_dependency(%q<rubocop>, ["~> 0.34"])
119
125
  s.add_dependency(%q<yard>, ["~> 0.8"])
120
- s.add_dependency(%q<redcarpet>, ["~> 3.3"])
121
- s.add_dependency(%q<github-markup>, ["~> 1.4"])
122
126
  end
123
127
  end
124
128
 
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'minitest'
4
+ Minitest.autorun
5
+ require 'active_support/core_ext/object/to_query'
6
+
7
+ class ToQueryTest < ::Minitest::Test
8
+ def test_simple_conversion
9
+ assert_query_equal 'a=10', a: 10
10
+ end
11
+
12
+ def test_cgi_escaping
13
+ assert_query_equal 'a%3Ab=c+d', 'a:b' => 'c d'
14
+ end
15
+
16
+ def test_nil_parameter_value
17
+ empty = Object.new
18
+ def empty.to_param
19
+ nil
20
+ end
21
+ assert_query_equal 'a=', 'a' => empty
22
+ end
23
+
24
+ def test_nested_conversion
25
+ assert_query_equal 'person%5Blogin%5D=seckar&person%5Bname%5D=Nicholas',
26
+ person: Hash[:login, 'seckar', :name, 'Nicholas']
27
+ end
28
+
29
+ def test_multiple_nested
30
+ assert_query_equal 'account%5Bperson%5D%5Bid%5D=20&person%5Bid%5D=10',
31
+ Hash[:account, { person: { id: 20 } }, :person, { id: 10 }]
32
+ end
33
+
34
+ def test_array_values
35
+ assert_query_equal 'person%5Bid%5D%5B%5D=10&person%5Bid%5D%5B%5D=20',
36
+ person: { id: [10, 20] }
37
+ end
38
+
39
+ def test_array_values_are_not_sorted
40
+ assert_query_equal 'person%5Bid%5D%5B%5D=20&person%5Bid%5D%5B%5D=10',
41
+ person: { id: [20, 10] }
42
+ end
43
+
44
+ def test_empty_array
45
+ assert_equal 'person%5B%5D=', [].to_query('person')
46
+ end
47
+
48
+ def test_nested_empty_hash
49
+ assert_equal '',
50
+ {}.to_query
51
+ assert_query_equal 'a=1&b%5Bc%5D=3',
52
+ a: 1, b: { c: 3, d: {} }
53
+ assert_query_equal '',
54
+ a: { b: { c: {} } }
55
+ assert_query_equal 'b%5Bc%5D=false&b%5Be%5D=&b%5Bf%5D=&p=12',
56
+ p: 12, b: { c: false, e: nil, f: '' }
57
+ assert_query_equal 'b%5Bc%5D=3&b%5Bf%5D=',
58
+ b: { c: 3, k: {}, f: '' }
59
+ assert_query_equal 'b=3',
60
+ a: [], b: 3
61
+ end
62
+
63
+ def test_hash_with_namespace
64
+ hash = { name: 'Nakshay', nationality: 'Indian' }
65
+ assert_equal 'user%5Bname%5D=Nakshay&user%5Bnationality%5D=Indian', hash.to_query('user')
66
+ end
67
+
68
+ def test_hash_sorted_lexicographically
69
+ hash = { type: 'human', name: 'Nakshay' }
70
+ assert_equal 'name=Nakshay&type=human', hash.to_query
71
+ end
72
+
73
+ private
74
+
75
+ def assert_query_equal(expected, actual)
76
+ assert_equal expected.split('&'), actual.to_query.split('&')
77
+ end
78
+ end
@@ -1,63 +1,92 @@
1
- module PageMagic
2
- describe ClassMethods do
3
- subject do
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe PageMagic::ClassMethods do
4
+ describe '#load' do
5
+ subject(:page_class) do
4
6
  Class.new.tap do |clazz|
5
7
  clazz.extend(described_class)
6
- clazz.include(InstanceMethods)
8
+ clazz.include(PageMagic::InstanceMethods)
7
9
  end
8
10
  end
9
11
 
10
- describe '#load' do
11
- let(:page_title) { 'page title' }
12
- let(:page_source) do
13
- <<-HTML
12
+ let(:page_title) { 'page title' }
13
+ let(:page_source) do
14
+ <<-HTML
14
15
  <html>
15
16
  <head><title>#{page_title}</title></head>
16
17
  </html>
17
- HTML
18
- end
18
+ HTML
19
+ end
19
20
 
20
- it 'returns an instance using that source' do
21
- expect(subject.load(page_source).title).to eq(page_title)
21
+ it 'returns an instance using that source' do
22
+ expect(page_class.load(page_source).title).to eq(page_title)
23
+ end
24
+ end
25
+
26
+ describe 'on_load' do
27
+ subject(:page_class) do
28
+ Class.new.tap do |clazz|
29
+ clazz.extend(described_class)
22
30
  end
23
31
  end
24
32
 
25
- describe 'on_load' do
26
- context 'block not set' do
27
- it 'returns a default block' do
28
- expect(subject.on_load).to be(described_class::DEFAULT_ON_LOAD)
29
- end
33
+ context 'when a block is not set' do
34
+ it 'returns a default block' do
35
+ expect(page_class.on_load).to be(described_class::DEFAULT_ON_LOAD)
30
36
  end
37
+ end
31
38
 
32
- context 'block set' do
33
- it 'returns that block' do
34
- expected_block = proc {}
35
- subject.on_load(&expected_block)
36
- expect(subject.on_load).to be(expected_block)
37
- end
39
+ context 'when a block is set' do
40
+ it 'returns that block' do
41
+ expected_block = proc {}
42
+ page_class.on_load(&expected_block)
43
+ expect(page_class.on_load).to be(expected_block)
38
44
  end
39
45
  end
46
+ end
40
47
 
41
- describe '#url' do
42
- it 'get/sets a value' do
43
- subject.url(:url)
44
- expect(subject.url).to eq(:url)
48
+ describe '#url' do
49
+ subject(:page_class) do
50
+ Class.new.tap do |clazz|
51
+ clazz.extend(described_class)
45
52
  end
46
53
  end
47
54
 
48
- describe '#visit' do
49
- include_context :webapp_fixture
50
- it 'passes all options to create an active session on the registered url' do
51
- subject.url '/page1'
52
- expect(PageMagic).to receive(:session).with(application: rack_app,
53
- options: {},
54
- browser: :rack_test,
55
- url: subject.url).and_call_original
55
+ it 'get/sets a value' do
56
+ page_class.url(:url)
57
+ expect(page_class.url).to eq(:url)
58
+ end
59
+ end
56
60
 
57
- session = subject.visit(application: rack_app, options: {}, browser: :rack_test)
61
+ describe '#visit' do
62
+ subject(:page_class) do
63
+ Class.new.tap do |clazz|
64
+ clazz.extend(described_class)
65
+ clazz.include(PageMagic::InstanceMethods)
66
+ clazz.url ''
67
+ end
68
+ end
58
69
 
59
- expect(session.title).to eq('page1')
70
+ let(:rack_app) do
71
+ Class.new do
72
+ def self.call(_env)
73
+ [200, {}, ['<html><head><title>page1</title></head></html>']]
74
+ end
60
75
  end
61
76
  end
77
+
78
+ it 'passes all options to create an active session on the registered url' do
79
+ allow(PageMagic).to receive(:session).and_call_original
80
+
81
+ page_class.visit(application: rack_app, options: {}, browser: :rack_test)
82
+
83
+ expected_option = { application: rack_app, options: {}, browser: :rack_test, url: page_class.url }
84
+ expect(PageMagic).to have_received(:session).with(expected_option)
85
+ end
86
+
87
+ it 'returns a session' do
88
+ session = page_class.visit(application: rack_app, options: {}, browser: :rack_test)
89
+ expect(session).to be_kind_of(PageMagic::Session)
90
+ end
62
91
  end
63
92
  end
@@ -0,0 +1,44 @@
1
+ RSpec.describe PageMagic::Comparator::Fuzzy do
2
+ describe '#fuzzy?' do
3
+ context 'when one value is fuzzy' do
4
+ it 'returns true' do
5
+ map = described_class.new(//)
6
+ expect(map).to be_fuzzy
7
+ end
8
+ end
9
+ end
10
+
11
+ describe 'match?' do
12
+ context 'when comparator contains the parameter' do
13
+ it 'returns true' do
14
+ expect(described_class.new(/f*o/)).to be_match('foo')
15
+ end
16
+ end
17
+
18
+ context 'when comparator does not contains the parameter' do
19
+ it 'returns false' do
20
+ expect(described_class.new(/f*o/)).not_to be_match('bar')
21
+ end
22
+ end
23
+ end
24
+
25
+ describe '#<=>' do
26
+ context 'when other is `Null`' do
27
+ it 'is lesser' do
28
+ expect(described_class.new(//) <=> PageMagic::Comparator::Null.new).to be(-1)
29
+ end
30
+ end
31
+
32
+ context 'when other is `Fuzzy`' do
33
+ it 'is equal' do
34
+ expect(described_class.new(//) <=> described_class.new(//)).to be 0
35
+ end
36
+ end
37
+
38
+ context 'when other is `Literal`' do
39
+ it 'is greater' do
40
+ expect(described_class.new(//) <=> PageMagic::Comparator::Literal.new('/')).to be 1
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,41 @@
1
+ RSpec.describe PageMagic::Comparator::Literal do
2
+ describe 'match?' do
3
+ context 'when parameter is the same' do
4
+ it 'returns true' do
5
+ expect(described_class.new('/')).to be_match('/')
6
+ end
7
+ end
8
+
9
+ context 'when it parameter is not the same' do
10
+ it 'returns false' do
11
+ expect(described_class.new('/')).not_to be_match('foo')
12
+ end
13
+ end
14
+ end
15
+
16
+ describe '#fuzzy?' do
17
+ it 'returns false' do
18
+ expect(described_class.new('value')).not_to be_fuzzy
19
+ end
20
+ end
21
+
22
+ describe '#<=>' do
23
+ context 'when other is `Null`' do
24
+ it 'is greater' do
25
+ expect(described_class.new('/') <=> PageMagic::Comparator::Null.new).to be 1
26
+ end
27
+ end
28
+
29
+ context 'when other is `Fuzzy`' do
30
+ it 'is greater' do
31
+ expect(described_class.new('/') <=> PageMagic::Comparator::Fuzzy.new(//)).to be 1
32
+ end
33
+ end
34
+
35
+ context 'when other is `Literal`' do
36
+ it 'is equal' do
37
+ expect(described_class.new('/') <=> described_class.new('/')).to be 0
38
+ end
39
+ end
40
+ end
41
+ end