Sha256: 9c95aa0a9045a5bb415b72067a011d8a7442996246a39d077fa1052817b2c3fe

Contents?: true

Size: 1.33 KB

Versions: 18

Compression:

Stored size: 1.33 KB

Contents

$:.unshift(File.expand_path('../../../lib',__FILE__))
require 'embedly'

# cache for hostnames
HOSTNAMES = {}

Given /an embedly api( with key)?$/ do |key_enabled|
  opts = {}
  if key_enabled
    raise 'Please set env variable $EMBEDLY_KEY' unless ENV['EMBEDLY_KEY']
    opts[:key] = ENV["EMBEDLY_KEY"]
    opts[:secret] = ENV["EMBEDLY_SECRET"]
  end
  if not HOSTNAMES[opts]
    HOSTNAMES[opts] = Embedly::API.new opts
  end
  @api = HOSTNAMES[opts]
end

When /(\w+) is called with the (.*) URLs?( and ([^\s]+) flag)?$/ do |method, urls, _, flag|
  @result = nil
  begin
    urls = urls.split(',')
    opts = {}
    if urls.size == 1
      opts[:url] = urls.first
    else
      opts[:urls] = urls
    end
    opts[flag.to_sym] = true if flag
    @result = @api.send(method, opts)
  rescue
    @error = $!
  end
end

Then /an? (\w+) error should get thrown/ do |error|
  @error.class.to_s.should == error
end

Then /objectify api_version is (\d+)$/ do |version|
  @api.api_version[:objectify].should == version
end

Then /([^\s]+) should be (.+)$/ do |key, value|
  raise @error if @error
  @result.collect do |o|
    o.send(key).to_s
  end.join(',').should == value
end

Then /([^\s]+) should start with ([^\s]+)/ do |key, value|
  raise @error if @error
  v = key.split('.').inject(@result[0]){|o,c| o.send(c)}.to_s
  v.to_s.should match(/^#{value}/)
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
embedly-1.9.1 features/steps/api_steps.rb
embedly-1.9.0 features/steps/api_steps.rb
embedly-1.8.0 features/steps/api_steps.rb
embedly-1.7.1 features/steps/api_steps.rb
embedly-1.7.0 features/steps/api_steps.rb
embedly-1.6.0 features/steps/api_steps.rb
embedly-1.5.6 features/steps/api_steps.rb
embedly-1.5.5 features/steps/api_steps.rb
embedly-1.5.4 features/steps/api_steps.rb
embedly-1.5.3 features/steps/api_steps.rb
embedly-1.5.2 features/steps/api_steps.rb
embedly-1.5.1 features/steps/api_steps.rb
embedly-1.5.0 features/steps/api_steps.rb
embedly-1.4.1 features/steps/api_steps.rb
embedly-1.4.0 features/steps/api_steps.rb
anideo-embedly-1.3.0 features/steps/api_steps.rb
embedly-1.3.0 features/steps/api_steps.rb
embedly-1.2.0 features/steps/api_steps.rb