I'd recommend you to move your browser-based specs to requests/integration 
directory instead, because this is what rspec-rails expects and gives you 
some additional helpers. Here's the relevant code:
https://github.com/rspec/rspec-rails/blob/master/lib/rspec/rails/example.rb#L46-L51

Also, in that way you don't have to change the watir-rspec config as well.

Jarmo

On Thursday, March 20, 2014 3:27:19 PM UTC+2, Arjen Ruiterkamp wrote:
>
> Ok, the problem apparently was with the tests being in 
> the/spec/acceptancefolder. The Rspec configuration isn't loaded for custom 
> folders by default..
>
> Basically I had to change all the config.include lines in spec_helper.rbfrom:
> config.include Watir::RSpec::Helper, :type => :request
> to
> config.include Watir::RSpec::Helper, :type => :acceptance 
>
> and in google_spec.rb change:
> describe "Google" do
> to
> describe "Google", :type => :acceptance do
>
> On Wednesday, March 19, 2014 2:18:35 PM UTC+1, Arjen Ruiterkamp wrote:
>>
>> Hello,
>>
>> I am fairly new to Ruby and trying to setup some acceptance tests using 
>> the watir-rspec gem.
>>
>> Now https://github.com/watir/watir-rspec states:
>>
>>    - No need to use the @browser or $browser variables when executing 
>>    browser methods.
>>
>> However, this doesn't seem to work for me.
>>
>> What I've done so far:
>> rails new hello_world
>>
>> Then added to the gemfile:
>> group :test do
>>   gem "rspec-rails"
>>   gem "watir-rspec"
>>   gem "watir-rails"
>> end
>>
>> Execute:
>> bundle install
>> rails generate rspec:install
>> watir-rspec install
>>
>> This all seems to work fine so far
>>
>> Now I created a file in the spec folder: /spec/acceptance/google_spec.rband 
>> added the watir-rspec example:
>>
>> require "spec_helper"
>> describe "Google" do
>>   before { goto "http://google.com"; }
>>
>>   it "has search box" do
>>     text_field(:name => "q").should be_present
>>   end
>>
>>   it "allows to search" do
>>     text_field(:name => "q").set "watir"
>>     button(:id => "gbqfb").click
>>     results = div(:id => "ires")
>>     results.should be_present.within(2)
>>     results.lis(:class => "g").map(&:text).should be_any { |text| text =~ 
>> /watir/ }
>>     results.should be_present.during(1)
>>   endend
>>
>> Now when I run rspec I get the following output:
>>
>> Results will be saved to tmp/spec-results/index.html
>> FF
>>
>> Failures:
>>
>>   1) Google has search box
>>      Failure/Error: before { goto "http://google.com"; }
>>      NoMethodError:
>>        undefined method `goto' for 
>> #<RSpec::Core::ExampleGroup::Nested_1:0x5715a50>
>>      # ./spec/acceptance/google_spec.rb:6:in `block (2 levels) in <top 
>> (required)>'
>>
>>   2) Google allows to search
>>      Failure/Error: before { goto "http://google.com"; }
>>      NoMethodError:
>>        undefined method `goto' for 
>> #<RSpec::Core::ExampleGroup::Nested_1:0x57c86d0>
>>      # ./spec/acceptance/google_spec.rb:6:in `block (2 levels) in <top 
>> (required)>'
>>
>> Finished in 0.051 seconds
>> 2 examples, 2 failures
>>
>> Failed examples:
>>
>> rspec ./spec/acceptance/google_spec.rb:8 # Google has search box
>> rspec ./spec/acceptance/google_spec.rb:12 # Google allows to search
>>
>> Obviously this can be solved by adding the browser variables but it 
>> should be possible without.. right?
>>
>> Relevant gem versions:
>> Using rspec-core (2.14.8)
>> Using rspec-expectations (2.14.5)
>> Using rspec-mocks (2.14.6)
>> Using rspec (2.14.1)
>> Using rspec-rails (2.14.1)
>> Using watir-classic (4.0.1)
>> Using watir-webdriver (0.6.8)
>> Using watir (5.0.0)
>> Using watir-rails (1.0.3)
>> Using watir-rspec (1.1.2)
>>
>> Regards,
>> Arjen
>>
>

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

[email protected]
http://groups.google.com/group/watir-general
[email protected]

--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to