Sha256: eca52fb6ea22141ea3310748cdc006f08e290bd0c71f16de17813af1b61647c8

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 = mock
    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.0 spec/action_kit_rest/pages/input_page_spec.rb
action_kit_rest-0.1.1 spec/action_kit_rest/pages/input_page_spec.rb