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/inspection_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/inspection_tree_builders/double.rb,
lib/super_diff/rspec/differs/object_having_attributes.rb,
lib/super_diff/rspec/inspection_tree_builders/kind_of.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/inspection_tree_builders/primitive.rb,
lib/super_diff/rspec/matcher_text_builders/be_predicate.rb,
lib/super_diff/rspec/inspection_tree_builders/instance_of.rb,
lib/super_diff/rspec/matcher_text_builders/have_predicate.rb,
lib/super_diff/rspec/differs/collection_containing_exactly.rb,
lib/super_diff/rspec/inspection_tree_builders/value_within.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/inspection_tree_builders/hash_including.rb,
lib/super_diff/rspec/operation_tree_builders/collection_including.rb,
lib/super_diff/rspec/inspection_tree_builders/collection_including.rb,
lib/super_diff/rspec/operation_tree_builders/object_having_attributes.rb,
lib/super_diff/rspec/inspection_tree_builders/object_having_attributes.rb,
lib/super_diff/rspec/inspection_tree_builders/generic_describable_matcher.rb,
lib/super_diff/rspec/operation_tree_builders/collection_containing_exactly.rb,
lib/super_diff/rspec/inspection_tree_builders/collection_containing_exactly.rb

Defined Under Namespace

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

Class Method Summary collapse

Class Method Details

.a_collection_containing_exactly_something?(value) ⇒ Boolean

Returns:

  • (Boolean)


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

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

.a_collection_including_something?(value) ⇒ Boolean

Returns:

  • (Boolean)


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

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

.a_hash_including_something?(value) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
# File 'lib/super_diff/rspec.rb', line 26

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

.a_kind_of_something?(value) ⇒ Boolean

Returns:

  • (Boolean)


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

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

.a_value_within_something?(value) ⇒ Boolean

Returns:

  • (Boolean)


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

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

.aliased_matcher?(value) ⇒ Boolean

Returns:

  • (Boolean)


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

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

.an_instance_of_something?(value) ⇒ Boolean

Returns:

  • (Boolean)


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

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

.an_object_having_some_attributes?(value) ⇒ Boolean

Returns:

  • (Boolean)


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

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

.array_including_something?(value) ⇒ Boolean

Returns:

  • (Boolean)


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

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

.configurationObject



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

def self.configuration
  SuperDiff.configuration
end

.configure(&block) ⇒ Object



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

def self.configure(&block)
  SuperDiff.configure(&block)
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)


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

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)


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

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)


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

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

.rspec_versionObject



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

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