rspec2

render_views returning NoMethodError

大憨熊 提交于 2019-12-23 02:39:27
问题 I'm currently going through the Ruby on Rails Tutorial by Michael Hartl, and in Section 3.2.2 of the tutorial, he talks about using RSpec to test for the titles of the page. My tests (which I wrote myself, following his tutorial) kept failing the title tests (it can find the tag, but the title is always a blank string), and some searching on Google told me I needed to include the function render_views to pass the tests. My problem is that no matter what I try, RSpec returns a NoMethodError

rspec: undefined local variable or method `be_true'

自作多情 提交于 2019-12-22 13:48:31
问题 I am using rspec 2.4.0 and cucumber 0.6.4. I am running a simple scenario (for the sake of this question): Scenario: Simple Test When I test something with step definition: require 'rspec' require 'rspec/expectations' When /^I test something$/ do result = (1==1) result.should be_true end When I run this scenario I get the following problems: undefined local variable or method `be_true' for #<Object:0x1b3b424> (NameError) I am also using bundler to manage my dependencies. Am I doing something

How to mock/stub the config initializer hash in rails 3

依然范特西╮ 提交于 2019-12-22 10:31:13
问题 Environment : Rails 3.1.1 and Rspec 2.10.1 I am loading all my application configuration through an external YAML file. My initializer (config/initializers/load_config.rb) looks like this AppConfig = YAML.load_file("#{RAILS_ROOT}/config/config.yml")[RAILS_ENV] And my YAML file sits under config/config.yml development: client_system: SWN b2c_agent_number: '10500' advocacy_agent_number: 16202 motorcycle_agent_number: '10400' tso_agent_number: '39160' feesecure_eligible_months_for_monthly

Adding custom directories (source and spec) to autotest in a Rails 3 project

坚强是说给别人听的谎言 提交于 2019-12-22 09:26:55
问题 I have a Rails 3 app that uses RSpec2 as my testing framework, and I'm able to use autotest to watch my model and spec directories for changes and re-run my spec suite when files change. I'd like to add a directory with some custom classes in it (RAILS_ROOT/lib/some_project/lib/ .rb) and their corresponding specs (RAILS_ROOT/spec/some_project/ _spec.rb) so that autotest will automatically pick up changes to all of those files and re-run as needed. How do I get autotest to watch these files in

bundle exec rspec VS rspec spec

半腔热情 提交于 2019-12-22 05:42:06
问题 Ruby 1.9.2 Rails 3.1 Here is the problem bundle exec rspec spec/ does not work, but rspec spec/ runs ok. When I run c:\RailsInstaller\work\apptwit>bundle exec rspec spec/ (this is the directory where my app is located, so the path to spec would not need to be specified) I receive c:/RailsInstaller/work/apptwit/spec/controllers/pages_controller_spec.rb:1:in `require': no such file to load -- spec_he lper (LoadError) from c:/RailsInstaller/work/apptwit/spec/controllers/pages_controller_spec.rb

Ssetting up rspec2 task in Rakefile

蓝咒 提交于 2019-12-22 04:33:26
问题 I have a Rakefile that looks like this: require 'rspec/core/rake_task' desc "Run all RSpec tests" RSpec::Core::RakeTask.new(:spec) This isn't working though. For example, if I try to run "rake -T", I get: code/projects/bellybuster[master]% rake -T --trace (in /Users/craig/code/projects/bellybuster) rake aborted! no such file to load -- rspec/core/rake_task /Users/craig/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' /Users/craig/.rvm/rubies/ruby

path not working properly when using capybara

六月ゝ 毕业季﹏ 提交于 2019-12-21 09:08:44
问题 I'm using rails 3.0.5, rspec2 with latest capybara. Routes setup like: scope "(:locale)", :locale => /de|fr|it|en/ do resources :dossiers end In application_controller I have this: def default_url_options(options={}) options[:locale] = "es" options end So in my views I can use link_to 'test', dossier_path(1) without any problems. But when I do the same in capybara's visit it tries to use the 1 for the locale and not for the id. It only works when I use visit dossier_path(nil, 1) or visit

Factory Girl / Capybara deleting records from database mid-test?

时光毁灭记忆、已成空白 提交于 2019-12-21 07:09:36
问题 Working with RSpec & Capybara, I'm getting an interesting test failure mode which goes away with a few subtle rearrangements of lines in the test case...stuff that shouldn't matter. I'm developing my own authentication system. It is currently working and I can login/out with the browser and the session works etc etc. However, trying to test this is failing. Something is going on that I don't quite understand, which seems to depend on the order of (seemingly) unrelated calls. require 'spec

RoR: testing an action that uses http token authentication

大憨熊 提交于 2019-12-20 08:41:39
问题 I'm trying to test a controller that's using an http token authentication in the before filter. My problem is that it works ok wheh I use curl to pass the token, but in my tests it always fails (I'm using rspec btw). Tried a simple test to see if the token was being passed at all, but it seems like it's not doing so. Am I missing anything to get the test to actually pass the token to the controller? Here's my before filter: def restrict_access authenticate_or_request_with_http_token do |token

capybara/selenium with rspec before :all hook

≡放荡痞女 提交于 2019-12-18 14:53:53
问题 In an attempt to reduce the number of page visits with selenium, I wanted to call the visit method from a before :all hook and run all my examples with a single page load. However, when I specify before :all vs before :each , the browser opens, but the url is never visited. Below is a simplified and contrived example... describe 'foobar', :js => true do before :all do Capybara.default_wait_time = 10 obj = Factory(:obj) visit obj_path(obj) end it 'should have foo' do page.should have_content(