Sha256: 7fac4a2bf2c9ee90e5e0c1308098a0cb5db8d0c83aad5e8651adef329ac035eb

Contents?: true

Size: 1.98 KB

Versions: 2

Compression:

Stored size: 1.98 KB

Contents

require 'spec_helper'

describe ActionKitRest::Pages::ImportPage do
  before(:each) do
    logger = double
    logger.stub(:debug).and_return(true)

    ActionKitRest.stub(:logger).and_return(logger)
    Vertebrae::Base.stub(:logger).and_return(logger)
  end

  let(:actionkit) { ActionKitRest.new(host: 'test.com')  }
  let(:status) { 200 }

  describe "create" do
    let(:body) { "" }
    let(:request_body) { {title: "Title", name: "name"}.to_json  }
    let(:request_path) { 'importpage/' }

    before(:each) do
      stub_post(request_path).with(body: request_body).to_return(:body => body, :status => status,
                                                                 :headers => {location: 'https://test.com/rest/v1/importpage/1093/', content_type: "application/json; charset=utf-8"})

      stub_request(:get, "https://test.com/rest/v1/importpage/1093/").to_return(body: fixture('page/object.json'), status: '200', content_type: "application/json; charset=utf-8")
    end

    describe ".create" do
      it "should allow creation" do
        resp = actionkit.import_page.create(title: "Title", name: "name")
        resp.title.should == 'Demand a Sustainable USDA'

      end
    end
  end

  describe 'update' do
    let(:body) { '' }
    let(:request_body) { {title: "Title", name: "name"}.to_json  }
    let(:request_path) { 'importpage/1093/' }

    before(:each) do
      stub_put(request_path).with(body: request_body).to_return(:body => body, :status => status,
                                                                 :headers => { content_type: "application/json; charset=utf-8"})

      stub_request(:get, "https://test.com/rest/v1/importpage/1093/").to_return(body: fixture('page/object.json'), status: '200', content_type: "application/json; charset=utf-8")
    end

    describe '.update' do
      it 'should allow updates' do
        resp = actionkit.import_page.update('1093', title: "Title", name: "name")
        resp.title.should == 'Demand a Sustainable USDA'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
action_kit_rest-0.2.2 spec/action_kit_rest/pages/input_page_spec.rb
action_kit_rest-0.2.1 spec/action_kit_rest/pages/input_page_spec.rb