When I log into my ruby applicaiton, the first page url is http://localhost:3000/tree_display/list. So , when I run the test to assert the same, I am getting this error.
[user1 project]$ rake test
DEPRECATION WARNING: String based terminators are deprecated, please use a lambda. (called from included at /home/.gem/ruby/2.1.3/bundler/gems/authlogic-09163c7d2a9b/lib/authlogic/session/callbacks.rb:66)
DEPRECATION WARNING: String based terminators are deprecated, please use a lambda. (called from included at /home/.gem/ruby/2.1.3/bundler/gems/authlogic-09163c7d2a9b/lib/authlogic/session/callbacks.rb:67)
Started
FAIL["test_login_and_access_bookmarks/managing_bookmarks", BookmarksTest, 0.678676891]
test_login_and_access_bookmarks/managing_bookmarks#BookmarksTest (0.68s)
expecting <"tree_display/list"> but rendering with <["content_pages/view", "shared/_header", "shared/_navigation", "auth/_login", "shared/_flash_messages", "shared/_footer_message", "layouts/application"]>
test/integration/bookmarks_test.rb:15:in `block in <class:BookmarksTest>'
1/1: [=========================================================================================================] 100% Time: 00:00:00, Time: 00:00:00
Finished in 0.68149s
1 tests, 2 assertions, 1 failures, 0 errors, 0 skips
[user1 project]$
It is rendering with <["content_pages/view", "shared/_header", "shared/_navigation", "auth/_login", "shared/_flash_messages", "shared/_footer_message", "layouts/application"]>. These are supposed to be on the first page when I enter the username and password and then I go to http://localhost:3000/tree_display/list
I noticed that the session variable contains this :#host="www.example.com",
What is the problem here? Why is it not rendering the tree_display/list? Appreciate any help.
Probably login failed in your test or it is taking time to login while you are asserting on previous page in the test. Try adding delays in assertion and login step.
Related
describe Item do
it 'calculates price according to a special formula' do
item = Item.new('kettle', price: 200)
item.price.should == 212
end
end
Deprecation Warnings:
Using should from rspec-expectations' old :should syntax without explicitly enabling the syntax is deprecated. Use the new :expect syntax or explicitly enable :should with
config.expect_with(:rspec) { |c| c.syntax = :should } instead. Called from E:/work/storeapp/spec/item_spec.rb:9:in `block (2 levels) in '.
If you need more of the backtrace for any of these deprecations to
identify where to make the necessary changes, you can configure
config.raise_errors_for_deprecations!, and it will turn the
deprecation warnings into errors, giving you the full backtrace.
1 deprecation warning total
Finished in 0.00505 seconds (files took 0.17058 seconds to load)
1 example, 0 failures
How this warning can be avoided?
Write the test in a new style:
expect(item.price).to eq 212
BTW. it seems you might doing sth quite risk/confusing. Once you assign 200 to the attribute, it will be more than confusing to see another value returned by a getter with a same name. Have you considered leaving the original method alone and defining a new one instead (like price_with_vat)?
i try to create internet shop from "Agile Web Development with Rails 4". When i write 'rake test', i get this message:
$ rake test
Run options: --seed 54737
# Running:
........F...F
Finished in 0.279167s, 46.5671 runs/s, 118.2088 assertions/s.
1) Failure:
ProductTest#test__product_is_not_valid_without_a_unique_title_-_i18n [/Users/roni/Coding/Ruby/depot/test/models/product_test.rb:82]:
--- expected
+++ actual
## -1 +1 ##
-["translation missing: en.activerecord.errors.messages.taken"]
+["has already been taken"]
2) Failure:
ProductTest#test_product_price_must_be_positive [/Users/roni/Coding/Ruby/depot/test/models/product_test.rb:25]:
Failed assertion, no message given.
13 runs, 33 assertions, 2 failures, 0 errors, 0 skips
It's product_test.rb
http://pastebin.com/1f5zkDwa
Please, help me, what i did wrong?
It appears the location of error messages for the 'already taken' case has been changed in Rails 4 and the book must have missed this update.
The error message has been moved to the namespace where also other validation error messages of ActiveModel reside, to the errors.messages. Hence, the 'taken' error message was set under key activerecord.errors.messages.taken, but in Rails 4 it is under errors.messages.taken.
If you update line 82 in your test with the new key, the test should pass.
Just like the message states, you don't have translation for en.activerecord.errors.messages.taken in config/locales.
Also, in assert_equal method, first argument is actual value, while second argument is expected value. So it should be:
assert_equal product.errors[:title], ["has already been taken"]
in this case.
I'm using Gallio/MbUnit framework for my web testing, and the tests are kicked off from Jenkins. I've installed the Gallio/MbUnit plugin and it's publishing the xml report. I'm trying to find a way to display test log or console messages in the "Test Result" section so the team can easily read failures instead of digging into the "Console Output" for any failed test run.
When I run these Gallio/MbUnit tests from my local machine using Icarus everything is pretty nicely formatted, but not so much with Jenkins. I'd like to keep using it and improve how we display the errors. Suggestions?
For a failed test:
Failed
...MainMenuTests.AcctClaimsItems
Failing for the past 4 builds (Since Failed#128 )
Took 47 sec.
add description
Error Message
Expected value to be false.Actual Value : d:\Jenkins\jobs\...\workspace\WebTesting\Base\Helpers.cs:line 90d:\Jenkins\jobs\...\workspace\WebTesting\TigerEye\Tests\MainMenuTests.cs:line 329true
Stacktrace
at WebTesting.Base.Helpers.Click(IWebDriver driver, IWebElement element) in
From the raw console output:
Start time: 4:21 PM
Initializing the runtime and loading plugins.
Verifying test files.
Initializing the test runner.
Running the tests.
[failed] Test WebTesting/MainMenuTests/AcctClaimsItems
Expected value to be false.
Found System.Web Exception after click to url
.../Accounting/FETReport.aspx
Actual Value : true
at WebTesting.Base.Click(IWebDriver driver, IWebElement element) in d:\Jenkins\jobs\...\workspace\WebTesting\Base\StaticHelpers.cs:line 90 at WebTesting...\Tests.MainMenuTests.AcctClaimsItems() in d:\Jenkins\jobs\...\workspace\WebTesting\TigerEye\Tests\MainMenuTests.cs:line 329
Code:
if (driver.PageSource.Contains("System.Web - Exception"))
{
TestLog.Write("Found exception on page {0}", driver.Url);
TestLog.Write(driver.PageSource.ToString());
Console.Write("Found exception on page {0}", driver.Url);
Console.Write(driver.PageSource.ToString());
Assert.IsFalse(driver.PageSource.Contains("System.Web - Exception"), "Found System.Web Exception after click to url {0}",driver.Url);
}
There is a general console parsing plugin you can use to add a post build step https://wiki.jenkins-ci.org/display/JENKINS/Log+Parser+Plugin
Can I get somehow a deeper Error backtrace when I run
jasmine-headless-webkit
Running Jasmine specs...
..F
FAIL: 3 tests, 1 failure, 0.019 secs.
(/Users/User/Development/project/spec/javascripts/modal_spec.coffee:14)
TypeError: 'undefined' is not a function
I want to know where exactly in the JS the error occurs. A nice backtrace would be perfect.
As pointed out here, you can use
jasmine-headless-webkit --runner-out ~/Desktop/jasmine-out.html
to generate a nice report with nice backtrace. Just open the generated html in your favorite browser
For some reason I keep getting a response code of 500 when I run cucumber, even though all the tests pass. The error occurs randomly for different tests, every time I run it. Sometimes all tests pass as well.
I thought it was a memory issue, so I tried restarting my computer, but that didn't do anything.
An example of the error is:
And I follow "link" # features/step_definitions/web_steps.rb:33
Failed. Response code = 500. Response message = Internal Server Error. (ActiveResource::ServerError)
./app/controllers/companies_controller.rb:23:in `show'
./features/step_definitions/web_steps.rb:35
./features/step_definitions/web_steps.rb:14:in `with_scope'
./features/step_definitions/web_steps.rb:34:in `/^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/'
features/manage_sites.feature:256:in `And I follow "link"'
It seems related to the tagging feature. I was using the #wip tag, and when I moved it around, it would cause the sporadic 500 errors. Removing all #wip tags makes all the tests pass.
I could be wrong though. I'll need to try and replicate it consistently.
Would anybody be able to help?