how to execute a Cucumber::Rake::Task by clicking a link on a web page.

204 views
Skip to first unread message

bk

unread,
Jan 10, 2011, 3:57:52 PM1/10/11
to sinatrarb
I have a Rakefile which runs my cucumber test suite.
My goal is to invoke these tests by simply navigating/cliking a
webpage served by Sinatra.

Here is how my app.rb looks

require 'rubygems'
require 'sinatra'
require 'cucumber'
require 'cucumber/rake/task'

get "/run" do
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "features --format progress --format html --out
results.html"
end
end

If I navigate to http://localhost:4567/run I get the following error
NoMethodError at /run
undefined method `desc' for #<Cucumber::Rake::Task:0x7056d5>
file: task.rb location: define_task line: 140

Can you please tell me what I'm doing wrong here? Or is there any
other way of doing this?


Thanks!!
BK

Sylvain Desvé

unread,
Jan 11, 2011, 3:09:09 AM1/11/11
to sina...@googlegroups.com
Hi !

Cucumber::Rake::Task.new define a task but does not execute it.
Moreover, a route definition block in Sinatra expects a valid return value (see README).

You need to define your Cucumber task somewhere in a Rakefile and then do something like :

get '/run' do
  `rake features` # Not sure, maybe you need to cd into your root directory before
end

This will run the features and show the results in the web page.

2011/1/10 bk <bkhamb...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "sinatrarb" group.
To post to this group, send email to sina...@googlegroups.com.
To unsubscribe from this group, send email to sinatrarb+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sinatrarb?hl=en.


Bharath Khambadkone

unread,
Jan 11, 2011, 8:45:10 AM1/11/11
to sina...@googlegroups.com
Thanks Sylvia,
I tried that and it worked great.

Thanks for you help!
Reply all
Reply to author
Forward
0 new messages