I'm writing a sample test with Watir where I navigate around a site with the IE class, issue queries, etc..
That works perfectly.
I want to continue by using PageContainer's methods on the last page I landed on.
For instance, using its HTML method on that page.
Now I'm new to Ruby and just started learning it for Watir.
I tried asking...
When a method being called in the success or enter phases of a state transition throw errors, what is the best way to catch this and ensure that the state reverts back to the previous state.
I'm using the AASM gem.
...
Hi,
I've been following Stuart's tutorial at
http://www.madebymany.co.uk/tutorial-for-restful_authentication-on-rails-with-facebook-connect-in-15-minutes-00523
and have been having a problem:
I get a NoMethodError in UsersController#link_user_accounts; Rails
doesn’t seem to recognize “facebook_session”. I have facebooker
installed an...
I'd like to figure out a way on how to get to the HTML result (mentioned further below) by using the following Ruby code and the Nokogiri Rubygem:
require 'rubygems'
require 'nokogiri'
value = Nokogiri::HTML.parse(<<-HTML_END)
"<html>
<body>
<p id='1'>A</p>
<p id='2'>B</p>
<h1>Bla</h1>
<p id='3'>C</p>
...
I have a simple page with a single rendered iFrame. There's a link called "Add File" and unobtrusively I would like to attach an event to the "Add File" anchor so that when clicked, it inserts a new iFrame below the existing one with the ID of the iFrame incremented.
An example of the iFrame would be:
<iframe name="uploadForm1" id="up...
Hi,
Is there a default method or class accessor that I can add to a Ruby class that get called if a accessor (Ruby like property) doesn't exit? I can then write some custom code to reply from like a array list read from a database where the value can be accessed like a accessor without me writing the accessor code (since if read from a ...
Since I've started using rspec, I've had a problem with the notion of fixtures. My primary concerns are this:
I use testing to reveal surprising behavior. I'm not always clever enough to enumerate every possible edge case for the examples I'm testing. Using hard-coded fixtures seems limiting because it only tests my code with the ve...
I have a rails application where I store created_at as datetime (standard).
I am building a form for searching and I find I have to use find_by_sql to do some complex subqueries. The form has a date range (no time) to search on for items created_at field.
The problem I find is that if I pass in just the date string for range to query......
I am working on syncing two business objects between an iPhone and a Web site using an XML-based payload and would love to solicit some ideas for an optimal routine.
The nature of this question is fairly generic though and I can see it being applicable to a variety of different systems that need to sync business objects between a web ...
Using Ruby LDAP running on Linux, I can create a new Active Directory user account without a problem. Now I want to be rename a user account username. When I try to change the sAMAccountName, it doesn't work. Is it possible to change an AD user account using Ruby LDAP? If so, how?
...
I have been using eval feature of ruby many a times. But I have heard people saying evals are nasty. When asked, why and how, I could never get a convincing reason not to use it. Are they really nasty? If yes, in what way? What are possible "safer" options to eval?
...
I have a data model something like this:
class CollectionItem < ActiveRecord::Base
# the collection_items table has columns collection_item_id, collection_id, item_id, position, etc
self.primary_key = 'collection_item_id'
belongs_to :collection
belongs_to :item
end
class Item < ActiveRecord::Base
has_many :collection_items
...
Hi
I am in the field of data crunching and very soon might make a move to the world of web programming. Although I am fascinated both by Python and Ruby as both of them seem to be having every similar styles when it comes to writing business logic or data crunching logic.
But when I start googling for web development I start inclining ...
This follows this prior question, which was answered. I actually discovered I could remove a join from that query, so now the working query is
start_cards = DeckCard.find :all, :joins => [:card], :conditions => ["deck_cards.deck_id = ? and cards.start_card = ?", @game.deck.id, true]
This appears to work. However, when I try to move th...
If I say
puts "Hello"
and decide to add an extra newline I need to do this:
puts "Hello\n"
Having this character in the string is ugly. Is there any way to do this without polluting my string?
...
cash = 100_000.00
sum = 0
cash += 1.00, sum while cash < 1_000_000.00 # underscores ignored
I found the above example in a book "Learning Ruby" but using Ruby 1.9 it doesn't compile ("interpret"?)
syntax error, unexpected ',', expecting $end
What's the comma supposed to be doing after 1.00?
Here's the full context of the example:
...
I love the Beautiful Soup scraping library in Python. It just works. Is there a close equivalent in Ruby?
...
LOOP
This works with do:
x=0
loop do puts x; x+=1; break if x == 100 end
but not with a semicolon:
x=0
loop; puts x; x+=1; break if x == 100 end
UNTIL
However, this works with 'do':
until x == 100 do puts x; x+=1 end
and with a simicolon:
until x == 100; puts x; x+=1 end
With certain Ruby syntax I have a choice of u...
Hi,
I'm writing a rake script and would like to detect (using Ruby rather than bash if possible) if the user who executed the rake script has root privileges.
If it is not root then I would like to terminate the script.
Regards,
Chris
...
temp = 98.3
begin
print "Your temperature is " + temp.to_s + " Fahrenheit. "
puts "I think you're okay."
temp += 0.1
end while temp < 98.6
In the above example, is everything between begin and end a block?
I'm still confused what a block is.
If you can't call it a block, what would you call that chunk of code between begin and end? I...