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)


47
48
49
50
# File 'lib/super_diff/rspec.rb', line 47

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)


33
34
35
36
# File 'lib/super_diff/rspec.rb', line 33

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
# 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)


52
53
54
55
# File 'lib/super_diff/rspec.rb', line 52

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)


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

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)


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

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)


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

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)


38
39
40
# File 'lib/super_diff/rspec.rb', line 38

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)


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

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)


29
30
31
# File 'lib/super_diff/rspec.rb', line 29

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)


70
71
72
# File 'lib/super_diff/rspec.rb', line 70

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)


59
60
61
# File 'lib/super_diff/rspec.rb', line 59

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

.rspec_versionObject



83
84
85
86
87
88
89
# File 'lib/super_diff/rspec.rb', line 83

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