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

undefined method `refinery_login_with' #2836

Closed
CJYate opened this issue Jan 16, 2015 · 10 comments
Closed

undefined method `refinery_login_with' #2836

CJYate opened this issue Jan 16, 2015 · 10 comments

Comments

@CJYate
Copy link
Contributor

CJYate commented Jan 16, 2015

On creating a new engine, it's not possible to run the RSpec tests.

I get an error of undefined method for "refinery_login_with" -- this is in the Feature spec at https://github.com/refinery/refinerycms/blob/master/core/lib/generators/refinery/engine/templates/spec/features/refinery/namespace/admin/plural_name_spec.rb.erb

It is apparently not including the helper function at refinerycms/testing/lib/refinery/testing/feature_macros/authentication.rb.

$ rails new my_new_application -m http://refinerycms.com/t/edge
<does stuff>
$ cd new_application
$ rails g refinery:engine my_item title:string info:text
<does stuff>
$ bundle install
$ rails generate refinery:my_items
$ rake db:migrate
$ rake db:seed
$ cd vendor/extensions/my_items/
$ bundle install

Fetching https://github.com/refinery/refinerycms.git
Fetching gem metadata from https://rubygems.org/.........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Could not find gem 'refinerycms-i18n (~> 3.0.0) ruby', which is required by gem 'refinerycms-my_items (>= 0) ruby',
in any of the sources.
(see https://github.com/refinery/refinerycms/issues/2835)

$ echo "gem 'refinerycms-i18n', git: 'https://github.com/refinery/refinerycms-i18n', branch: 'master'" >> Gemfile 
$ bundle install
$ rspec

<ERRORS>

/home/cjbrew/t/new_application/vendor/extensions/my_items/spec/features/refinery/my_items/admin/my_items_spec.rb:8:in `block (4 levels) in <top (required)>': undefined method `refinery_login_with' for RSpec::ExampleGroups::Refinery::MyItems::Admin::MyItems:Class (NoMethodError)
...

_undefined method "refinery_login_with" for RSpec::ExampleGroups::Refinery::MyItems::Admin::MyItems:Class (NoMethodError)_

The full error output:

$ rspec
/home/cjbrew/t/new_application/vendor/extensions/my_items/spec/features/refinery/my_items/admin/my_items_spec.rb:8:in `block (4 levels) in <top (required)>': undefined method `refinery_login_with' for RSpec::ExampleGroups::Refinery::MyItems::Admin::MyItems:Class (NoMethodError)
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:325:in `module_exec'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:325:in `subclass'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:219:in `block in define_example_group_method'
    from /home/cjbrew/t/new_application/vendor/extensions/my_items/spec/features/refinery/my_items/admin/my_items_spec.rb:7:in `block (3 levels) in <top (required)>'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:325:in `module_exec'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:325:in `subclass'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:219:in `block in define_example_group_method'
    from /home/cjbrew/t/new_application/vendor/extensions/my_items/spec/features/refinery/my_items/admin/my_items_spec.rb:6:in `block (2 levels) in <top (required)>'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:325:in `module_exec'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:325:in `subclass'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:219:in `block in define_example_group_method'
    from /home/cjbrew/t/new_application/vendor/extensions/my_items/spec/features/refinery/my_items/admin/my_items_spec.rb:5:in `block in <top (required)>'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:325:in `module_exec'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:325:in `subclass'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/example_group.rb:219:in `block in define_example_group_method'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/dsl.rb:41:in `block in expose_example_group_alias'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/dsl.rb:79:in `block (2 levels) in expose_example_group_alias_globally'
    from /home/cjbrew/t/new_application/vendor/extensions/my_items/spec/features/refinery/my_items/admin/my_items_spec.rb:4:in `<top (required)>'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `block in load_spec_files'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `each'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load_spec_files'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:96:in `setup'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:84:in `run'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:69:in `run'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:37:in `invoke'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/gems/rspec-core-3.1.7/exe/rspec:4:in `<top (required)>'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/bin/rspec:23:in `load'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/bin/rspec:23:in `<main>'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/bin/ruby_executable_hooks:15:in `eval'
    from /home/cjbrew/.rvm/gems/ruby-2.1.5@refedge/bin/ruby_executable_hooks:15:in `<main>'
@CJYate
Copy link
Contributor Author

CJYate commented Jan 16, 2015

$ rails -v
Rails 4.1.8
$ ruby -v
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]

Gemfile from the main app:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.8'
# Use sqlite3 as the database for Active Record
group :development, :test do
  gem 'sqlite3'
end
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring',        group: :development

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]


gem 'refinerycms', git: 'https://github.com/refinery/refinerycms', branch: 'master'
gem 'refinerycms-i18n', git: 'https://github.com/refinery/refinerycms-i18n', branch: 'master'

gem 'quiet_assets'

# Add support for refinerycms-acts-as-indexed
gem 'refinerycms-acts-as-indexed', ['~> 2.0', '>= 2.0.0']

# Add support for refinerycms-wymeditor
gem 'refinerycms-wymeditor', ['~> 1.0', '>= 1.0.0']

gem 'seo_meta', git: 'https://github.com/parndt/seo_meta', branch: 'master'

gem 'paper_trail', git: 'https://github.com/airblade/paper_trail', branch: 'master'

gem 'refinerycms-my_items', path: 'vendor/extensions'

Gemfile from the extension:

source "https://rubygems.org"

gemspec

git 'https://github.com/refinery/refinerycms.git', :branch => 'master' do
  gem 'refinerycms'

  group :development, :test do
    gem 'refinerycms-testing'
  end
end

# Database Configuration
platforms :jruby do
  gem 'activerecord-jdbcsqlite3-adapter'
  gem 'activerecord-jdbcmysql-adapter'
  gem 'activerecord-jdbcpostgresql-adapter'
  gem 'jruby-openssl'
end

platforms :ruby do
  gem 'sqlite3'
  gem 'mysql2'
  gem 'pg'
end

group :development, :test do
  platforms :ruby do
    require 'rbconfig'
    if RbConfig::CONFIG['target_os'] =~ /linux/i
      gem 'therubyracer', '~> 0.11.4'
    end
  end
end

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails'
  gem 'coffee-rails'
  gem 'uglifier'
end
gem 'refinerycms-i18n', git: 'https://github.com/refinery/refinerycms-i18n', branch: 'master'

@CJYate
Copy link
Contributor Author

CJYate commented Jan 19, 2015

Trying to diagnose the problem but I'm at a loss -- I can see the module where the function is defined (testing/lib/refinery/testing/controller_macros/authentication.rb), and I can see where that is included (testing/lib/refinery/testing.rb via testing/lib/refinerycms-testing.rb).

So why is the module not working? I can't tell what has changed to break this functionality :)

@parndt
Copy link
Member

parndt commented Jan 21, 2015

It did not know what type of spec it was. Fixed in #2843

@CJYate
Copy link
Contributor Author

CJYate commented Jan 21, 2015

Ahhh... "type: :feature" on the spec definition?

I think that used to be implicit, and now isn't -- correct?

Thanks, Chris
On 21 Jan 2015 01:34, "Philip Arndt" notifications@github.com wrote:

It did not know what type of spec it was. Fixed in #2843
#2843


Reply to this email directly or view it on GitHub
#2836 (comment)
.

@parndt
Copy link
Member

parndt commented Jan 21, 2015

That's right

@simi
Copy link
Member

simi commented Jan 21, 2015

@CJYate
Copy link
Contributor Author

CJYate commented Jan 21, 2015

Thanks @simi. I have seen the warnings about implicit type inference -- I have previously added the "infer type" option in spec_helper.rb to work around it but it seems cleaner to add it for each generated spec.

As per that upgrade information, should the generator create a rails_helper.rb file alongside spec_helper.rb?

CJYate pushed a commit to CJYate/refinerycms that referenced this issue Jan 21, 2015
@CJYate
Copy link
Contributor Author

CJYate commented Jan 21, 2015

@parndt thanks for the commit above^. I think this one is still required:
CJYate@86844aa

The only (?) problem now left appears to be the accessibility of members (the attr_accessible change) which I know is open on another ticket.

@parndt parndt closed this as completed in a8b65cf Jan 21, 2015
parndt added a commit that referenced this issue Jan 21, 2015
Fixes #2836 by updating rspec syntax in generated files.
@parndt
Copy link
Member

parndt commented Jan 21, 2015

Can you open a PR?

@CJYate
Copy link
Contributor Author

CJYate commented Jan 21, 2015

Will do - though my branch contains stuff you've already added -- hopefully there is no conflict and you can just merge the change.

If not I'll just update my master branch and cherry-pick the commit first. I don't know exactly how pull requests work from the receiving side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants