RSpec integration for object oriented acceptance testing with bbq.
Add bbq-rspec
to your Gemfile
:
gem "bbq-rspec"
Run install generator:
bundle exec rails generate bbq:install
Require BBQ in spec/spec_helper.rb:
require "bbq/rspec"
bundle exec rails g bbq:test MyFeatureName
bundle exec rake spec:acceptance
class TestUser < Bbq::TestUser
def email
@options[:email] || "[email protected]"
end
module Buyer
def ask_question(question)
fill_in "question", :with => question
fill_in "email", :with => email
click_on("Ask")
end
def go_to_page_and_open_widget(page_url, &block)
go_to_page(page_url)
open_widget &block
end
def go_to_page(page_url)
visit page_url
wait_until { page.find("iframe") }
end
def open_widget
within_widget do
page.find("#widget h3").click
yield if block_given?
end
end
def within_widget(&block)
within_frame(widget_frame, &block)
end
def widget_frame
page.evaluate_script("document.getElementsByTagName('iframe')[0].id")
end
end
end
feature "ask question widget" do
let(:user) {
user = TestUser.new(:driver => :webkit)
user.roles('buyer')
user
}
scenario "as a guest user, I should be able to ask a question" do
user.go_to_page_and_open_widget("/widget") do
user.ask_question "my question"
expect(user).to see("Thanks!")
end
end
end
- Fork it ( https://github.com/drugpl/bbq-rspec/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request