Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
= shopify-mock
This gem is used for testing Shopify apps without having to actually connect to Shopify to develop the application.
You can use this gem explicitly for testing, or you can also use it in your development environment to speed things up when fiddling around in the web browser, or in the console.
== Installation
Add the gem to your Gemfile in the appropriate group:
gem 'shopify-mock', :group => [:development, :test]
== Enabling / Disabling
For non Rails apps, shopify-mock is disabled by default, and real-world Internet access is allowed. In a Rails app, shopify-mock is disabled except for in the :test environment.
To enable / disable shopify-mock manually, set ShopifyAPI::Mock.enabled to true or false:
ShopifyAPI::Mock.enabled = true # or false to disable
ShopifyAPI::Mock.enabled? # => to get the current state
And to completely disable access to the Internet altogether, or re-enable it:
ShopifyAPI::Mock.allow_internet = false # or true to re-enable
ShopifyAPI::Mock.allow_internet? # => to get the current state
== Example
After installing the gem in your Shopify app, load the rails console, and try this quick example:
rails c test
order = ShopifyAPI::Session.temp("test", "randomtoken") { ShopifyAPI::Order.first }
You'll notice that the order was not downloaded from Shopify, but based off of a shopify-mock fixture found in lib/shopify-mock/fixtures/orders.json
== Responses
You have access to all the registered mock responses through ShopifyAPI::Mock::Response
ShopifyAPI::Mock::Response.all # => array of all registered responses
ShopifyAPI::Mock::Response.clear # => clears all the currently registered responses
You also have access to each Shopify object asset by it's id
based on the ids in the fixtures. If you are using the fixtures include in the gem, you can do
product = ShopifyAPI::Product.find(632910392)
and you'll get back the fixture product called Ipod Nano 8GB
And you can register your own response:
ShopifyAPI::Mock::Response.new(:get, "orders/1.xml", "response content")
== Fixtures
You have access to the shopify-mock fixtures through ShopifyAPI::Mock::Fixture
ShopifyAPI::Mock::Fixture.all # => an array of all the fixtures
ShopifyAPI::Mock::Fixture.find(:orders, :json) # => returns the orders.json fixture
ShopifyAPI::Mock::Fixture.path # => the path to the fixture files
# to use your own fixture path:
ShopifyAPI::Mock::Fixture.path = File.join(Rails.root, 'spec', 'fixtures')
ShopifyAPI::Mock.reset # => to reload the fixtures
A Fixture object has these methods:
fixture = ShopifyAPI::Mock::Fixture.all.first
fixture.name # => the name of the fixture, such as :orders
fixture.ext # => the extension of the fixture, such as :json, or :xml
fixture.data # => the file contents
# to override the fixture's contents:
fixture.data = "new contents" # => use "new contents" for this fixture
fixture.data = nil # => resets back to default contents
== Contributing to shopify-mock
== Resources
== License
MIT License
Copyright (c) 2011 Travis Haynes.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Unknown package
We found that shopify-mock-new demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.