Skip to content

Errors when using describe and :step hook. #28

Description

@catmando

Great Great Gem, thanks so much!

I'm getting the following two problems, I'm documenting together, as I strongly suspect they are related to my configuration.

First Problem: I cannot wrap my steps in a describe:

for example:

require 'spec_helper'

describe 'admin pages', js: true do # remove this and everything works fine

  RSpec::Steps.steps "orders index", js: true do

    it "should login and display the Orders page" do
      size_window(:default)
      @orders = 5.times.collect do
        FactoryGirl.create(:order, :with_valid_payment)
        FactoryGirl.create(:order, :with_valid_payment, :from_one_month_ago)
        FactoryGirl.create(:order, :with_valid_payment, :with_tag)
        FactoryGirl.create(:order, :with_valid_payment, :with_name)
      end
      @admin = FactoryGirl.create(:user, type: "Administrator")
      login(@admin, then_visit: "/admin/orders")
      page.find('h1', text: "Orders")
      page.should have_content("Orders")
    end

    it "should show latest orders" do
      orders = page.all(".order-row", count: 15)
      orders.count.should eq(15)
    end

...

I get this:

/Users/mitch/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.2/lib/rspec/core/example_group.rb:240:in `block in define_example_group_method': Creating an isolated context from within a context is not allowed. Change `RSpec.describe` to `describe` or move this to a top-level scope. (RuntimeError)
    from /Users/mitch/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.2/lib/rspec/core/dsl.rb:43:in `block in expose_example_group_alias'
    from /Users/mitch/.rvm/gems/ruby-2.3.0/gems/rspec-steps-2.1.1/lib/rspec-steps/builder.rb:10:in `build_example_group'
    from /Users/mitch/.rvm/gems/ruby-2.3.0/gems/rspec-steps-2.1.1/lib/rspec-steps/dsl.rb:19:in `steps'
    from /Users/mitch/railsdev/v4-catprint/spec/integration/admin_spec.rb:5:in `block in <top (required)>'

Note, that if I use the monkeypatch, and simply say steps, I get a slightly different error (perhaps this is a clue?)

/Users/mitch/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.2/lib/rspec/core/example_group.rb:675:in `method_missing': undefined method `steps' for RSpec::ExampleGroups::AdminPages:Class (NoMethodError)
    from /Users/mitch/railsdev/v4-catprint/spec/integration/admin_spec.rb:5:in `block in <top (required)>'
    from /Users/mitch/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.2/lib/rspec/core/example_group.rb:385:in `module_exec'
    from /Users/mitch/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.2/lib/rspec/core/example_group.rb:385:in `subclass'
    from /Users/mitch/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.2/lib/rspec/core/example_group.rb:255:in `block in define_example_group_method'
    from /Users/mitch/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.2/lib/rspec/core/dsl.rb:43:in `block in expose_example_group_alias'
    from /Users/mitch/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.2/lib/rspec/core/dsl.rb:82:in `block (2 levels) in expose_example_group_alias_globally'
    from /Users/mitch/railsdev/v4-catprint/spec/integration/admin_spec.rb:3:in `<top (required)>'

Second (possibly related) problem

In my specs helper if I have:

config.after(:step) do
   ...
end

I get:

/Users/mitch/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.2/lib/rspec/core/hooks.rb:591:in `extract_scope_from': You must explicitly give a scope (example, context) or scope alias (each, all) when using symbols as metadata for a hook. (ArgumentError)
    from /Users/mitch/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.2/lib/rspec/core/hooks.rb:578:in `scope_and_options_from'
    from /Users/mitch/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.2/lib/rspec/core/hooks.rb:449:in `register'
    from /Users/mitch/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.2/lib/rspec/core/hooks.rb:272:in `after'
    from /Users/mitch/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.2/lib/rspec/core/configuration.rb:1651:in `after'
    from /Users/mitch/railsdev/v4-catprint/spec/spec_helper.rb:193:in `block in <top (required)>'
    from /Users/mitch/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.4.2/lib/rspec/core.rb:97:in `configure'
    from /Users/mitch/railsdev/v4-catprint/spec/spec_helper.rb:123:in `<top (required)>'

Here is the header of the spec_helper.rb if that helps:

require 'rails_helper'
require 'rspec'
require 'rspec/expectations'
require 'factory_girl_rails'
require 'shoulda/matchers'
require 'database_cleaner'
require 'capybara/rspec'
require 'capybara/rails'
require 'support/user_helper'
require 'support/component_test_helpers'
require 'capybara/poltergeist'
require 'billy/rspec'
require 'fixtures/doodlebin/stubs'
require 'timecop'
require "rack_session_access/capybara"
require 'rspec-steps/monkeypatching' # I get the same problems with or without this
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions