Sha256: de510e2879b2520c2f9c322959da95cb8646ed6ef9a21a404f86b85ec734fbbb

Contents?: true

Size: 1.92 KB

Versions: 9

Compression:

Stored size: 1.92 KB

Contents

require "spec_helper"

describe JsonSpec::Matchers do
  let(:environment) do
    klass = Class.new
    klass.send(:include, JsonSpec::Matchers)
    klass.new
  end

  let(:json){ %({"json":"spec"}) }

  context "be_json_eql" do
    it "instantiates its matcher" do
      JsonSpec::Matchers::BeJsonEql.should_receive(:new).with(json)
      environment.be_json_eql(json)
    end

    it "returns its matcher" do
      matcher = environment.be_json_eql(json)
      matcher.should be_a(JsonSpec::Matchers::BeJsonEql)
    end
  end

  context "include_json" do
    it "instantiates its matcher" do
      JsonSpec::Matchers::IncludeJson.should_receive(:new).with(json)
      environment.include_json(json)
    end

    it "returns its matcher" do
      matcher = environment.include_json(json)
      matcher.should be_a(JsonSpec::Matchers::IncludeJson)
    end
  end

  context "have_json_path" do
    let(:path){ "json" }

    it "instantiates its matcher" do
      JsonSpec::Matchers::HaveJsonPath.should_receive(:new).with(path)
      environment.have_json_path(path)
    end

    it "returns its matcher" do
      matcher = environment.have_json_path(path)
      matcher.should be_a(JsonSpec::Matchers::HaveJsonPath)
    end
  end

  context "have_json_type" do
    let(:type){ Hash }

    it "instantiates its matcher" do
      JsonSpec::Matchers::HaveJsonType.should_receive(:new).with(type)
      environment.have_json_type(type)
    end

    it "returns its matcher" do
      matcher = environment.have_json_type(type)
      matcher.should be_a(JsonSpec::Matchers::HaveJsonType)
    end
  end

  context "have_json_size" do
    let(:size){ 1 }

    it "instantiates its matcher" do
      JsonSpec::Matchers::HaveJsonSize.should_receive(:new).with(size)
      environment.have_json_size(size)
    end

    it "returns its matcher" do
      matcher = environment.have_json_size(size)
      matcher.should be_a(JsonSpec::Matchers::HaveJsonSize)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
json_spec-1.1.5 spec/json_spec/matchers_spec.rb
json_spec-1.1.4 spec/json_spec/matchers_spec.rb
json_spec-1.1.3 spec/json_spec/matchers_spec.rb
json_spec-1.1.2 spec/json_spec/matchers_spec.rb
json_spec-1.1.1 spec/json_spec/matchers_spec.rb
json_spec-1.1.0 spec/json_spec/matchers_spec.rb
json_spec-1.0.3 spec/json_spec/matchers_spec.rb
json_spec-1.0.2 spec/json_spec/matchers_spec.rb
json_spec-1.0.0 spec/json_spec/matchers_spec.rb