Skip to content

Commit

Permalink
New feature: Customer index
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewfl authored and steveklabnik committed Dec 18, 2013
1 parent 43349be commit c318fb3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
10 changes: 3 additions & 7 deletions features/customers.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@ Feature: Customers
}
"""

Scenario: testing stuff
Scenario: List all customers
Given I have created more than one Customer
When I GET to /customers
Then I should get a 200 OK status code

# Scenario: List all customers
# Given I have created more than one Customer
# When I GET to /customers
# Then I should get a 200 OK status code
# And there should be more than two customers paged
And there should be more than two customers paged
3 changes: 2 additions & 1 deletion features/step_definitions/customers.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Given(/^I have created a Customer$/) do

@client.POST('/customers', {})
end


Given(/^I have created more than one Customer$/) do
2.times { step "I have created a Customer" }
end
6 changes: 5 additions & 1 deletion features/step_definitions/http_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ def checker(from, of, nesting)
end

Then(/^the fields on this (.*) match:$/) do |resource, against|
checker JSON.parse(against), @client.body["#{resource}s"][0], ''
checker JSON.parse(against), @client["#{resource}s"], ''
end

Then(/^there should be more than two (.*) paged$/) do |name|
assert @client.body[name].size >= 2, "There were not more than two #{name}"
end

# TODO: move?
Expand Down
3 changes: 2 additions & 1 deletion lib/min_json_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ def initialize(api_secret, accept_header, root_url)
end

def POST (endpoint, body)
body = JSON.parse(body) if body.is_a? String
options = {
headers: {
'Accept' => @accept_header,
},
body: JSON.parse(body),
body: body,
basic_auth: {
username: @api_secret,
password: '',
Expand Down

0 comments on commit c318fb3

Please sign in to comment.