Not Able to Implement for Then Statement in cucumber

22 views
Skip to first unread message

abhisheksreepal

unread,
Oct 24, 2009, 2:56:09 PM10/24/09
to Cukes
Hi,

I am using
Windows Xp
cucumber-0.4.2
watir-1.6.2
My code below is working fine but I always get PENDING Statement for
my last step.
Anything in the code which is missing ?


CODE:
class GoogleSearch
def initialize(browser)
@browser = browser
end
def goto
@browser.goto 'http://www.google.com/'
end
def search(text)
@browser.text_field(:name, 'q').set(text)
@browser.button(:name, 'btnG').click
end
end
Given 'I am on the Google search page' do
@page = GoogleSearch.new(@browser)
@page.goto
end
When /I search for "(.*)"/ do |query|
@page.search(query)
end
Then /^I should see$ / do
@browser.link(:url, url).text.should == "abhi"
end



OUTPUT:

Feture: Serch
In order to lern more
s n informtion seeker
I wnt to find more informtion

Scenrio: Find wht I'm looking for # fetures/serch.feture:6
Given I m on the Google serch pge # fetures/step_definition/
serch.rb:18
When I serch for "cucumber github" # fetures/step_definition/
serch.rb:23
Then I should see # fetures/serch.feture:9

1 scenrio (1 undefined)
3 steps (1 undefined, 2 pssed)
0m3.797s

You cn implement step definitions for undefined steps with these
snippets:

Then /^I should see$/ do
pending
end

aslak hellesoy

unread,
Oct 24, 2009, 6:50:09 PM10/24/09
to cu...@googlegroups.com
On Sat, Oct 24, 2009 at 8:56 PM, abhisheksreepal
<abhishe...@gmail.com> wrote:
>
> Hi,
>
> I am using
> Windows Xp
> cucumber-0.4.2
> watir-1.6.2
> My code below is working fine but I always get PENDING Statement for
> my last step.
> Anything in the code which is missing ?
>

Looks right to me. Can you put your code (.feature file and search.rb)
up at http://gist.github.com/ or http://pastie.org/ please?

PS - unrelated to your problem, but see
http://wiki.github.com/aslakhellesoy/cucumber/troubleshooting for a
workaround to get 'a' characters working on windows.

Aslak

aslak hellesoy

unread,
Oct 24, 2009, 6:52:39 PM10/24/09
to cu...@googlegroups.com
I see you have /^I should see$ /

Just lose the space between $ and /

Aslak

abhisheksreepal

unread,
Oct 25, 2009, 2:42:36 AM10/25/09
to Cukes
Hi Aslak,

Thanks for the reply.I have added Search.feature and search.rb to
"http://gist.github.com/" (gist: 217938)
Even When I lose Space between $ and /, I will still get "Pending"
You can implement step definitions for undefined steps with these
snippets:
Then /^I should see$/ do
pending
end


"Missing 'a' in the command shell "
As of now I will just do this chcp 1252 and execute my cucumber
feature.

aslak hellesoy

unread,
Oct 25, 2009, 6:32:41 AM10/25/09
to cu...@googlegroups.com
On Sun, Oct 25, 2009 at 8:42 AM, abhisheksreepal
<abhishe...@gmail.com> wrote:
>
> Hi Aslak,
>
> Thanks for the reply.I have added Search.feature and search.rb to
> "http://gist.github.com/" (gist: 217938)

Thanks. Hint: You can paste links into emails: http://gist.github.com/217938

> Even When I lose Space between $ and /, I will still get "Pending"

Really? You still have a space in there on line 22. Try again.

It hurts a littlre to read your code. Some general Ruby tips: I
recommend you start indenting your code with 2 spaces. Also - have an
empty line between methods and step definitions. And never use capital
letters in file names.

abhisheksreepal

unread,
Oct 25, 2009, 8:38:39 AM10/25/09
to Cukes
Hi Aslak,

Thanks for the Ruby tips. I apologize for my Code format since i am
still a novice.I'll Refactor it
The issue is rectified now.I had ran the code without saving i think
(My mistake).

But One more thing, I was getting an error message when i remove space
between $ and /.(I might be wrong saying this is the root cause). But
please can you tell me what was the problem.

Initially i was getting this error message(added below) when i removed
space between $ and /.
I have just pasted the error message which i was getting.



Output:

Feature: Search
In order to learn more
As an information seeker
I want to find more information

Scenario: Find what I'm looking for # features/search.feature:6
Given I am on the Google search page # features/step_definitions/
search_step
s.rb:13
When I search for "cucumber github" # features/step_definitions/
search_step
s.rb:17
unknown property or method `document'
HRESULT error code:0x80010108
The object invoked has disconnected from its clients.
(WIN32OLERunti
meError)
./features/step_definitions/search_steps.rb:9:in `search'
./features/step_definitions/search_steps.rb:18:in `/I search for
"(.*)"/'
features/search.feature:8:in `When I search for "cucumber
github"'
Then I should see # features/step_definitions/
search_step
s.rb:20

Failing Scenarios:
cucumber features/search.feature:6 # Scenario: Find what I'm looking
for

1 scenario (1 failed)
3 steps (1 failed, 1 skipped, 1 passed)
0m0.859s
rake aborted!
Command failed with status (1): [C:/Ruby/bin/ruby.exe -I "C:/Ruby/lib/
ruby/...]

(See full trace by running task with --trace)



.

aslak hellesoy

unread,
Oct 25, 2009, 9:13:30 AM10/25/09
to cu...@googlegroups.com
On Sun, Oct 25, 2009 at 2:38 PM, abhisheksreepal
<abhishe...@gmail.com> wrote:
>
> Hi Aslak,
>
> Thanks for the Ruby tips. I apologize for my Code format since i am
> still a novice.I'll Refactor it
> The issue is rectified now.I had ran the code without saving i think
> (My mistake).
>
> But One more thing, I was getting an error message when i remove space
> between $ and /.(I might be wrong saying this is the root cause). But
> please can you tell me what was the problem.
>
> Initially i was getting this error message(added below) when i removed
> space between $ and /.
> I have just pasted the error message which i was getting.
>

Now you're getting a Watir error. Try googling the error message. It's
not Cucumber related.

Aslak

George Dinwiddie

unread,
Oct 25, 2009, 11:51:52 AM10/25/09
to cu...@googlegroups.com
abhisheksreepal wrote:
> Hi Aslak,
>
> Thanks for the reply.I have added Search.feature and search.rb to
> "http://gist.github.com/" (gist: 217938)
> Even When I lose Space between $ and /, I will still get "Pending"
> You can implement step definitions for undefined steps with these
> snippets:
> Then /^I should see$/ do
> pending
> end

Could there be a space after "I should see" in the Scenario?

My general strategy is to make things looser and looser until
/something/ happens, then tighten back up to what I want. Try taking
the $ out of the Then definition and see if that works.

- George

--
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach http://www.agilemaryland.org
----------------------------------------------------------------------

abhisheksreepal

unread,
Oct 25, 2009, 2:22:35 PM10/25/09
to Cukes
Hi George Dinwiddie ,

Thanks for the reply.Aslak hellesoy had given the correct solution.(I
had done a mistake- I had executed without saving)
Issue is rectified.
Sorry for the trouble.

Reply all
Reply to author
Forward
0 new messages