Sha256: 05f9087a19a9a90c86c1b0bc16c82f250a8b76c7f5764f010c23e5f44144a116

Contents?: true

Size: 1.17 KB

Versions: 18

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

describe Betterdocs::Dsl::Controller::Action::Response do
  let :docs do
    double(
      'Betterdocs::ResultRepresenterCollector',
      nested_links: :links,
      nested_properties: :properties
    )
  end

  let :representer do
    double('Representer', docs: docs)
  end

  let :result_data do
    double(
      'Result',
      representer: representer,
      to_json: '{ "the": "result" }'
    )
  end

  let :response do
    data = result_data
    described_class.new do
      data
    end
  end

  let :param_value do
    double('Betterdocs::Dsl::Controller::Action::Param', value: 'foo')
  end

  it 'has params' do
    allow(response).to receive(:param).with(:test).and_return param_value
    expect(response.params[:test]).to eq 'foo'
  end

  it 'has data' do
    expect(response.data).to eq result_data
  end

  it 'has properties' do
    expect(response.properties).to eq :properties
  end

  it 'has links' do
    expect(response.links).to eq :links
  end

  it 'has representer' do
    expect(response.representer).to eq representer
  end

  it 'can be converted into a JSON document' do
    expect(response.to_json).to eq '{ "the": "result" }'
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
betterdocs-0.10.0 spec/betterdocs/dsl/controller/action/response_spec.rb
betterdocs-0.9.2 spec/betterdocs/dsl/controller/action/response_spec.rb
betterdocs-0.9.1 spec/betterdocs/dsl/controller/action/response_spec.rb
betterdocs-0.9.0 spec/betterdocs/dsl/controller/action/response_spec.rb
betterdocs-0.8.1 spec/betterdocs/dsl/controller/action/response_spec.rb
betterdocs-0.8.0 spec/betterdocs/dsl/controller/action/response_spec.rb
betterdocs-0.7.1 spec/betterdocs/dsl/controller/action/response_spec.rb
betterdocs-0.7.0 spec/betterdocs/dsl/controller/action/response_spec.rb
betterdocs-0.6.8 spec/betterdocs/dsl/controller/action/response_spec.rb
betterdocs-0.6.7 spec/betterdocs/dsl/controller/action/response_spec.rb
betterdocs-0.6.6 spec/betterdocs/dsl/controller/action/response_spec.rb
betterdocs-0.6.5 spec/betterdocs/dsl/controller/action/response_spec.rb
betterdocs-0.6.4 spec/betterdocs/dsl/controller/action/response_spec.rb
betterdocs-0.6.3 spec/betterdocs/dsl/controller/action/response_spec.rb
betterdocs-0.6.2 spec/betterdocs/dsl/controller/action/response_spec.rb
betterdocs-0.6.1 spec/betterdocs/dsl/controller/action/response_spec.rb
betterdocs-0.6.0 spec/betterdocs/dsl/controller/action/response_spec.rb
betterdocs-0.5.0 spec/betterdocs/dsl/controller/action/response_spec.rb