Skip to content
This repository has been archived by the owner on Sep 12, 2019. It is now read-only.

Commit

Permalink
Vaguely working gem (but totally not)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhawthorn committed Nov 21, 2017
1 parent a3addb2 commit 2ac9769
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 7 deletions.
15 changes: 15 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
source "https://rubygems.org"

branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
gem "solidus", github: "solidusio/solidus", branch: branch

gem 'pg'
gem 'mysql2'

group :development, :test do
gem "pry-rails"
end

gem 'deface', require: false

gemspec
21 changes: 21 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'bundler'
Bundler::GemHelper.install_tasks

require 'rspec/core/rake_task'
require 'spree/testing_support/common_rake'

RSpec::Core::RakeTask.new

task :default do
if Dir["spec/dummy"].empty?
Rake::Task[:test_app].invoke
Dir.chdir("../../")
end
Rake::Task[:spec].invoke
end

desc 'Generates a dummy app for testing'
task :test_app do
ENV['LIB_NAME'] = 'solidus_stock_transfers'
Rake::Task['common:test_app'].invoke
end
2 changes: 1 addition & 1 deletion lib/solidus_stock_transfers/factories.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FactoryGirl.define do
FactoryBot.define do
# Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them.
#
# Example adding this to your spec_helper will load these Factories for use:
Expand Down
18 changes: 12 additions & 6 deletions solidus_stock_transfers.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,34 @@ require 'solidus_stock_transfers/version'
Gem::Specification.new do |s|
s.name = 'solidus_stock_transfers'
s.version = SolidusStockTransfers::VERSION
s.summary = 'TODO'
s.description = 'TODO'
s.summary = 'Stock transfer interface for solidus'
s.description = 'An admin interface for transfering stock between StockLocations. Extracted from Solidus 2.5'
s.license = 'BSD-3-Clause'

# s.author = 'You'
# s.email = 'you@example.com'
s.author = 'John Hawthorn'
s.email = 'john@stembolt.com'
# s.homepage = 'http://www.example.com'

s.files = Dir["{app,config,db,lib}/**/*", 'LICENSE', 'Rakefile', 'README.md']
s.test_files = Dir['test/**/*']

s.add_dependency 'solidus_core', '~> 1.0'
s.add_dependency 'solidus_core', ['>= 2.5.x', '< 3']
s.add_dependency 'solidus_support'
s.add_dependency 'deface'

s.add_development_dependency 'capybara'
s.add_development_dependency 'ffaker'
s.add_development_dependency 'poltergeist'
s.add_development_dependency 'coffee-rails'
s.add_development_dependency 'sass-rails'
s.add_development_dependency 'database_cleaner'
s.add_development_dependency 'factory_girl'
s.add_development_dependency 'factory_bot'
s.add_development_dependency 'rspec-rails'
s.add_development_dependency 'rubocop', '0.37.2'
s.add_development_dependency 'rubocop-rspec', '1.4.0'
s.add_development_dependency 'simplecov'
s.add_development_dependency 'sqlite3'
s.add_development_dependency 'capybara-screenshot'
s.add_development_dependency 'rspec-activemodel-mocks'
s.add_development_dependency 'rails-controller-testing'
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module Spree
describe Admin::StockTransfersController, type: :controller do
stub_authorization!

routes { Spree::Core::Engine.routes }

let(:warehouse) { StockLocation.create(name: "Warehouse") }
let(:ny_store) { StockLocation.create(name: "NY Store") }
let(:la_store) { StockLocation.create(name: "LA Store") }
Expand Down
4 changes: 4 additions & 0 deletions spec/requests/spree/api/stock_transfers_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
require 'spec_helper'
require 'spree/api/testing_support/setup'
require 'spree/api/testing_support/helpers'

module Spree
describe Api::StockTransfersController do
extend Spree::Api::TestingSupport::Setup
include Spree::Api::TestingSupport::Helpers

let!(:stock_transfer) { create(:stock_transfer_with_items) }
let(:transfer_item) { stock_transfer.transfer_items.first }
Expand Down
4 changes: 4 additions & 0 deletions spec/requests/spree/api/transfer_items_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
require 'spec_helper'
require 'spree/api/testing_support/setup'
require 'spree/api/testing_support/helpers'

module Spree
describe Api::TransferItemsController do
extend Spree::Api::TestingSupport::Setup
include Spree::Api::TestingSupport::Helpers

let!(:stock_transfer) { create(:stock_transfer_with_items) }
let(:transfer_item) { stock_transfer.transfer_items.first }
Expand Down
23 changes: 23 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
if ENV['COVERAGE']
require "simplecov"
SimpleCov.start "rails"
end

ENV["RAILS_ENV"] ||= "test"

require File.expand_path("../dummy/config/environment.rb", __FILE__)

require 'rails-controller-testing'
require 'solidus_support/extension/feature_helper'

require 'spree/api/testing_support/helpers'
require 'cancan/matchers'
require 'rspec/active_model/mocks'

Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each { |f| require f }

RSpec.configure do |config|
config.infer_spec_type_from_file_location!

FactoryBot.find_definitions
end
5 changes: 5 additions & 0 deletions spec/support/dummy_ability.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'cancan'

class DummyAbility
include CanCan::Ability
end
13 changes: 13 additions & 0 deletions spec/support/working_factories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
RSpec.shared_examples_for 'a working factory' do
it "builds successfully" do
expect(build(factory)).to be_a(factory_class)
end

it "creates successfully" do
expect(create(factory)).to be_a(factory_class)
end

it "is creates a valid record" do
expect(create(factory)).to be_valid
end
end

0 comments on commit 2ac9769

Please sign in to comment.