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

Works generator generates tests that fail miserably #513

Open
flyingzumwalt opened this issue Apr 28, 2014 · 10 comments
Open

Works generator generates tests that fail miserably #513

flyingzumwalt opened this issue Apr 28, 2014 · 10 comments
Labels

Comments

@flyingzumwalt
Copy link
Contributor

In a freshly generated Rails app where I ran the rails g curate -f generator, When I run

$ rails g curate:work Text

it adds a suite of 50+ tests. Most of those tests fail.

To get most of the generated tests to pass

I had to do the following:

In spec/spec_helper.rb, add

require 'curate/spec_support'

AND THEN
add these to Gemfile:

gem 'poltergeist' 
gem 'vcr'
gem 'webmock'

AND

  1. delete spec/factories/people_factory.rb
  2. copy spec/matchers from curate into host app spec/support/matchers

That leaves 4 tests still failing

  1) Text behaves like remotely_identified by doi with valid attributes mints!
     Failure/Error: Hydra::RemoteIdentifier.mint(remote_service_name, subject)
     RuntimeError:
       Make sure to set your Curate.configuration.application_root_url
     Shared Example Group: "remotely_identified" called from ./spec/repository_models/text_spec.rb:14
     # ./config/initializers/hydra-remote_identifier_config.rb:6:in `block (4 levels) in <top (required)>'

  2) CurationConcern::TextsController behaves like is_a_curation_concern_controller #edit someone elses private work should show 401 Unauthorized
     Failure/Error: get :edit, id: a_work
     CanCan::AccessDenied:
       You are not authorized to access this page.
     Shared Example Group: "is_a_curation_concern_controller" called from ./spec/controllers/curation_concern/texts_controller_spec.rb:6
     # /Users/matt/.rvm/gems/ruby-1.9.3-p545/gems/cancan-1.6.10/lib/cancan/ability.rb:208:in `authorize!'
     # /Users/matt/.rvm/gems/ruby-1.9.3-p545/gems/cancan-1.6.10/lib/cancan/controller_additions.rb:338:in `authorize!'
     # /Users/matt/.rvm/gems/ruby-1.9.3-p545/bundler/gems/curate-d17e75b7e862/app/controllers/curation_concern/base_controller.rb:40:in `authorize_curation_concern!'

  3) CurationConcern::TextsController behaves like is_a_curation_concern_controller #edit someone elses public work should show me the page
     Failure/Error: get :edit, id: a_work
     CanCan::AccessDenied:
       You are not authorized to access this page.
     Shared Example Group: "is_a_curation_concern_controller" called from ./spec/controllers/curation_concern/texts_controller_spec.rb:6
     # /Users/matt/.rvm/gems/ruby-1.9.3-p545/gems/cancan-1.6.10/lib/cancan/ability.rb:208:in `authorize!'
     # /Users/matt/.rvm/gems/ruby-1.9.3-p545/gems/cancan-1.6.10/lib/cancan/controller_additions.rb:338:in `authorize!'
     # /Users/matt/.rvm/gems/ruby-1.9.3-p545/bundler/gems/curate-d17e75b7e862/app/controllers/curation_concern/base_controller.rb:40:in `authorize_curation_concern!'

  4) CurationConcern::TextsController behaves like is_a_curation_concern_controller #new my work should show me the page
     Failure/Error: expect(response.body).to have_tag('.promote-doi .control-group') do
     NoMethodError:
       undefined method `has_tag?' for #<String:0x007f863c423cf8>
     Shared Example Group: "is_a_curation_concern_controller" called from ./spec/controllers/curation_concern/texts_controller_spec.rb:6
     # /Users/matt/.rvm/gems/ruby-1.9.3-p545/gems/rspec-expectations-2.14.5/lib/rspec/matchers/built_in/has.rb:10:in `matches?'
     # /Users/matt/.rvm/gems/ruby-1.9.3-p545/gems/rspec-expectations-2.14.5/lib/rspec/expectations/handler.rb:24:in `handle_matcher'

Finished in 34.37 seconds
52 examples, 4 failures
@jeremyf
Copy link
Contributor

jeremyf commented Apr 28, 2014

Failing test 4) add "gem 'rspec-html-matchers'" in Gemfile

@flyingzumwalt
Copy link
Contributor Author

That did fix the 4th failing test.

@jeremyf
Copy link
Contributor

jeremyf commented Apr 28, 2014

Failing test 1) add to your environment file https://github.com/ndlib/curate_vanilla/blob/master/config/environments/staging.rb#L45

@jeremyf
Copy link
Contributor

jeremyf commented Apr 28, 2014

For test 2 & 3) Try running LOCAL=TRUE rspec ./spec/controllers/curation_concern/texts_controller_spec.rb:6

The LOCAL means "Raise the exceptions instead of using the exception handler." There may be something buried in there.

@flyingzumwalt
Copy link
Contributor Author

Same errors with LOCAL=TRUE rspec ./spec/controllers/curation_concern/texts_controller_spec.rb

@jeremyf
Copy link
Contributor

jeremyf commented Apr 28, 2014

@flyingzumwalt Actually, I believe it is working. However your application is treating exceptions as local. That was one thing I had setup for Curate's tests to assume that exceptions are not local.

So the proposed solution would be to handle either case.

@flyingzumwalt
Copy link
Contributor Author

Ah. Ok. I'll do that in my app, but this ticket will be important to address in Curate so that future adopters won't run into it.

@jeremyf
Copy link
Contributor

jeremyf commented Apr 28, 2014

Absolutely. And shouldn't be closed.

I believe your two steps are appropriate and should have the test case: "And the generated model tests work"

@jeremyf
Copy link
Contributor

jeremyf commented Apr 29, 2014

As an interesting aside - curate is assuming the use of rspec. Even in the spec_support.

@scherztc
Copy link
Contributor

Would it be useful to have something similar to sufia_models with curation_concerns (works)?

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

No branches or pull requests

3 participants