Sha256: b5dc804874e8e4d7ae77a0d778327f5756467184368cdf8e90c93564c00a4570

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

$:.unshift("lib/client")
$:.unshift("spec")
require 'spec_helper'
require 'haml'
require "aphro"

describe Aphro do
  def view name
    content = File.read "spec/fixtures/#{name}.html.haml"
    Haml::Engine.new(content).render
  end

  let(:twitter) do
    Aphro.client "http://localhost:3000/"
  end

  it "initializes with a site" do
    ->{Aphro::Client.new "http://localhost:3000"}.should_not raise_error ArgumentError
    ->{Aphro::Client.new }.should raise_error ArgumentError
  end

  describe "#actions" do
    it "gets the next available actions in the current state" do
      twitter.actions.should == {sign_up: {method: :get},
                                 sign_in: {method: :post}}
    end
  end

  describe "#attributes" do
    it "returns the required attributes for an action" do
      attributes = twitter.attributes_for :sign_in

      attributes.should == %w(email password)
    end
  end

  describe "#method_missing" do
    it "responds to the current available actions" do
      params = {email: "mark@example.com", password: "password"}
      twitter.sign_in params
    end

    it "updates the state and available actions" do
      params = {email: "mark@example.com", password: "password"}
      twitter.sign_in params

      twitter.actions.should == [read_messages: {method: :get},
                                 tweet:         {method: :post}]

    end

    it "raises a no method error" do
      ->{twitter.imaginary_action}.should raise_error NoMethodError
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aphro-0.0.1 spec/aphro_spec.rb