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 'placeholder' for Turnip::Steps::Module #62

Closed
denro opened this issue Jun 27, 2012 · 11 comments
Closed

undefined method 'placeholder' for Turnip::Steps::Module #62

denro opened this issue Jun 27, 2012 · 11 comments

Comments

@denro
Copy link

denro commented Jun 27, 2012

Hey!

looks like our placeholders aren't working with the 1.0.0 release.

we define them with:

steps_for :banners do
  step 'I fill in :banner_count :banner_type banner/banners' do |banner_count, banner_type|
    banner_count.times do |i|
      within "li.list:nth-of-type(#{i+1})" do
        fill_in 'Link', :with => "http://example.com"
        case banner_type
        when 'retina'
          attach_file "iPad Retina Banner Image", "spec/fixtures/files/valid_2x_banner.jpg"
        when 'standard'
          attach_file "iPad Banner Image", "spec/fixtures/files/valid_banner.jpg"
        end
      end
    end
  end

  placeholder :banner_count do
    match(/\d+/)      { |i| i.to_i }
    match(/another/)  { 2 }
    match(/a/)        { 1 }
  end
end

then when we load our steps we get the following error:


spec/acceptance/steps/banner_steps.rb:21:in `<module:Steps>': undefined method `placeholder' for Turnip::Steps:Module (NoMethodError)
    from spec/acceptance/steps/banner_steps.rb:1:in `<top (required)>'
    from /Users/denro/.rvm/gems/ruby-1.9.2-p320@serviceplus/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:245:in `load'
    from /Users/denro/.rvm/gems/ruby-1.9.2-p320@serviceplus/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:245:in `block in load'
    from /Users/denro/.rvm/gems/ruby-1.9.2-p320@serviceplus/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /Users/denro/.rvm/gems/ruby-1.9.2-p320@serviceplus/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:245:in `load'
    from /Users/denro/workspace/serviceplus/spec/support/turnip_steps_loader.rb:2:in `block in <top (required)>'
    from /Users/denro/workspace/serviceplus/spec/support/turnip_steps_loader.rb:2:in `glob'
    from /Users/denro/workspace/serviceplus/spec/support/turnip_steps_loader.rb:2:in `<top (required)>'
@bdmac
Copy link
Collaborator

bdmac commented Jun 27, 2012

This is just a guess since I haven't upgraded to 1.0.0 yet but have you tried moving your call to placeholder outside of your steps_for block?

@jnicklas
Copy link
Owner

Yes, that's it. placeholders have to be global.

@denro
Copy link
Author

denro commented Jun 28, 2012

thanks works!

@denro denro closed this as completed Jun 28, 2012
@gravis
Copy link

gravis commented Sep 12, 2012

Hi, I'm having the same issue with turnip 1.0.0 :

module CompaniesSteps

 step ":subject user should have the role :role" do |subject, role|
    within "table.members tr.user_#{subject.id}" do
      page.should have_content role
    end
    @company.send("#{role}s").should include subject
  end
  placeholder :subject do
    match /he/ do  @user end
    match /the user/ do @invited_user end
  end
end

which produces:

Exception encountered: #<NoMethodError: undefined method `placeholder' for #<Module:0x007fa5ed74f258>::CompaniesSteps> 

I've tried to move the placeholder to Turnip::Steps module to make it even more "global", but same error is raised.
Am I doing something wrong?

@PragTob
Copy link
Contributor

PragTob commented Sep 12, 2012

It seems that placeholder definitions can not be wrapped into a module, if you remove the module your example should work. At least it does for me :-)

Cheers!

@gravis
Copy link

gravis commented Sep 12, 2012

👍 Thanks, it works for me now. Anyway, I expect a lot of naming collisions here, since :subject might be refering to a lot of different steps. I'd prefer the placeholder to be scoped in step :)

@gravis
Copy link

gravis commented Sep 12, 2012

Sorry, I replied too quickly, the error is gone, but now I have another one: @user is nil. Placeholder being outside the module, this was expected. Double vote for scope inside the step now

@PragTob
Copy link
Contributor

PragTob commented Sep 12, 2012

Dunno how easily that can be achieved but I think it's valuable too. But I guess @jnicklas can comment on that :-)

I don't know if custom place holders were meant to return instance variables but yeah, we'll see :-)

@tarky
Copy link

tarky commented Feb 2, 2015

I also prefer the placeholder to be scoped in step or steps_for.

@nimaai
Copy link

nimaai commented Mar 10, 2017

I also prefer the placeholder to be scoped in step or steps_for.

Me too.

@marian13
Copy link

marian13 commented Dec 9, 2021

I also prefer the placeholder to be scoped in step or steps_for.

+1

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

8 participants