A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/allure-framework/allure-rspec/issues/46 below:

can't excute one-liner in model spec · Issue #46 · allure-framework/allure-rspec · GitHub

Hello, I tried to use Allure at model spec, but it doesn't work.
I found this problem is caused by one-liner spec, but I didn't fix it.

I make a user model, which has name column.
Then write a spec 'spec/models/user_spec.rb'.

require "rails_helper"

RSpec.describe User, :type => :model do
  before do
    @user = User.create(name: "user")
  end
  subject { @user }
  it { is_expected.to be_valid }
end

run this spec, this error message is shown.

Starting test User.User should be valid with labels {}

NoMethodError: undefined method `[]' for nil:NilClass
/home/user/.rvm/gems/ruby-2.2.0-preview1/gems/allure-ruby-adaptor-api-0.6.6/lib/allure-ruby-adaptor-api/builder.rb:43:in `stop_test'
/home/user/.rvm/gems/ruby-2.2.0-preview1/gems/allure-rspec-0.6.9/lib/allure-rspec/formatter.rb:63:in `stop_test'
/home/user/.rvm/gems/ruby-2.2.0-preview1/gems/allure-rspec-0.6.9/lib/allure-rspec/formatter.rb:27:in `example_passed'
/home/user/.rvm/gems/ruby-2.2.0-preview1/gems/ruby-debug-ide-0.4.24/lib/ruby-debug-ide.rb:86:in `debug_load'
/home/user/.rvm/gems/ruby-2.2.0-preview1/gems/ruby-debug-ide-0.4.24/lib/ruby-debug-ide.rb:86:in `debug_program'
-e:1:in `load'
-e:1:in `<main>'

I debug the spec and found at function "stop_test", 'self.suites[suite][:tests][test]' is nil.

  def stop_test(suite, test, result = {})
    self.suites[suite][:tests][test][:steps].each do |step_title, step|
      if step[:stop].nil? || step[:stop] == 0
        stop_step(suite, test, step_title, result[:status])
      end
    end
    .
    .

When this test case, values are below:

suite => "User"
test => "User should be valid"
self.suites => {
    "User"=> {
        :title=>"User", 
        :start=>1427879918114,
        :tests=> {
            "User "=> {
                :title=>"User should be valid",
                :start=>1427879918116,
                :failure=>nil,
                :steps=>{}, 
                :attachments=>[], 
                :labels=>{:thread=>18398360, :host=>"notePC-003"}
            }
        }, 
        :labels=>{:thread=>18398360, :host=>"notePC-003"}
    }
}

I think 'self.suites[suite][:tests][test]' should be equal "User should be valid", but now it is 'User'.
the place set 'test' is a function 'example_started', so I tried to fix it, however, I don't know what to do.

def example_started(notification)
  suite = description(notification.example.example_group).to_s
  test = description(notification.example).to_s
  AllureRubyAdaptorApi::Builder.start_test(suite, test, labels(notification))
end

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4