Sha256: 64ceaab848c467dd716affcfcc94519a835f14cd975254c0161104eaa6979200

Contents?: true

Size: 1018 Bytes

Versions: 7

Compression:

Stored size: 1018 Bytes

Contents

class Spinach::Features::DefaultConfig < Spinach::FeatureSteps
  include API

  step 'I use the default hyperclient config' do
    @api = Hyperclient.new('http://api.example.org')
  end

  step 'the request should have been sent with the correct JSON headers' do
    assert_requested :get, 'api.example.org', headers: {
      'Content-Type' => 'application/hal+json', 'Accept' => 'application/hal+json,application/json'
    }
  end

  step 'I send some data to the API' do
    stub_request(:post, 'http://api.example.org/posts')
    assert_equal 200, api._links.posts._post(title: 'My first blog post')._response.status
  end

  step 'it should have been encoded as JSON' do
    assert_requested :post, 'api.example.org/posts', body: '{"title":"My first blog post"}'
  end

  step 'I get some data from the API' do
    @posts = api._links.posts
  end

  step 'it should have been parsed as JSON' do
    @posts._attributes.total_posts.to_i.must_equal 2
    @posts._attributes['total_posts'].to_i.must_equal 2
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hyperclient-0.8.5 features/steps/default_config.rb
hyperclient-0.8.4 features/steps/default_config.rb
hyperclient-0.8.3 features/steps/default_config.rb
hyperclient-0.8.2 features/steps/default_config.rb
hyperclient-0.8.1 features/steps/default_config.rb
hyperclient-0.8.0 features/steps/default_config.rb
hyperclient-0.7.2 features/steps/default_config.rb