Module: SuperDiff::RSpec

Defined in:
lib/super_diff/rspec.rb,
lib/super_diff/rspec/differ.rb,
lib/super_diff/rspec/differs.rb,
lib/super_diff/rspec/augmented_matcher.rb,
lib/super_diff/rspec/object_inspection.rb,
lib/super_diff/rspec/matcher_text_builders.rb,
lib/super_diff/rspec/matcher_text_template.rb,
lib/super_diff/rspec/differs/hash_including.rb,
lib/super_diff/rspec/operation_tree_builders.rb,
lib/super_diff/rspec/matcher_text_builders/base.rb,
lib/super_diff/rspec/matcher_text_builders/match.rb,
lib/super_diff/rspec/differs/collection_including.rb,
lib/super_diff/rspec/differs/object_having_attributes.rb,
lib/super_diff/rspec/matcher_text_builders/respond_to.rb,
lib/super_diff/rspec/matcher_text_builders/raise_error.rb,
lib/super_diff/rspec/matcher_text_builders/be_predicate.rb,
lib/super_diff/rspec/matcher_text_builders/have_predicate.rb,
lib/super_diff/rspec/differs/collection_containing_exactly.rb,
lib/super_diff/rspec/matcher_text_builders/contain_exactly.rb,
lib/super_diff/rspec/operation_tree_builders/hash_including.rb,
lib/super_diff/rspec/object_inspection/inspection_tree_builders.rb,
lib/super_diff/rspec/operation_tree_builders/collection_including.rb,
lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb,
lib/super_diff/rspec/object_inspection/inspection_tree_builders/double.rb,
lib/super_diff/rspec/object_inspection/inspection_tree_builders/kind_of.rb,
lib/super_diff/rspec/object_inspection/inspection_tree_builders/primitive.rb,
lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb,
lib/super_diff/rspec/object_inspection/inspection_tree_builders/instance_of.rb,
lib/super_diff/rspec/object_inspection/inspection_tree_builders/value_within.rb,
lib/super_diff/rspec/object_inspection/inspection_tree_builders/hash_including.rb,
lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_including.rb,
lib/super_diff/rspec/object_inspection/inspection_tree_builders/object_having_attributes.rb,
lib/super_diff/rspec/object_inspection/inspection_tree_builders/collection_containing_exactly.rb

Defined Under Namespace

Modules: AugmentedMatcher, Differs, MatcherTextBuilders, ObjectInspection, OperationTreeBuilders Classes: Differ, MatcherTextTemplate

Class Method Summary collapse

Class Method Details

.a_collection_containing_exactly_something?(value) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
53
# File 'lib/super_diff/rspec.rb', line 50

def self.a_collection_containing_exactly_something?(value)
  fuzzy_object?(value) &&
    value.base_matcher.is_a?(::RSpec::Matchers::BuiltIn::ContainExactly)
end

.a_collection_including_something?(value) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
38
39
# File 'lib/super_diff/rspec.rb', line 35

def self.a_collection_including_something?(value)
  fuzzy_object?(value) &&
    value.respond_to?(:expecteds) &&
    !(value.expecteds.one? && value.expecteds.first.is_a?(::Hash))
end

.a_hash_including_something?(value) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
# File 'lib/super_diff/rspec.rb', line 22

def self.a_hash_including_something?(value)
  fuzzy_object?(value) &&
    value.respond_to?(:expecteds) &&
    value.expecteds.one? &&
    value.expecteds.first.is_a?(::Hash)
end

.a_kind_of_something?(value) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
58
# File 'lib/super_diff/rspec.rb', line 55

def self.a_kind_of_something?(value)
  fuzzy_object?(value) &&
    value.base_matcher.is_a?(::RSpec::Matchers::BuiltIn::BeAKindOf)
end

.a_value_within_something?(value) ⇒ Boolean

Returns:

  • (Boolean)


77
78
79
80
# File 'lib/super_diff/rspec.rb', line 77

def self.a_value_within_something?(value)
  fuzzy_object?(value) &&
    value.base_matcher.is_a?(::RSpec::Matchers::BuiltIn::BeWithin)
end

.an_instance_of_something?(value) ⇒ Boolean

Returns:

  • (Boolean)


66
67
68
69
# File 'lib/super_diff/rspec.rb', line 66

def self.an_instance_of_something?(value)
  fuzzy_object?(value) &&
    value.base_matcher.is_a?(::RSpec::Matchers::BuiltIn::BeAnInstanceOf)
end

.an_object_having_some_attributes?(value) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
48
# File 'lib/super_diff/rspec.rb', line 45

def self.an_object_having_some_attributes?(value)
  fuzzy_object?(value) &&
    value.base_matcher.is_a?(::RSpec::Matchers::BuiltIn::HaveAttributes)
end

.array_including_something?(value) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/super_diff/rspec.rb', line 41

def self.array_including_something?(value)
  value.is_a?(::RSpec::Mocks::ArgumentMatchers::ArrayIncludingMatcher)
end

.configurationObject



18
19
20
# File 'lib/super_diff/rspec.rb', line 18

def self.configuration
  SuperDiff.configuration
end

.configure(&block) ⇒ Object



14
15
16
# File 'lib/super_diff/rspec.rb', line 14

def self.configure(&block)
  SuperDiff.configure(&block)
end

.fuzzy_object?(value) ⇒ Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/super_diff/rspec.rb', line 82

def self.fuzzy_object?(value)
  value.is_a?(::RSpec::Matchers::AliasedMatcher)
end

.hash_including_something?(value) ⇒ Boolean

HINT: ‘a_hash_including` is an alias of `include` in the rspec-expectations gem.

`hash_including` is an argument matcher in the rspec-mocks gem.

Returns:

  • (Boolean)


31
32
33
# File 'lib/super_diff/rspec.rb', line 31

def self.hash_including_something?(value)
  value.is_a?(::RSpec::Mocks::ArgumentMatchers::HashIncludingMatcher)
end

.instance_of_something?(value) ⇒ Boolean

HINT: ‘an_instance_of` is a matcher in the rspec-expectations gem.

`instance_of` is an argument matcher in the rspec-mocks gem.

Returns:

  • (Boolean)


73
74
75
# File 'lib/super_diff/rspec.rb', line 73

def self.instance_of_something?(value)
  value.is_a?(::RSpec::Mocks::ArgumentMatchers::InstanceOf)
end

.kind_of_something?(value) ⇒ Boolean

HINT: ‘a_kind_of` is a matcher in the rspec-expectations gem.

`kind_of` is an argument matcher in the rspec-mocks gem.

Returns:

  • (Boolean)


62
63
64
# File 'lib/super_diff/rspec.rb', line 62

def self.kind_of_something?(value)
  value.is_a?(::RSpec::Mocks::ArgumentMatchers::KindOf)
end

.rspec_versionObject



86
87
88
89
90
91
# File 'lib/super_diff/rspec.rb', line 86

def self.rspec_version
  @_rspec_version ||= begin
    require "rspec/core/version"
    GemVersion.new(::RSpec::Core::Version::STRING)
  end
end