I'm trying to write a Javascript spec for my Rails 3.2 application using Teaspoon (the Jasmine version). I'm trying to write a spec that does something like this
describe("Fun", function() {
var page = require('webpage').create() //ERROR
it("should be so much fun", function() {
page.open('/pageToTest/')
expect($('#HereIsTheParty')).not.toBe( undefined );
});
});
However, require('webpage') doesn't run (Error: Module name "system" has not been loaded yet for context) even though the Requirejs gem has been installed and can be accessed from the Chrome console.
My question is, can I easily get require('webpage') to run using Rails or should I be using something else? Is it maybe easier to just use Capybara since so far I've been using
describe "Fun", :type => :feature do
it "should be so much fun" do
visit '/pageToTest/'
expect(page).to have_content 'Success'
end
end
without any problems. I would however prefer using pure Javascript since in this case it's more convenient. What do you guys think? Thanks!