Sha256: cd21c36808a2b2dee03431f41745e105fa89e3471ce7a0d113f6786a51f05f94

Contents?: true

Size: 1.9 KB

Versions: 2

Compression:

Stored size: 1.9 KB

Contents

Given /^I have github instance$/ do
  @github = Github.new
end

Given /^I have "([^"]*)" instance$/ do |api_classes|
  @instance = convert_to_constant(api_classes).new
end

When /^I fetch "([^"]*)"$/ do |method|
  @response = @github.send(method.to_sym)
end

When /^I call (.*)$/ do |api_part|
  @response = @instance.send(api_part.to_sym)
end

When /^I will have access to "([^"]*)" API$/ do |api|
  @response.class.to_s.should match api
end

When /^I want to (.*) (?:resource|resources)$/ do |method|
  @method = method
end

When /^I want to (.*) (?:resource|resources) with the following params:$/ do |method, table|
  table.hashes.each do |attributes|
    @method = method.to_sym
    @attributes = attributes
  end
end

When /^I pass the following request options:$/ do |table|
  table.hashes.each do |options|
    @options = options
  end
end

When /^I am looking for "([^"]*)" with the following params:$/ do |method, table|
  table.hashes.each do |attributes|
    @method = method.to_sym
    @attributes = attributes
  end
end

When /^I make request$/ do
  @options ||= {}
  @attributes ||= {}
  @response = @instance.send @method, *@attributes.values, @options
end

When /^I request "([^"]*)" page$/ do |link|
  @next_response = @response.send :"#{link}_page"
end

When /^I iterate through collection pages$/ do
  @pages = []
  @response.each_page do |page|
    @pages << page.flatten
  end
end

Then /^the response collection of resources is different for "([^"]*)" attribute$/ do |attr|
  @next_response.first.send(:"#{attr}").should_not eql @response.first.send(:"#{attr}")
end

Then /^this collection should include first page$/ do
  @pages.flatten.map(&:name).should include @response.first.name
end

Then /^request should fail with "([^"]*)"$/ do |exception|
  @options ||= {}
  @attributes ||= {}
  expect {
    @response = @instance.send @method, *@attributes.values, @options
  }.to raise_error(convert_to_constant(exception))
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
github_api-0.5.0 features/step_definitions/github_api_steps.rb
github_api-0.5.0.rc1 features/step_definitions/github_api_steps.rb