Module: Sinclair::Matchers

Defined in:
lib/sinclair/matchers.rb,
lib/sinclair/matchers/base.rb,
lib/sinclair/matchers/method_to.rb,
lib/sinclair/matchers/add_method.rb,
lib/sinclair/matchers/add_method_to.rb,
lib/sinclair/matchers/add_class_method.rb,
lib/sinclair/matchers/change_method_on.rb,
lib/sinclair/matchers/add_class_method_to.rb,
lib/sinclair/matchers/add_instance_method.rb,
lib/sinclair/matchers/change_class_method.rb,
lib/sinclair/matchers/add_instance_method_to.rb,
lib/sinclair/matchers/change_class_method_on.rb,
lib/sinclair/matchers/change_instance_method.rb,
lib/sinclair/matchers/change_instance_method_on.rb

Overview

Matchers module will have the DSL to be included in RSpec in order to have access to the matchers

Examples:

RSpec.configure do |config|
  config.include Sinclair::Matchers
end

class MyModel
end

RSpec.describe 'my test' do
  let(:klass)   { Class.new(MyModel) }
  let(:builder) { Sinclair.new(klass) }

  before do
    builder.add_method(:class_name, 'self.class.name')
  end

  it do
    expect { builder.build }.to add_method(:class_name).to(klass)
  end
end

Author:

  • darthjee

Defined Under Namespace

Modules: AddMethod, MethodTo Classes: AddClassMethod, AddClassMethodTo, AddInstanceMethod, AddInstanceMethodTo, AddMethodTo, Base, ChangeClassMethod, ChangeClassMethodOn, ChangeInstanceMethod, ChangeInstanceMethodOn, ChangeMethodOn

Instance Method Summary collapse

Instance Method Details

#add_class_method(method_name) ⇒ AddClassMethod

DSL to AddClassMethod

Examples:

RSpec.configure do |config|
  config.include Sinclair::Matchers
end

class MyModel
end

RSpec.describe 'my test' do
  let(:klass)   { Class.new(MyModel) }
  let(:builder) { Sinclair.new(klass) }

  before do
    builder.add_method(:class_name, 'self.class.name')
  end

  it do
    expect { builder.build }.to add_method(:class_name).to(klass)
  end
end


61
62
63
# File 'lib/sinclair/matchers.rb', line 61

def add_class_method(method_name)
  Sinclair::Matchers::AddClassMethod.new(method_name)
end

#add_method(method_name) ⇒ AddInstanceMethod

DSL to AddInstanceMethod

Examples:

RSpec.configure do |config|
  config.include Sinclair::Matchers
end

class MyModel
end

RSpec.describe 'my test' do
  let(:klass)   { Class.new(MyModel) }
  let(:builder) { Sinclair.new(klass) }

  before do
    builder.add_method(:class_name, 'self.class.name')
  end

  it do
    expect { builder.build }.to add_method(:class_name).to(klass)
  end
end


51
52
53
# File 'lib/sinclair/matchers.rb', line 51

def add_method(method_name)
  Sinclair::Matchers::AddInstanceMethod.new(method_name)
end

#change_class_method(method_name) ⇒ ChangeClassMethod

DSL to ChangeClassMethod

Examples:

RSpec.configure do |config|
  config.include Sinclair::Matchers
end

class MyModel
end

RSpec.describe 'my test' do
  let(:klass)   { Class.new(MyModel) }
  let(:builder) { Sinclair.new(klass) }

  before do
    builder.add_method(:class_name, 'self.class.name')
  end

  it do
    expect { builder.build }.to add_method(:class_name).to(klass)
  end
end


81
82
83
# File 'lib/sinclair/matchers.rb', line 81

def change_class_method(method_name)
  Sinclair::Matchers::ChangeClassMethod.new(method_name)
end

#change_method(method_name) ⇒ ChangeInstanceMethod

DSL to ChangeInstanceMethod

Examples:

RSpec.configure do |config|
  config.include Sinclair::Matchers
end

class MyModel
end

RSpec.describe 'my test' do
  let(:klass)   { Class.new(MyModel) }
  let(:builder) { Sinclair.new(klass) }

  before do
    builder.add_method(:class_name, 'self.class.name')
  end

  it do
    expect { builder.build }.to add_method(:class_name).to(klass)
  end
end


71
72
73
# File 'lib/sinclair/matchers.rb', line 71

def change_method(method_name)
  Sinclair::Matchers::ChangeInstanceMethod.new(method_name)
end