Nice post Erik. I am wondering how did you get around the admin login?
I'm using this:
u = User.create! :name => 'Administrator', :login => 'admin',
:password => 'radiant', :password_confirmation => 'radiant'
visit("/admin/login")
fill_in("Username", "admin")
fill_in("Password", "radiant")
click_button "Login"
but the outcome is always "Invalid username or password.".
Cheers,
Enrico
2009/2/14 Erik Ostrom <[email protected]>:
> I'm doing what it says in the subject line, and I thought I'd post some
> notes and links. For those who don't know, Cucumber (http://cukes.info/) is
> a BDD tool, successor to RSpec's story runner, that lets you describe
> desired behavior ("features") in something that looks like human language,
> and then write the code that defines the behavior ("steps") in Ruby. Webrat
> (http://github.com/brynary/webrat/tree/master) is an acceptance testing tool
> that lets you write steps that emulate browser interaction - clicking links,
> filling in forms - without the overhead of actually firing up a browser.
> You all know what Radiant is.
>
> (I'm working with Radiant 0.6.9, unfortunately, because I want my extension
> to support an existing site. But I suspect the basic steps will apply to
> 0.7.)
>
>
>
> The basic setup went pretty quickly. The instructions for using Cucumber
> with Rails (http://wiki.github.com/aslakhellesoy/cucumber/ruby-on-rails) go,
> roughly:
>
> - install a bunch of gems
> - create a Rails project (I already had a Radiant project)
> - run the cucumber generator
>
> In my case, script/generate didn't know about Cucumber, I guess because
> Radiant looks for generators in other places. So I created a new Rails
> project, ran the generator there, and copied the files that looked useful
> into my Radiant extension. I'm reconstructing this from the git commit - it
> looks like the files were:
>
> - features/step_definitions/webrat_steps.rb
> - features/support/paths.rb
> - features/support/env.rb
>
> I modified env.rb in two ways:
>
> - The path to config/environment is three steps higher (../../../).
> - Load fixtures from spec/ (see
> http://wiki.github.com/aslakhellesoy/cucumber/fixtures).
>
> That was pretty much it - I'm now able to start writing features and steps.
>
>
>
> There was one major hitch. I wrote a step definition that goes like this:
>
> When /^I visit the "(.+)" admin page$/ do |page|
> visit page_edit_path(Page.find_by_title(page))
> end
>
> ... and a feature that goes like this, in part:
>
> When I visit the "Anno Domini" admin page
> And I fill in "Address" with "366 So. First Street, San Jose, CA 95113"
> And I press "Save and Continue Editing"
>
> You can guess what that does. On the last step, when the form was
> submitted, I got the error "Couldn't find Page without an ID". The edit
> form, in the test environment only, was being created with
> action="/admin/page/edit" (note the missing page ID) instead of
> "/admin/pages/edit/3".
>
> Turns out that in the test environment, Radiant adds its own test fixtures
> to the extension paths. If you're configured to load all extensions, that
> will include BasicExtension, which sets up a default route that gets in the
> way of page_edit_path, and probably a lot of other paths.
>
> For anyone else traveling this path, the way I got around this was to ensure
> my extension was the only one loaded, by putting this line in
> config/environment.rb in my project:
>
> config.extensions = [ :locations ] if config.environment == 'test'
>
> There may be a better way, but this is probably good enough. Looking
> forward, I see that in 0.7, the route that caused the trouble is commented
> out.
>
>
>
> Hope this is useful. When the extension is a little more functional, I plan
> to put it up on Github, so there'll be some sample code. Meantime, Aslak
> Hellesoy's Ba extension (http://github.com/aslakhellesoy/ba/tree/master) is
> I think a little behind current practices, but it's where I got most of my
> ideas.
>
> --Erik Ostrom
> [email protected]
> _______________________________________________
> Radiant mailing list
> Post: [email protected]
> Search: http://radiantcms.org/mailing-list/search/
> Site: http://lists.radiantcms.org/mailman/listinfo/radiant
>
--
Enrico Teotti
IT consultant, accessible web sites and web applications
Sydney, NSW, Australia
[email protected]
mobile (IT) +393286590765
mobile (AU) +00610416748450
http://www.teotti.com
_______________________________________________
Radiant mailing list
Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant