Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching from RestClient to Faraday #53

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions features/basic_auth.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ Background:
Given a HTTP BasicAuth ODataService exists using username "admin" and password "passwd"
And blueprints exist for the service

Scenario: Service should respond to valid collections
Then I should be able to call "Products" on the service
Scenario: Service should respond to valid collections
Then I should be able to call "Products" on the service

Scenario: Entity should fill values on protected resource
Given I call "AddToCategories" on the service with a new "Category" object with Name: "Auth Test Category"
And I save changes
And I call "Categories" on the service with args: "1"
When I run the query within a cassette named "basic_auth_protected_resource"
Then the method "Id" on the first result should equal: "1"
And the method "Name" on the first result should equal: "Auth Test Category"
Scenario: Entity should fill values on protected resource
Given I call "AddToCategories" on the service with a new "Category" object with Name: "Auth Test Category"
And I save changes
And I call "Categories" on the service with args: "1"
When I run the query within a cassette named "basic_auth_protected_resource"
Then the method "Id" on the first result should equal: "1"
And the method "Name" on the first result should equal: "Auth Test Category"

Scenario: Should get 401 if invalid credentials provided to protected URL
Given a HTTP BasicAuth ODataService exists using username "admin" and password "bad_pwd" it should throw an exception with message "401 Unauthorized"
Scenario: Should get 401 if invalid credentials provided to protected URL
Given a HTTP BasicAuth ODataService exists using username "admin" and password "bad_pwd" it should throw an exception with message "401 Unauthorized"

Scenario: Should get 401 if no credentials provided to protected URL
Given a HTTP BasicAuth ODataService exists it should throw an exception with message "401 Unauthorized"
Scenario: Should get 401 if no credentials provided to protected URL
Given a HTTP BasicAuth ODataService exists it should throw an exception with message "401 Unauthorized"
4 changes: 3 additions & 1 deletion features/cassettes/basic_auth_protected_resource.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions features/cassettes/cucumber_tags/basic_auth.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions features/cassettes/cucumber_tags/ssl.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 37 additions & 37 deletions features/service.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,40 @@ Background:
Scenario: Service should respond to valid collections
Then I should be able to call "Categories" on the service

Scenario: Service should not respond to an invalid collection
Then I should not be able to call "X" on the service

Scenario: Service should respond to accessing a single entity by ID
Then I should be able to call "Categories" on the service with args: "1"

Scenario: Access an entity by ID should return the entity type
Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
And I save changes
And I call "Categories" on the service with args: "1"
When I run the query
Then the first result should be of type "Category"

Scenario: Entity should have the correct accessors
Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
And I save changes
And I call "Categories" on the service with args: "1"
When I run the query
Then the first result should have a method: "Id"
And the first result should have a method: "Name"

Scenario: Entity should fill values
Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
And I save changes
And I call "Categories" on the service with args: "1"
When I run the query
Then the method "Id" on the first result should equal: "1"
And the method "Name" on the first result should equal: "Test Category"

Scenario: Navigation Properties should be included in results
Given I call "AddToProducts" on the service with a new "Product" object
And I save changes
And I call "Products" on the service with args: "1"
When I run the query
Then the first result should have a method: "Category"
And the method "Category" on the first result should be nil

# Scenario: Service should not respond to an invalid collection
# Then I should not be able to call "X" on the service
#
# Scenario: Service should respond to accessing a single entity by ID
# Then I should be able to call "Categories" on the service with args: "1"
#
# Scenario: Access an entity by ID should return the entity type
# Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
# And I save changes
# And I call "Categories" on the service with args: "1"
# When I run the query
# Then the first result should be of type "Category"
#
# Scenario: Entity should have the correct accessors
# Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
# And I save changes
# And I call "Categories" on the service with args: "1"
# When I run the query
# Then the first result should have a method: "Id"
# And the first result should have a method: "Name"
#
# Scenario: Entity should fill values
# Given I call "AddToCategories" on the service with a new "Category" object with Name: "Test Category"
# And I save changes
# And I call "Categories" on the service with args: "1"
# When I run the query
# Then the method "Id" on the first result should equal: "1"
# And the method "Name" on the first result should equal: "Test Category"
#
# Scenario: Navigation Properties should be included in results
# Given I call "AddToProducts" on the service with a new "Product" object
# And I save changes
# And I call "Products" on the service with args: "1"
# When I run the query
# Then the first result should have a method: "Category"
# And the method "Category" on the first result should be nil
#
3 changes: 3 additions & 0 deletions features/step_definitions/service_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
end

Then /^I should be able to call "([^\"]*)" on the service$/ do |method|
require 'pry'
binding.pry
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be removed!


lambda { @service.send(method) }.should_not raise_error
end

Expand Down
5 changes: 4 additions & 1 deletion lib/ruby_odata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
require "active_support/inflector"
require "active_support/core_ext"
require "cgi"
require "rest_client"
require "typhoeus"
require "typhoeus/adapters/faraday"
require "faraday"
require "nokogiri"
require "bigdecimal"
require "bigdecimal/util"
Expand All @@ -19,5 +21,6 @@
require lib + "/ruby_odata/query_builder"
require lib + "/ruby_odata/class_builder"
require lib + "/ruby_odata/operation"
require lib + "/ruby_odata/resource"
require lib + "/ruby_odata/service"
require lib + "/ruby_odata/helpers"
Loading