Sha256: efadae3bce522adf035f9266ec3177f566664e82cc0ba3327fd1391c59003a41

Contents?: true

Size: 996 Bytes

Versions: 8

Compression:

Stored size: 996 Bytes

Contents

require File.dirname(__FILE__) + '/../spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers/have_constant'

class HCMSpecs
  X = :x
end

describe HaveConstantMatcher do
  it "matches when mod has the constant" do
    matcher = HaveConstantMatcher.new :X
    matcher.matches?(HCMSpecs).should be_true
  end

  it "does not match when mod does not have the constant" do
    matcher = HaveConstantMatcher.new :A
    matcher.matches?(HCMSpecs).should be_false
  end

  it "provides a failure message for #should" do
    matcher = HaveConstantMatcher.new :A
    matcher.matches?(HCMSpecs)
    matcher.failure_message.should == [
      "Expected HCMSpecs to have constant 'A'",
      "but it does not"
    ]
  end

  it "provides a failure messoge for #should_not" do
    matcher = HaveConstantMatcher.new :X
    matcher.matches?(HCMSpecs)
    matcher.negative_failure_message.should == [
      "Expected HCMSpecs NOT to have constant 'X'",
      "but it does"
    ]
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mspec-1.5.17 spec/matchers/have_constant_spec.rb
mspec-1.5.16 spec/matchers/have_constant_spec.rb
mspec-1.5.15 spec/matchers/have_constant_spec.rb
mspec-1.5.14 spec/matchers/have_constant_spec.rb
mspec-1.5.13 spec/matchers/have_constant_spec.rb
mspec-1.5.10 spec/matchers/have_constant_spec.rb
mspec-1.5.12 spec/matchers/have_constant_spec.rb
mspec-1.5.11 spec/matchers/have_constant_spec.rb