Sha256: 1997e8ffa268b7ba94fbb3fa97d910b68cd83fba1cc425c04e5e977a9ca86dbe

Contents?: true

Size: 904 Bytes

Versions: 2

Compression:

Stored size: 904 Bytes

Contents

require 'spec_helper'

describe "README features" do
  describe "Custom actions" do
    let(:custom_path) { 'accounts/:account_id/item_lists.json' }

    around do |example|
      begin
        ExampleCom::ItemList.define_action :index, method: :get, path: custom_path
        example.run
      ensure
        ExampleCom::ItemList.define_action :index, method: :get, path: ':route_key.json'
      end
    end

    before do
      stub_request(:get, expected_item_lists_path)
    end

    specify "will change the URL for the request" do
      ExampleCom::ItemList.all(account_id: '123')
      expect_request(:get, path: expected_item_lists_path)
    end

    specify "are isolated to class" do
      expect(ExampleCom::Item._defined_actions[:index][:path]).to eq(':route_key.json')
    end

    def expected_item_lists_path
      example_com_build_url('accounts/123/item_lists.json')
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
signaling-1.1.2 spec/integration/readme_features/custom_action_path_spec.rb
signaling-1.1.1 spec/integration/readme_features/custom_action_path_spec.rb