I have a few tests for simple tags like or the results are correct but the rspec tests are failing. I am able to validate that the output is correct using save_and_open_page but I can't understand why the rspec tests don't view this as valid output!?
Can you spot what's wrong? Thanks!
Spec Code
it { save_and_open_page; should have_selector('title', text: "CredSimple - Sign in") }
Resulting Failure Messages
Failure/Error: it { save_and_open_page should have_selector('title', text: "CredSimple - Sign in") }
expected css "title" with text "CredSimple - Sign in" to return something
The save_and_open_page confirms that the page has the title that the test is seeking:
<title>CredSimple - Sign in</title>
Related
I have this feature test in rspec
fill_in "Name", "title"
#fill_in "Body", "my blog" # this is the old implementation before tinymce
within_frame("mce_0_ifr") do
page.driver.browser.find_element(:id, 'tinymce').send_keys("blog 123")
puts page.html
end
click_button "Submit"
From the output I can clearly see that the word "blog 123" was written in the body via
<body id="tinymce"><p>blog 123</p></body>
But I get a test fail because it does not create a new blog post.
Turns out the code is fine. I was getting an error due to tinymce and html5 required validation not working together. Therefore the data is never sent, and capybara moves on to the next expect thus rendering an error. Just incase someone get's into this problem I'll post how I solved it.
<script>
tinymce.init({
selector: "textarea.tinymce",
editor.on('change', function () {
editor.save();
})
})
</script>
So, I have a facebook App that I am testing. I'd like to test a user's interaction on the app, and I'm having an issue.
The user flow that I'm testing is relatively simple: when a user comes to the in-page facebook app, if they already like the page in which the app is located they will see x-content, if they have not yet liked the page, they will be met with a like gate. My goal is to confirm that my users are able to see certain text once they have like the facebook page.
my test:
describe "facebook" do
it "visit and like page", :vcr do
Capybara.current_driver = :selenium
visit "https://www.facebook.com/pages/Testpage/433439410073990?id=433439410073990&sk=app_454512097948559"
within('#login_form') do
fill_in "email", with: FB_EMAIL
fill_in "pass", with: FB_PASSWORD
click_on "Log In"
end
page.should have_content('Testpage')
within('#timelineHeadlineLikeButton') do
click_on 'like'
end
end
end
my problem is that I can't figure out how to get capybara to like the page.
How are you integration testing you facebook applications?
I don't have the complete example.
test.rb
(You can add it to a initializer and add it if the enviroment is test).
OmniAuth.config.test_mode = true
FACEBOOK_INFO = {
"id"=> "220449",
"email" => "nypee#facebook.com",
}
OmniAuth.config.mock_auth[:facebook] = {
"uid" => '112345',
"provider" => 'facebook',
"user_info" => {"name" => "Nype Aylor", "nickname" => 'Aylor'},
"credentials" => {"token" => 'plataformatec'},
"extra" => {"user_hash" => FACEBOOK_INFO}
}
This simulates the call to omniauth.
So in your test, when you simulate a click to the facebook button,
the response you will get is the one from
OmniAuth.config.mock_auth[:facebook].
I think is the best way to integrate testing with Facebook
I have a test using shoulda that is failing for reasons I don't understand. Any idea what the fix is for this? I hardcoded the array for testing purposes.
All my other shoulda matcher based tests are working fine.
Validation
validates_inclusion_of :status, :in => ["Active", "Closed"]
Test:
it { should ensure_inclusion_of(:status).in_array(["Active", "Closed"]) }
Failure
Failure/Error: it { should ensure_inclusion_of(:status).in_array(["Active", "Closed"]) }
["Active", "Closed"] doesn't match array in validation
Looking at the source code for that matcher:
https://github.com/thoughtbot/shoulda-matchers/blob/master/lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb#L88
Do you have another validation which prevents nil or blank values for :status?
I am trying to test with has_link? in my spec test, here is my test:
page.has_link?('next_page', {}).should == true
but, the test always fail, although the link with id 'next_page' dose exist!
the strange thing is that have_content always works fine, here is how I implement it:
page.should have_content("some text")
Can you help me please ? what I am missing here ?
EDIT
Here is the resulted link in the page:
<a id="next_page" href="javascript: void(0)" onclick="javascript: void(0)" style="color: #888888">Next</a>
I think you should do :
page.has_link? "next_page"
or
page.has_link? "next_page", url_path
You can try below sample -
it "should have logout link" do
expect(page).to have_link('Logout')
end
I do this with:
rendered.should have_link("Teams", :href => teams_path)
We're using code that we've used before, so I suspect that this may be site-related. In using a standard:
FB.ui(
{
method: 'feed',
app_id: '<?= $LDP->config->facebook->id ?>',
name: 'Post Name',
link: flink,
picture: "https://www.domain.ca/templates/visual/images/share.gif",
caption: "Caption",
description: 'Join the fun today!',
actions: [
{ name: "Check it out!", link: flink }
]
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
It first displays the expected share dialog, and when you click the button at bottom right to go through with the stream publication, a new popup appears with:
Title: Require Captcha
unknown error
Security Check
please enter the text below
[captcha appears]
The only button is "Ok". Correctly solving the Captcha results in a crash (Facebook servers throwing a 500 error).
Any ideas?
I'm experiencing this too. I can confirm that changing the domain in the link makes it all good.
I got a parallel domain for our app and after three days the same Captcha with "Unknown error" appeared. Best of all – if a user gives the correct Captcha words the post will still fail. This is pretty annoying and we're getting complaints from our users.
Turns out this is a bug with Facebook (broken captcha issue). The pop-up is an innate anti-spam system, but people should be able to succeed with the CAPTCHA. I'd filed a private bug with Facebook, and it's slated to be fixed apparently.
Try calling FB.init() before calling FB.ui() to see if that helps get things in sync. Also be sure to specify the channelUrl in the init call too.