vendredi 8 mai 2015

Can't run my rspec test with jRuby and Rails 4.1.4.

I have a Rails application (4.1.4) running with jRuby 1.7.15 (1.9.3p392) 2014-09-03 82b5cc3 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_67-b01.

You can see my Gemfile at: http://ift.tt/1FTGsn5.

My Gemfile.lock: http://ift.tt/1GTsvln.

As you can see I'm using rspec (2.14.1) and rspec-rails (2.14.2).

I have a user_spec.rb file something like this:

require 'spec_helper'

describe User do
  include_context "stubbed organization"
  subject { build_stubbed(:super_admin, organization: organization) }
  let(:notification_queue) { build_stubbed(:notification_queue) }

  before(:each) do
    allow(NotificationQueue).to receive(:find_each)
  end
  it "has name assigned" do
    user = build(:member, first_name: 'John', last_name: 'Smiths')
    expect(user.first_name).to eq('John')
    expect(user.last_name).to eq('Smiths')
  end

  it "has a first name" do
    subject.first_name = nil
    expect(subject).not_to be_valid
  end

  it "has a last name" do
    subject.last_name = nil
    expect(subject).not_to be_valid
  end

end

and once I run the test I get the following results:

⇒  rspec spec/models/user_spec.rb
/Users/info/.rvm/gems/jruby-1.7.15@j-platform/gems/simplecov-0.8.2/lib/simplecov.rb:31 warning: tracing (e.g. set_trace_func) will not capture all events without --debug flag
[rspec-sidekiq] WARNING! Sidekiq will *NOT* process jobs in this environment. See http://ift.tt/1vqGeMo
3/3: ****************************************_,------,
0/3: ****************************************_|  /\_/\
0/3: ****************************************~|_( x .x)
3/3: **************************************** ""  ""

Failures:

  1) User has a first name
     Failure/Error: Unable to find matching line from backtrace
     NoMethodError:
       undefined method `has_key?' for nil:NilClass
     # ./app/models/client.rb:125:in `initialize_apps_data'
     # ./spec/shared/stubbed_organization.rb:3:in `client'
     # ./spec/shared/stubbed_organization.rb:15:in `(root)'

  2) User has a last name
     Failure/Error: Unable to find matching line from backtrace
     NoMethodError:
       undefined method `has_key?' for nil:NilClass
     # ./app/models/client.rb:125:in `initialize_apps_data'
     # ./spec/shared/stubbed_organization.rb:3:in `client'
     # ./spec/shared/stubbed_organization.rb:15:in `(root)'

  3) User has name assigned
     Failure/Error: Unable to find matching line from backtrace
     NoMethodError:
       undefined method `has_key?' for nil:NilClass
     # ./app/models/client.rb:125:in `initialize_apps_data'
     # ./spec/shared/stubbed_organization.rb:3:in `client'
     # ./spec/shared/stubbed_organization.rb:15:in `(root)'

Any help would be appreciated.

Aucun commentaire:

Enregistrer un commentaire