Unable to create new permission set for Solidus - ruby-on-rails

I've started on creating multi vendor permissions for Solidus.
I used one of the other permission_sets as a starting point, but I'm missing one crucial thing.
As you can see, my test fails:
$ bundle exec rspec spec/models/spree/permission_sets/multi_vendor_spec.rb
multi_vendor_spec.rb:3:in `<top (required)>':
uninitialized constant Spree::PermissionSets::MultiVendor (NameError)
from gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in `load'
from gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in `block in load_spec_files'
from gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1325:in `each'
from gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1325:in `load_spec_files'
from gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:102:in `setup'
from gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:88:in `run'
from gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:73:in `run'
from gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:41:in `invoke'
from gems/rspec-core-3.3.2/exe/rspec:4:in `<top (required)>'
from bin/rspec:23:in `load'
from bin/rspec:23:in `<main>'
from bin/ruby_executable_hooks:15:in `eval'
from bin/ruby_executable_hooks:15:in `<main>'
Can you see why Spree::PermissionSets::MultiVendor is reported uninitialized?
Cheers,
Martin

The fix is to add
require 'spree/permission_sets/multi_vendor' to spree/permission_sets.rb

Related

Rails, using rspec to run one file

I want to run an rspec test on one file.
I have tried various methods such as
rspec path/to/spec/file.rb
rake spec SPEC=spec/controllers/sessions_controller_spec.rb
bundle exec rspec path/to/spec/file.rb
But all of them give me this error:
.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-2.0.3/lib/rack/builder.rb:146:in `to_app': missing run or map statement (RuntimeError)
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-2.0.3/lib/rack/builder.rb:160:in `block in generate_map'
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-2.0.3/lib/rack/builder.rb:160:in `each'
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-2.0.3/lib/rack/builder.rb:160:in `generate_map'
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-2.0.3/lib/rack/builder.rb:145:in `to_app'
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/capybara-2.16.1/lib/capybara/rails.rb:13:in `<top (required)>'
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
from /home/jay/Sites/New Folder/pg/scheduler/spec/spec_helper.rb:19:in `<top (required)>'
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/configuration.rb:1455:in `require'
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/configuration.rb:1455:in `block in requires='
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/configuration.rb:1455:in `each'
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/configuration.rb:1455:in `requires='
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/configuration_options.rb:112:in `block in process_options_into'
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/configuration_options.rb:111:in `each'
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/configuration_options.rb:111:in `process_options_into'
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/configuration_options.rb:21:in `configure'
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/runner.rb:99:in `setup'
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/runner.rb:86:in `run'
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/runner.rb:71:in `run'
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/lib/rspec/core/runner.rb:45:in `invoke'
from /home/jay/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rspec-core-3.7.0/exe/rspec:4:in `<main>'
How do I run an rspec test on one file?
I tried :
ruby -I test test/unit/my_model_test.rb
and it worked for me let me know if it helped you

Why does my rake abort?

I get the following stack when I run rake rails:update:bin
rake aborted!
LoadError: cannot load such file -- google/api_client
/Users/jonathangrant/.rvm/gems/ruby-2.0.0-p648/gems/bundler-1.13.6/lib/bundler/runtime.rb:91:in `require'
/Users/jonathangrant/.rvm/gems/ruby-2.0.0-p648/gems/bundler-1.13.6/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
/Users/jonathangrant/.rvm/gems/ruby-2.0.0-p648/gems/bundler-1.13.6/lib/bundler/runtime.rb:86:in `each'
/Users/jonathangrant/.rvm/gems/ruby-2.0.0-p648/gems/bundler-1.13.6/lib/bundler/runtime.rb:86:in `block in require'
/Users/jonathangrant/.rvm/gems/ruby-2.0.0-p648/gems/bundler-1.13.6/lib/bundler/runtime.rb:75:in `each'
/Users/jonathangrant/.rvm/gems/ruby-2.0.0-p648/gems/bundler-1.13.6/lib/bundler/runtime.rb:75:in `require'
/Users/jonathangrant/.rvm/gems/ruby-2.0.0-p648/gems/bundler-1.13.6/lib/bundler.rb:106:in `require'
/Users/jonathangrant/omnivirt/adsoptimal-upload/config/application.rb:7:in `<top (required)>'
/Users/jonathangrant/omnivirt/adsoptimal-upload/Rakefile:4:in `require'
/Users/jonathangrant/omnivirt/adsoptimal-upload/Rakefile:4:in `<top (required)>'
/Users/jonathangrant/.rvm/gems/ruby-2.0.0-p648/gems/rake-11.3.0/lib/rake/rake_module.rb:28:in `load'
/Users/jonathangrant/.rvm/gems/ruby-2.0.0-p648/gems/rake-11.3.0/lib/rake/rake_module.rb:28:in `load_rakefile'
/Users/jonathangrant/.rvm/gems/ruby-2.0.0-p648/gems/rake-11.3.0/lib/rake/application.rb:686:in `raw_load_rakefile'
/Users/jonathangrant/.rvm/gems/ruby-2.0.0-p648/gems/rake-11.3.0/lib/rake/application.rb:96:in `block in load_rakefile'
/Users/jonathangrant/.rvm/gems/ruby-2.0.0-p648/gems/rake-11.3.0/lib/rake/application.rb:178:in `standard_exception_handling'
/Users/jonathangrant/.rvm/gems/ruby-2.0.0-p648/gems/rake-11.3.0/lib/rake/application.rb:95:in `load_rakefile'
/Users/jonathangrant/.rvm/gems/ruby-2.0.0-p648/gems/rake-11.3.0/lib/rake/application.rb:79:in `block in run'
/Users/jonathangrant/.rvm/gems/ruby-2.0.0-p648/gems/rake-11.3.0/lib/rake/application.rb:178:in `standard_exception_handling'
/Users/jonathangrant/.rvm/gems/ruby-2.0.0-p648/gems/rake-11.3.0/lib/rake/application.rb:77:in `run'
/Users/jonathangrant/.rvm/gems/ruby-2.0.0-p648/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
/Users/jonathangrant/.rvm/gems/ruby-2.0.0-p648/bin/rake:23:in `load'
/Users/jonathangrant/.rvm/gems/ruby-2.0.0-p648/bin/rake:23:in `<main>'
/Users/jonathangrant/.rvm/gems/ruby-2.0.0-p648/bin/ruby_executable_hooks:15:in `eval'
/Users/jonathangrant/.rvm/gems/ruby-2.0.0-p648/bin/ruby_executable_hooks:15:in `<main>'
Why am I getting this issue?
I am using Ruby 2.0.0 and Rails 4.1.5 on my OSX 10.11.16 Mac.
Well, the surface answer is because Ruby can't find google/api_client. ;) But obviously that's not super helpful.
First, try putting in place a couple of best practices:
Install RVM,
Create and use a gemset for your project (rvm use 2.0.0#my-awesome-project --create).
Run bundle install.
Then try the rake task again. What happens now?
(those best practices are RVM + gemsets)

Loaderror: cannot find such file

Hi i have just started making an app on ruby on rails and i have problems writing my spec files.
i ran bundle exec rspec spec/controllers/api/user_controller_spec.rb but it gave me the error:
/home/action/.gem/ruby/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load': cannot load such file -- /home/action
/slidey/spec/controllers/api/user_controller_spec.rb (LoadError)
from /home/action/.gem/ruby/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
from /home/action/.gem/ruby/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
from /home/action/.gem/ruby/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
from /home/action/.gem/ruby/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
from /home/action/.gem/ruby/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
from /home/action/.gem/ruby/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'
EDIT: when i ran bundle exec rspec spec they gave me the following error:
/home/action/.gem/ruby/2.0.0/gems/activerecord-4.0.8/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `has
_attached_file' for #<Class:0x007f44f503bee8> (NoMethodError)
from /home/action/slidey/app/models/documents.rb:6:in `<class:Documents>'
from /home/action/slidey/app/models/documents.rb:1:in `<top (required)>'
from /home/action/.gem/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in `require'
from /home/action/.gem/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in `block in require'
from /home/action/.gem/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:214:in `load_dependency'
from /home/action/.gem/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in `require'
from /home/action/.gem/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:330:in `require_or_load'
from /home/action/.gem/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:463:in `load_missing_constant'
from /home/action/.gem/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:184:in `const_missing'
from /home/action/slidey/spec/models/documents_spec.rb:3:in `<top (required)>'
from /home/action/.gem/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:223:in `load'
from /home/action/.gem/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:223:in `block in load'
from /home/action/.gem/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:214:in `load_dependency'
from /home/action/.gem/ruby/2.0.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:223:in `load'
can anyone shed some light on this? what does it mean?
It looks like it cannot find the file spec/controllers/api/user_controller_spec.rb
Try to rename your spec file into users_controller_spec.rb

bundle console fails w/ uninitialized constant Rails

I have create a new Rails engine using the rails plugin new Foobar --full --mountable command. When running bundle console I get uninitialized constant Rails Why is this?
Resolving dependencies...
Unfortunately, a fatal error has occurred. Please see the Bundler troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
/Users/kyledecot/Desktop/Foobar/lib/foobar/engine.rb:2:in `<module:Foobar>': uninitialized constant Rails (NameError)
from /Users/kyledecot/Desktop/Foobar/lib/foobar/engine.rb:1:in `<top (required)>'
from /Users/kyledecot/Desktop/Foobar/lib/foobar.rb:1:in `require'
from /Users/kyledecot/Desktop/Foobar/lib/foobar.rb:1:in `<top (required)>'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:76:in `require'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:72:in `each'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:72:in `block in require'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:61:in `each'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:61:in `require'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler.rb:131:in `require'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/cli.rb:664:in `console'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/vendor/thor/command.rb:27:in `run'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_command'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/vendor/thor.rb:363:in `dispatch'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/vendor/thor/base.rb:438:in `start'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/cli.rb:10:in `start'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/bin/bundle:22:in `block in <top (required)>'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/friendly_errors.rb:5:in `with_friendly_errors'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/bin/bundle:22:in `<top (required)>'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/bin/bundle:23:in `load'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/bin/bundle:23:in `<main>'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#foobar/bin/ruby_executable_hooks:15:in `eval'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#foobar/bin/ruby_executable_hooks:15:in `<main>'
Adding require 'rails' in Foobar/lib/foobar/engine.rb file worked for me. I got my answer from here.

Why am I getting an error when I try to update my Heroku database?

Why am I getting an error when I try to update my Heroku database?
Whenever I try any heroku rake... command I get the same error:
$ heroku rake db:setup
(in /app)
rake aborted!
uninitialized constant Rake::DSL
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2482:in `const_missing'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:8:in `<class:TaskLib>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:6:in `<module:Rake>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:3:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/rdoctask.rb:20:in `require'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/rdoctask.rb:20:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/tasks/documentation.rake:1:in `require'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/tasks/documentation.rake:1:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/tasks.rb:15:in `load'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/tasks.rb:15:in `block in <top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/tasks.rb:6:in `each'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/tasks.rb:6:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/application.rb:215:in `require'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/application.rb:215:in `initialize_tasks'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/application.rb:139:in `load_tasks'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.8/lib/rails/application.rb:77:in `method_missing'
/app/Rakefile:7:in `<top (required)>'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2373:in `load'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:1991:in `run'
/usr/ruby1.9.2/bin/rake:31:in `<main>'
Rakefile should include
require 'rake/dsl_definition'
There are two ways to fix this. I have a blog post about it here:
Use an older rake version, or require DSL for the newer gem.
http://codeglot.com/posts/13-you_have_already_activated_rake_0_9_2.
sadly, including require 'rake/dsl_definition' did not work for me. I am using rails 3.0.6. So I reverted back to rake 0.8.7.

Resources