Sha256: 9c2476172c91f674113ad66504b79bcf5fc634948bc0ae1a02794b0e545756ac

Contents?: true

Size: 1.52 KB

Versions: 15

Compression:

Stored size: 1.52 KB

Contents

$: << File.dirname(__FILE__) + '/../../lib'
require 'mspec'
require 'mspec/utils/script'

# The purpose of these specs is to confirm that the #should
# and #should_not methods are functioning appropriately. We
# use a separate spec file that is invoked from the MSpec
# specs but is run by MSpec. This avoids conflicting with
# RSpec's #should and #should_not methods.

class ShouldSpecsMonitor
  def initialize
    @called = 0
  end

  def expectation(state)
    @called += 1
  end

  def finish
    puts "I was called #{@called} times"
  end
end

# Simplistic runner
formatter = DottedFormatter.new
formatter.register

monitor = ShouldSpecsMonitor.new
MSpec.register :expectation, monitor
MSpec.register :finish, monitor

at_exit { MSpec.actions :finish }

MSpec.actions :start

# Specs
describe "MSpec expectation method #should" do
  it "accepts a matcher" do
    :sym.should be_kind_of(Symbol)
  end

  it "causes a failue to be recorded" do
    1.should == 2
  end

  it "registers that an expectation has been encountered" do
    # an empty example block causes an exception because
    # no expectation was encountered
  end

  it "invokes the MSpec :expectation actions" do
    1.should == 1
  end
end

describe "MSpec expectation method #should_not" do
  it "accepts a matcher" do
    "sym".should_not be_kind_of(Symbol)
  end

  it "causes a failure to be recorded" do
    1.should_not == 1
  end

  it "registers that an expectation has been encountered" do
  end

  it "invokes the MSpec :expectation actions" do
    1.should_not == 2
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
mspec-1.9.1 spec/expectations/should.rb
mspec-1.9.0 spec/expectations/should.rb
mspec-1.8.0 spec/expectations/should.rb
mspec-1.7.0 spec/expectations/should.rb
mspec-1.6.0 spec/expectations/should.rb
mspec-1.5.21 spec/expectations/should.rb
mspec-1.5.20 spec/expectations/should.rb
mspec-1.5.19 spec/expectations/should.rb
mspec-1.5.18 spec/expectations/should.rb
mspec-1.5.17 spec/expectations/should.rb
mspec-1.5.16 spec/expectations/should.rb
mspec-1.5.15 spec/expectations/should.rb
mspec-1.5.14 spec/expectations/should.rb
mspec-1.5.13 spec/expectations/should.rb
mspec-1.5.12 spec/expectations/should.rb